Debian Codegraph @

lib/tests/test_annotate.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2009 Gary van der Merwe <[email protected]>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 # Updated RJL 2020 - added b(ytes) prefix to strings where needed based
20 # upon the same usage in breezy/tests/test_annotate.py
21 # Note that although this was originally copied from the same
22 # (as per the old comment below) this now differs quite a bit
23 # and is closest to test_annotate_author_or_committer in breezy commit
24 # 7513 of 2020-06-11
25
26 from breezy.tests import TestCase, TestCaseWithTransport
27 from PyQt5 import QtCore
28 from breezy.conflicts import ConflictList
29 from breezy.plugins.qbrz.lib import tests as qtests
30 from breezy.plugins.qbrz.lib.annotate import AnnotateWindow
31
32
33 class TestAnnotate(qtests.QTestCase):
34
35 # Copied from breezy/tests/test_annotate.py
36 def create_merged_trees(self):
37 """create 2 trees with merges between them.
38
39 rev-1 --+
40 | |
41 rev-2 rev-1_1_1
42 | |
43 +------+
44 |
45 rev-3
46 """
47
48 tree1 = self.make_branch_and_tree('tree1')
49 self.build_tree_contents([('tree1/a', b'first\n')])
50 tree1.add(['a'], ids=[b'a-id'])
51 tree1.commit('a', rev_id=b'rev-1', committer="[email protected]", timestamp=1166046000.00, timezone=0)
52
53 tree2 = tree1.controldir.sprout('tree2').open_workingtree()
54 self.build_tree_contents([('tree1/a', b'first\nsecond\n')])
55 tree1.commit('b', rev_id=b'rev-2', committer='[email protected]', timestamp=1166046001.00, timezone=0)
56
57 self.build_tree_contents([('tree2/a', b'first\nthird\n')])
58 tree2.commit('c', rev_id=b'rev-1_1_1', committer="[email protected]", timestamp=1166046002.00, timezone=0)
59
60 conflicts = tree1.merge_from_branch(tree2.branch)
61 if isinstance(conflicts, int): # brz < 3.2
62 self.assertEqual(1, conflicts)
63 else:
64 self.assertEqual(1, len(conflicts))
65
66 self.build_tree_contents([('tree1/a', b'first\nsecond\nthird\n')])
67 tree1.set_conflicts(ConflictList())
68 tree1.commit('merge 2', rev_id=b'rev-3', committer='[email protected]', timestamp=1166046003.00, timezone=0)
69 return tree1, tree2
70
71 def test_just_show_annotate(self):
72 tree1, tree2 = self.create_merged_trees()
73 win = AnnotateWindow(tree1.branch, tree1, tree1, 'a', b'a-id')
74 self.addCleanup(win.close)
75 win.show()
76 # If you want to see the output, add a sleep after this
77 QtCore.QCoreApplication.processEvents()