annotate tests/test-simplemerge.py @ 42813:268662aac075

interfaces: create a new folder for interfaces and move repository.py in it I was trying to understand current interfaces and write new ones and I realized we need to improve how current interfaces are organised. This creates a dedicated folder for defining interfaces and move `repository.py` which defines all the current interfaces inside it. Differential Revision: https://phab.mercurial-scm.org/D6741
author Pulkit Goyal <pulkit@yandex-team.ru>
date Sun, 18 Aug 2019 00:45:33 +0300
parents 02850baddadd
children d75142ef054a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
1 # Copyright (C) 2004, 2005 Canonical Ltd
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
2 #
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
3 # This program is free software; you can redistribute it and/or modify
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
4 # it under the terms of the GNU General Public License as published by
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
5 # the Free Software Foundation; either version 2 of the License, or
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
6 # (at your option) any later version.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
7 #
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
8 # This program is distributed in the hope that it will be useful,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
11 # GNU General Public License for more details.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
12 #
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
13 # You should have received a copy of the GNU General Public License
15782
7de7630053cb Remove FSF mailing address from GPL headers
Martin Geisler <mg@aragost.com>
parents: 10413
diff changeset
14 # along with this program; if not, see <http://www.gnu.org/licenses/>.
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
15
28927
2d433fa7ff44 tests: make test-simplemerge use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28861
diff changeset
16 from __future__ import absolute_import
2d433fa7ff44 tests: make test-simplemerge use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28861
diff changeset
17
4363
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
18 import unittest
28927
2d433fa7ff44 tests: make test-simplemerge use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28861
diff changeset
19 from mercurial import (
2d433fa7ff44 tests: make test-simplemerge use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28861
diff changeset
20 error,
2d433fa7ff44 tests: make test-simplemerge use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28861
diff changeset
21 simplemerge,
2d433fa7ff44 tests: make test-simplemerge use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28861
diff changeset
22 util,
2d433fa7ff44 tests: make test-simplemerge use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28861
diff changeset
23 )
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
24
37084
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 32279
diff changeset
25 from mercurial.utils import (
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 32279
diff changeset
26 stringutil,
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 32279
diff changeset
27 )
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 32279
diff changeset
28
28927
2d433fa7ff44 tests: make test-simplemerge use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28861
diff changeset
29 TestCase = unittest.TestCase
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
30 # bzr compatible interface, for the tests
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
31 class Merge3(simplemerge.Merge3Text):
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
32 """3-way merge of texts.
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
33
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
34 Given BASE, OTHER, THIS, tries to produce a combined text
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
35 incorporating the changes from both BASE->OTHER and BASE->THIS.
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
36 All three will typically be sequences of lines."""
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
37 def __init__(self, base, a, b):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
38 basetext = b'\n'.join([i.strip(b'\n') for i in base] + [b''])
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
39 atext = b'\n'.join([i.strip(b'\n') for i in a] + [b''])
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
40 btext = b'\n'.join([i.strip(b'\n') for i in b] + [b''])
37084
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 32279
diff changeset
41 if (stringutil.binary(basetext) or stringutil.binary(atext)
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 32279
diff changeset
42 or stringutil.binary(btext)):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
43 raise error.Abort(b"don't know how to merge binary files")
6002
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
44 simplemerge.Merge3Text.__init__(self, basetext, atext, btext,
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
45 base, a, b)
abd66eb0889e merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents: 4633
diff changeset
46
4363
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
47 CantReprocessAndShowBase = simplemerge.CantReprocessAndShowBase
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
48
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
49 def split_lines(t):
28861
86db5cb55d46 pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents: 26587
diff changeset
50 return util.stringio(t).readlines()
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
51
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
52 ############################################################
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
53 # test case data from the gnu diffutils manual
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
54 # common base
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
55 TZU = split_lines(b""" The Nameless is the origin of Heaven and Earth;
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
56 The named is the mother of all things.
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4363
diff changeset
57
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
58 Therefore let there always be non-being,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
59 so we may see their subtlety,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
60 And let there always be being,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
61 so we may see their outcome.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
62 The two are the same,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
63 But after they are produced,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
64 they have different names.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
65 They both may be called deep and profound.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
66 Deeper and more profound,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
67 The door of all subtleties!
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
68 """)
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
69
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
70 LAO = split_lines(b""" The Way that can be told of is not the eternal Way;
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
71 The name that can be named is not the eternal name.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
72 The Nameless is the origin of Heaven and Earth;
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
73 The Named is the mother of all things.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
74 Therefore let there always be non-being,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
75 so we may see their subtlety,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
76 And let there always be being,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
77 so we may see their outcome.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
78 The two are the same,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
79 But after they are produced,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
80 they have different names.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
81 """)
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
82
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
83
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
84 TAO = split_lines(b""" The Way that can be told of is not the eternal Way;
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
85 The name that can be named is not the eternal name.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
86 The Nameless is the origin of Heaven and Earth;
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
87 The named is the mother of all things.
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4363
diff changeset
88
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
89 Therefore let there always be non-being,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
90 so we may see their subtlety,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
91 And let there always be being,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
92 so we may see their result.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
93 The two are the same,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
94 But after they are produced,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
95 they have different names.
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4363
diff changeset
96
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
97 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
98
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
99 """)
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
100
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
101 MERGED_RESULT = split_lines(b"""\
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 6212
diff changeset
102 The Way that can be told of is not the eternal Way;
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
103 The name that can be named is not the eternal name.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
104 The Nameless is the origin of Heaven and Earth;
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
105 The Named is the mother of all things.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
106 Therefore let there always be non-being,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
107 so we may see their subtlety,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
108 And let there always be being,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
109 so we may see their result.
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
110 The two are the same,
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
111 But after they are produced,
38645
02850baddadd tests: prevent conflict markers in test case from triggering warnings
Danny Hooper <hooper@google.com>
parents: 37892
diff changeset
112 they have different names.\
02850baddadd tests: prevent conflict markers in test case from triggering warnings
Danny Hooper <hooper@google.com>
parents: 37892
diff changeset
113 \n<<<<<<< LAO\
02850baddadd tests: prevent conflict markers in test case from triggering warnings
Danny Hooper <hooper@google.com>
parents: 37892
diff changeset
114 \n=======
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4363
diff changeset
115
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
116 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
38645
02850baddadd tests: prevent conflict markers in test case from triggering warnings
Danny Hooper <hooper@google.com>
parents: 37892
diff changeset
117 \
02850baddadd tests: prevent conflict markers in test case from triggering warnings
Danny Hooper <hooper@google.com>
parents: 37892
diff changeset
118 \n>>>>>>> TAO
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
119 """)
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
120
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
121 class TestMerge3(TestCase):
4363
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
122 def log(self, msg):
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
123 pass
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
124
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
125 def test_no_changes(self):
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
126 """No conflicts because nothing changed"""
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
127 m3 = Merge3([b'aaa', b'bbb'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
128 [b'aaa', b'bbb'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
129 [b'aaa', b'bbb'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
130
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
131 self.assertEqual(m3.find_unconflicted(),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
132 [(0, 2)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
133
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
134 self.assertEqual(list(m3.find_sync_regions()),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
135 [(0, 2,
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
136 0, 2,
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
137 0, 2),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
138 (2, 2, 2, 2, 2, 2)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
139
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
140 self.assertEqual(list(m3.merge_regions()),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
141 [(b'unchanged', 0, 2)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
142
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
143 self.assertEqual(list(m3.merge_groups()),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
144 [(b'unchanged', [b'aaa', b'bbb'])])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
145
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
146 def test_front_insert(self):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
147 m3 = Merge3([b'zz'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
148 [b'aaa', b'bbb', b'zz'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
149 [b'zz'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
150
17513
d08b333816c6 spelling: sentinel
timeless@mozdev.org
parents: 15782
diff changeset
151 # todo: should use a sentinel at end as from get_matching_blocks
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
152 # to match without zz
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
153 self.assertEqual(list(m3.find_sync_regions()),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
154 [(0, 1, 2, 3, 0, 1),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
155 (1, 1, 3, 3, 1, 1)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
156
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
157 self.assertEqual(list(m3.merge_regions()),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
158 [(b'a', 0, 2),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
159 (b'unchanged', 0, 1)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
160
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
161 self.assertEqual(list(m3.merge_groups()),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
162 [(b'a', [b'aaa', b'bbb']),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
163 (b'unchanged', [b'zz'])])
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4363
diff changeset
164
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
165 def test_null_insert(self):
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
166 m3 = Merge3([],
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
167 [b'aaa', b'bbb'],
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
168 [])
17513
d08b333816c6 spelling: sentinel
timeless@mozdev.org
parents: 15782
diff changeset
169 # todo: should use a sentinel at end as from get_matching_blocks
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
170 # to match without zz
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
171 self.assertEqual(list(m3.find_sync_regions()),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
172 [(0, 0, 2, 2, 0, 0)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
173
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
174 self.assertEqual(list(m3.merge_regions()),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
175 [(b'a', 0, 2)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
176
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
177 self.assertEqual(list(m3.merge_lines()),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
178 [b'aaa', b'bbb'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
179
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
180 def test_no_conflicts(self):
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
181 """No conflicts because only one side changed"""
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
182 m3 = Merge3([b'aaa', b'bbb'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
183 [b'aaa', b'111', b'bbb'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
184 [b'aaa', b'bbb'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
185
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
186 self.assertEqual(m3.find_unconflicted(),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
187 [(0, 1), (1, 2)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
188
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
189 self.assertEqual(list(m3.find_sync_regions()),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
190 [(0, 1, 0, 1, 0, 1),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
191 (1, 2, 2, 3, 1, 2),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
192 (2, 2, 3, 3, 2, 2)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
193
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
194 self.assertEqual(list(m3.merge_regions()),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
195 [(b'unchanged', 0, 1),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
196 (b'a', 1, 2),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
197 (b'unchanged', 1, 2)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
198
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
199 def test_append_a(self):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
200 m3 = Merge3([b'aaa\n', b'bbb\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
201 [b'aaa\n', b'bbb\n', b'222\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
202 [b'aaa\n', b'bbb\n'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
203
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
204 self.assertEqual(b''.join(m3.merge_lines()),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
205 b'aaa\nbbb\n222\n')
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
206
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
207 def test_append_b(self):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
208 m3 = Merge3([b'aaa\n', b'bbb\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
209 [b'aaa\n', b'bbb\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
210 [b'aaa\n', b'bbb\n', b'222\n'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
211
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
212 self.assertEqual(b''.join(m3.merge_lines()),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
213 b'aaa\nbbb\n222\n')
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
214
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
215 def test_append_agreement(self):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
216 m3 = Merge3([b'aaa\n', b'bbb\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
217 [b'aaa\n', b'bbb\n', b'222\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
218 [b'aaa\n', b'bbb\n', b'222\n'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
219
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
220 self.assertEqual(b''.join(m3.merge_lines()),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
221 b'aaa\nbbb\n222\n')
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
222
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
223 def test_append_clash(self):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
224 m3 = Merge3([b'aaa\n', b'bbb\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
225 [b'aaa\n', b'bbb\n', b'222\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
226 [b'aaa\n', b'bbb\n', b'333\n'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
227
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
228 ml = m3.merge_lines(name_a=b'a',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
229 name_b=b'b',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
230 start_marker=b'<<',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
231 mid_marker=b'--',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
232 end_marker=b'>>')
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
233 self.assertEqual(b''.join(ml),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
234 b'aaa\n'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
235 b'bbb\n'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
236 b'<< a\n'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
237 b'222\n'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
238 b'--\n'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
239 b'333\n'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
240 b'>> b\n'
4633
ff7253a0d1da Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4516
diff changeset
241 )
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
242
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
243 def test_insert_agreement(self):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
244 m3 = Merge3([b'aaa\n', b'bbb\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
245 [b'aaa\n', b'222\n', b'bbb\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
246 [b'aaa\n', b'222\n', b'bbb\n'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
247
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
248 ml = m3.merge_lines(name_a=b'a',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
249 name_b=b'b',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
250 start_marker=b'<<',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
251 mid_marker=b'--',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
252 end_marker=b'>>')
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
253 self.assertEqual(b''.join(ml), b'aaa\n222\nbbb\n')
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4363
diff changeset
254
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
255
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
256 def test_insert_clash(self):
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
257 """Both try to insert lines in the same place."""
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
258 m3 = Merge3([b'aaa\n', b'bbb\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
259 [b'aaa\n', b'111\n', b'bbb\n'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
260 [b'aaa\n', b'222\n', b'bbb\n'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
261
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
262 self.assertEqual(m3.find_unconflicted(),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
263 [(0, 1), (1, 2)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
264
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
265 self.assertEqual(list(m3.find_sync_regions()),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
266 [(0, 1, 0, 1, 0, 1),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
267 (1, 2, 2, 3, 2, 3),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
268 (2, 2, 3, 3, 3, 3)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
269
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
270 self.assertEqual(list(m3.merge_regions()),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
271 [(b'unchanged', 0, 1),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
272 (b'conflict', 1, 1, 1, 2, 1, 2),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
273 (b'unchanged', 1, 2)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
274
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
275 self.assertEqual(list(m3.merge_groups()),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
276 [(b'unchanged', [b'aaa\n']),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
277 (b'conflict', [], [b'111\n'], [b'222\n']),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
278 (b'unchanged', [b'bbb\n']),
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
279 ])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
280
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
281 ml = m3.merge_lines(name_a=b'a',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
282 name_b=b'b',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
283 start_marker=b'<<',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
284 mid_marker=b'--',
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
285 end_marker=b'>>')
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
286 self.assertEqual(b''.join(ml),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
287 b'''aaa
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
288 << a
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
289 111
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
290 --
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
291 222
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
292 >> b
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
293 bbb
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
294 ''')
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
295
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
296 def test_replace_clash(self):
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
297 """Both try to insert lines in the same place."""
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
298 m3 = Merge3([b'aaa', b'000', b'bbb'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
299 [b'aaa', b'111', b'bbb'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
300 [b'aaa', b'222', b'bbb'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
301
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
302 self.assertEqual(m3.find_unconflicted(),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
303 [(0, 1), (2, 3)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
304
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
305 self.assertEqual(list(m3.find_sync_regions()),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
306 [(0, 1, 0, 1, 0, 1),
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
307 (2, 3, 2, 3, 2, 3),
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
308 (3, 3, 3, 3, 3, 3)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
309
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
310 def test_replace_multi(self):
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
311 """Replacement with regions of different size."""
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
312 m3 = Merge3([b'aaa', b'000', b'000', b'bbb'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
313 [b'aaa', b'111', b'111', b'111', b'bbb'],
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
314 [b'aaa', b'222', b'222', b'222', b'222', b'bbb'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
315
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
316 self.assertEqual(m3.find_unconflicted(),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
317 [(0, 1), (3, 4)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
318
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
319
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
320 self.assertEqual(list(m3.find_sync_regions()),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
321 [(0, 1, 0, 1, 0, 1),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
322 (3, 4, 4, 5, 5, 6),
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
323 (4, 4, 5, 5, 6, 6)])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
324
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
325 def test_merge_poem(self):
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
326 """Test case from diff3 manual"""
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
327 m3 = Merge3(TZU, LAO, TAO)
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
328 ml = list(m3.merge_lines(b'LAO', b'TAO'))
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
329 self.log(b'merge result:')
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
330 self.log(b''.join(ml))
37891
a3ed6e7217c1 tests: replace use of assertEquals with assertEqual in test-simplemerge.py
Augie Fackler <augie@google.com>
parents: 37084
diff changeset
331 self.assertEqual(ml, MERGED_RESULT)
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
332
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
333 def test_binary(self):
32279
68c43a416585 tests: use context manager form of assertRaises
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28927
diff changeset
334 with self.assertRaises(error.Abort):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
335 Merge3([b'\x00'], [b'a'], [b'b'])
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
336
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
337 def test_dos_text(self):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
338 base_text = b'a\r\n'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
339 this_text = b'b\r\n'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
340 other_text = b'c\r\n'
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
341 m3 = Merge3(base_text.splitlines(True), other_text.splitlines(True),
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
342 this_text.splitlines(True))
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
343 m_lines = m3.merge_lines(b'OTHER', b'THIS')
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
344 self.assertEqual(b'<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
345 b'>>>>>>> THIS\r\n'.splitlines(True), list(m_lines))
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
346
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
347 def test_mac_text(self):
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
348 base_text = b'a\r'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
349 this_text = b'b\r'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
350 other_text = b'c\r'
4362
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
351 m3 = Merge3(base_text.splitlines(True), other_text.splitlines(True),
465b9ea02868 Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
352 this_text.splitlines(True))
37892
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
353 m_lines = m3.merge_lines(b'OTHER', b'THIS')
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
354 self.assertEqual(b'<<<<<<< OTHER\rc\r=======\rb\r'
c1bc196e021d tests: port test-simplemerge.py to Python 3
Augie Fackler <augie@google.com>
parents: 37891
diff changeset
355 b'>>>>>>> THIS\r'.splitlines(True), list(m_lines))
4363
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
356
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
357 if __name__ == '__main__':
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
358 # hide the timer
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
359 import time
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
360 orig = time.time
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
361 try:
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
362 time.time = lambda: 0
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
363 unittest.main()
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
364 finally:
2e3c54fb79a3 actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4362
diff changeset
365 time.time = orig