##// END OF EJS Templates
tests: make test-simplemerge use absolute_import
Pulkit Goyal -
r28927:2d433fa7 default
parent child Browse files
Show More
@@ -1,201 +1,200 b''
1 1 #require test-repo
2 2
3 3 $ cd "$TESTDIR"/..
4 4
5 5 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
6 6 doc/check-seclevel.py not using absolute_import
7 7 doc/gendoc.py not using absolute_import
8 8 doc/hgmanpage.py not using absolute_import
9 9 hgext/color.py not using absolute_import
10 10 hgext/eol.py not using absolute_import
11 11 hgext/extdiff.py not using absolute_import
12 12 hgext/factotum.py not using absolute_import
13 13 hgext/fetch.py not using absolute_import
14 14 hgext/fsmonitor/pywatchman/__init__.py not using absolute_import
15 15 hgext/fsmonitor/pywatchman/__init__.py requires print_function
16 16 hgext/fsmonitor/pywatchman/capabilities.py not using absolute_import
17 17 hgext/fsmonitor/pywatchman/pybser.py not using absolute_import
18 18 hgext/gpg.py not using absolute_import
19 19 hgext/graphlog.py not using absolute_import
20 20 hgext/hgcia.py not using absolute_import
21 21 hgext/hgk.py not using absolute_import
22 22 hgext/highlight/__init__.py not using absolute_import
23 23 hgext/highlight/highlight.py not using absolute_import
24 24 hgext/histedit.py not using absolute_import
25 25 hgext/largefiles/__init__.py not using absolute_import
26 26 hgext/largefiles/basestore.py not using absolute_import
27 27 hgext/largefiles/lfcommands.py not using absolute_import
28 28 hgext/largefiles/lfutil.py not using absolute_import
29 29 hgext/largefiles/localstore.py not using absolute_import
30 30 hgext/largefiles/overrides.py not using absolute_import
31 31 hgext/largefiles/proto.py not using absolute_import
32 32 hgext/largefiles/remotestore.py not using absolute_import
33 33 hgext/largefiles/reposetup.py not using absolute_import
34 34 hgext/largefiles/uisetup.py not using absolute_import
35 35 hgext/largefiles/wirestore.py not using absolute_import
36 36 hgext/mq.py not using absolute_import
37 37 hgext/rebase.py not using absolute_import
38 38 hgext/share.py not using absolute_import
39 39 hgext/win32text.py not using absolute_import
40 40 i18n/check-translation.py not using absolute_import
41 41 i18n/polib.py not using absolute_import
42 42 setup.py not using absolute_import
43 43 tests/heredoctest.py requires print_function
44 44 tests/killdaemons.py not using absolute_import
45 45 tests/md5sum.py not using absolute_import
46 46 tests/mockblackbox.py not using absolute_import
47 47 tests/printenv.py not using absolute_import
48 48 tests/readlink.py not using absolute_import
49 49 tests/readlink.py requires print_function
50 50 tests/revlog-formatv0.py not using absolute_import
51 51 tests/run-tests.py not using absolute_import
52 52 tests/sitecustomize.py not using absolute_import
53 53 tests/svn-safe-append.py not using absolute_import
54 54 tests/svnxml.py not using absolute_import
55 55 tests/test-atomictempfile.py not using absolute_import
56 56 tests/test-demandimport.py not using absolute_import
57 57 tests/test-demandimport.py requires print_function
58 58 tests/test-doctest.py not using absolute_import
59 59 tests/test-hgwebdir-paths.py not using absolute_import
60 60 tests/test-lrucachedict.py not using absolute_import
61 61 tests/test-lrucachedict.py requires print_function
62 62 tests/test-manifest.py not using absolute_import
63 63 tests/test-pathencode.py not using absolute_import
64 tests/test-simplemerge.py not using absolute_import
65 64 tests/test-trusted.py requires print_function
66 65
67 66 #if py3exe
68 67 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py
69 68 contrib/check-code.py: invalid syntax: (unicode error) 'unicodeescape' codec can't decode bytes in position *-*: malformed \N character escape (<unknown>, line *) (glob)
70 69 doc/hgmanpage.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
71 70 hgext/automv.py: error importing module: <SyntaxError> invalid syntax (commands.py, line *) (line *) (glob)
72 71 hgext/blackbox.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
73 72 hgext/bugzilla.py: error importing module: <ImportError> No module named 'urlparse' (line *) (glob)
74 73 hgext/censor.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
75 74 hgext/chgserver.py: error importing module: <ImportError> No module named 'SocketServer' (line *) (glob)
76 75 hgext/children.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
77 76 hgext/churn.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
78 77 hgext/clonebundles.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
79 78 hgext/color.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
80 79 hgext/convert/bzr.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *) (glob)
81 80 hgext/convert/common.py: error importing module: <ImportError> No module named 'cPickle' (line *) (glob)
82 81 hgext/convert/convcmd.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at bundlerepo.py:*) (glob)
83 82 hgext/convert/cvs.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *) (glob)
84 83 hgext/convert/cvsps.py: error importing module: <ImportError> No module named 'cPickle' (line *) (glob)
85 84 hgext/convert/darcs.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *) (glob)
86 85 hgext/convert/filemap.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *) (glob)
87 86 hgext/convert/git.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *) (glob)
88 87 hgext/convert/gnuarch.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *) (glob)
89 88 hgext/convert/hg.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
90 89 hgext/convert/monotone.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *) (glob)
91 90 hgext/convert/p*.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *) (glob)
92 91 hgext/convert/subversion.py: error importing module: <ImportError> No module named 'cPickle' (line *) (glob)
93 92 hgext/convert/transport.py: error importing module: <ImportError> No module named 'svn.client' (line *) (glob)
94 93 hgext/eol.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
95 94 hgext/extdiff.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
96 95 hgext/factotum.py: error importing: <ImportError> No module named 'httplib' (error at url.py:*) (glob)
97 96 hgext/fetch.py: error importing module: <SyntaxError> invalid syntax (commands.py, line *) (line *) (glob)
98 97 hgext/fsmonitor/watchmanclient.py: error importing module: <SystemError> Parent module 'hgext.fsmonitor' not loaded, cannot perform relative import (line *) (glob)
99 98 hgext/gpg.py: error importing module: <SyntaxError> invalid syntax (commands.py, line *) (line *) (glob)
100 99 hgext/graphlog.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
101 100 hgext/hgcia.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
102 101 hgext/hgk.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
103 102 hgext/histedit.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
104 103 hgext/keyword.py: error importing: <ImportError> No module named 'BaseHTTPServer' (error at common.py:*) (glob)
105 104 hgext/largefiles/basestore.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at bundlerepo.py:*) (glob)
106 105 hgext/largefiles/lfcommands.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at bundlerepo.py:*) (glob)
107 106 hgext/largefiles/lfutil.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
108 107 hgext/largefiles/localstore.py: error importing module: <ImportError> No module named 'lfutil' (line *) (glob)
109 108 hgext/largefiles/overrides.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at bundlerepo.py:*) (glob)
110 109 hgext/largefiles/proto.py: error importing: <ImportError> No module named 'httplib' (error at httppeer.py:*) (glob)
111 110 hgext/largefiles/remotestore.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at wireproto.py:*) (glob)
112 111 hgext/largefiles/reposetup.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
113 112 hgext/largefiles/uisetup.py: error importing module: <SyntaxError> invalid syntax (archival.py, line *) (line *) (glob)
114 113 hgext/largefiles/wirestore.py: error importing module: <ImportError> No module named 'lfutil' (line *) (glob)
115 114 hgext/mq.py: error importing module: <SyntaxError> invalid syntax (commands.py, line *) (line *) (glob)
116 115 hgext/notify.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
117 116 hgext/pager.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
118 117 hgext/patchbomb.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
119 118 hgext/purge.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
120 119 hgext/rebase.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at bundlerepo.py:*) (glob)
121 120 hgext/record.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
122 121 hgext/relink.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
123 122 hgext/schemes.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
124 123 hgext/share.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
125 124 hgext/shelve.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
126 125 hgext/strip.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
127 126 hgext/transplant.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at bundlerepo.py:*) (glob)
128 127 mercurial/archival.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
129 128 mercurial/branchmap.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
130 129 mercurial/bundle*.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
131 130 mercurial/bundlerepo.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
132 131 mercurial/changegroup.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
133 132 mercurial/changelog.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
134 133 mercurial/cmdutil.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
135 134 mercurial/commands.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
136 135 mercurial/commandserver.py: error importing module: <ImportError> No module named 'SocketServer' (line *) (glob)
137 136 mercurial/context.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
138 137 mercurial/copies.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
139 138 mercurial/crecord.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
140 139 mercurial/dirstate.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
141 140 mercurial/discovery.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
142 141 mercurial/dispatch.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
143 142 mercurial/exchange.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
144 143 mercurial/extensions.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
145 144 mercurial/filelog.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
146 145 mercurial/filemerge.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
147 146 mercurial/fileset.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
148 147 mercurial/formatter.py: error importing module: <ImportError> No module named 'cPickle' (line *) (glob)
149 148 mercurial/graphmod.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
150 149 mercurial/help.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
151 150 mercurial/hg.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at bundlerepo.py:*) (glob)
152 151 mercurial/hgweb/common.py: error importing module: <ImportError> No module named 'BaseHTTPServer' (line *) (glob)
153 152 mercurial/hgweb/hgweb_mod.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob)
154 153 mercurial/hgweb/hgwebdir_mod.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob)
155 154 mercurial/hgweb/protocol.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob)
156 155 mercurial/hgweb/request.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob)
157 156 mercurial/hgweb/server.py: error importing module: <ImportError> No module named 'BaseHTTPServer' (line *) (glob)
158 157 mercurial/hgweb/webcommands.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob)
159 158 mercurial/hgweb/webutil.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob)
160 159 mercurial/hgweb/wsgicgi.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob)
161 160 mercurial/hook.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
162 161 mercurial/httpclient/_readers.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
163 162 mercurial/httpconnection.py: error importing: <ImportError> No module named 'httplib' (error at __init__.py:*) (glob)
164 163 mercurial/httppeer.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
165 164 mercurial/keepalive.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
166 165 mercurial/localrepo.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
167 166 mercurial/mail.py: error importing module: <AttributeError> module 'email' has no attribute 'Header' (line *) (glob)
168 167 mercurial/manifest.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
169 168 mercurial/merge.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
170 169 mercurial/namespaces.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
171 170 mercurial/patch.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
172 171 mercurial/pure/mpatch.py: error importing module: <ImportError> cannot import name 'pycompat' (line *) (glob)
173 172 mercurial/pure/parsers.py: error importing module: <ImportError> No module named 'mercurial.pure.node' (line *) (glob)
174 173 mercurial/repair.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
175 174 mercurial/revlog.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
176 175 mercurial/revset.py: error importing module: <AttributeError> 'dict' object has no attribute 'iteritems' (line *) (glob)
177 176 mercurial/scmutil.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
178 177 mercurial/scmwindows.py: error importing module: <ImportError> No module named '_winreg' (line *) (glob)
179 178 mercurial/simplemerge.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
180 179 mercurial/sshpeer.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at wireproto.py:*) (glob)
181 180 mercurial/sshserver.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
182 181 mercurial/statichttprepo.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
183 182 mercurial/store.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
184 183 mercurial/streamclone.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
185 184 mercurial/subrepo.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
186 185 mercurial/templatefilters.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
187 186 mercurial/templatekw.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
188 187 mercurial/templater.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
189 188 mercurial/ui.py: error importing: <ImportError> No module named 'cPickle' (error at formatter.py:*) (glob)
190 189 mercurial/unionrepo.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
191 190 mercurial/url.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
192 191 mercurial/verify.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
193 192 mercurial/win*.py: error importing module: <ImportError> No module named 'msvcrt' (line *) (glob)
194 193 mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line *) (glob)
195 194 mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
196 195 tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
197 196 tests/test-demandimport.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
198 197 tests/test-lrucachedict.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
199 198 tests/test-trusted.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
200 199
201 200 #endif
@@ -1,354 +1,360 b''
1 1 # Copyright (C) 2004, 2005 Canonical Ltd
2 2 #
3 3 # This program is free software; you can redistribute it and/or modify
4 4 # it under the terms of the GNU General Public License as published by
5 5 # the Free Software Foundation; either version 2 of the License, or
6 6 # (at your option) any later version.
7 7 #
8 8 # This program is distributed in the hope that it will be useful,
9 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 11 # GNU General Public License for more details.
12 12 #
13 13 # You should have received a copy of the GNU General Public License
14 14 # along with this program; if not, see <http://www.gnu.org/licenses/>.
15 15
16 from __future__ import absolute_import
17
16 18 import unittest
17 from unittest import TestCase
18 from mercurial import util, simplemerge, error
19 from mercurial import (
20 error,
21 simplemerge,
22 util,
23 )
19 24
25 TestCase = unittest.TestCase
20 26 # bzr compatible interface, for the tests
21 27 class Merge3(simplemerge.Merge3Text):
22 28 """3-way merge of texts.
23 29
24 30 Given BASE, OTHER, THIS, tries to produce a combined text
25 31 incorporating the changes from both BASE->OTHER and BASE->THIS.
26 32 All three will typically be sequences of lines."""
27 33 def __init__(self, base, a, b):
28 34 basetext = '\n'.join([i.strip('\n') for i in base] + [''])
29 35 atext = '\n'.join([i.strip('\n') for i in a] + [''])
30 36 btext = '\n'.join([i.strip('\n') for i in b] + [''])
31 37 if util.binary(basetext) or util.binary(atext) or util.binary(btext):
32 38 raise error.Abort("don't know how to merge binary files")
33 39 simplemerge.Merge3Text.__init__(self, basetext, atext, btext,
34 40 base, a, b)
35 41
36 42 CantReprocessAndShowBase = simplemerge.CantReprocessAndShowBase
37 43
38 44 def split_lines(t):
39 45 return util.stringio(t).readlines()
40 46
41 47 ############################################################
42 48 # test case data from the gnu diffutils manual
43 49 # common base
44 50 TZU = split_lines(""" The Nameless is the origin of Heaven and Earth;
45 51 The named is the mother of all things.
46 52
47 53 Therefore let there always be non-being,
48 54 so we may see their subtlety,
49 55 And let there always be being,
50 56 so we may see their outcome.
51 57 The two are the same,
52 58 But after they are produced,
53 59 they have different names.
54 60 They both may be called deep and profound.
55 61 Deeper and more profound,
56 62 The door of all subtleties!
57 63 """)
58 64
59 65 LAO = split_lines(""" The Way that can be told of is not the eternal Way;
60 66 The name that can be named is not the eternal name.
61 67 The Nameless is the origin of Heaven and Earth;
62 68 The Named is the mother of all things.
63 69 Therefore let there always be non-being,
64 70 so we may see their subtlety,
65 71 And let there always be being,
66 72 so we may see their outcome.
67 73 The two are the same,
68 74 But after they are produced,
69 75 they have different names.
70 76 """)
71 77
72 78
73 79 TAO = split_lines(""" The Way that can be told of is not the eternal Way;
74 80 The name that can be named is not the eternal name.
75 81 The Nameless is the origin of Heaven and Earth;
76 82 The named is the mother of all things.
77 83
78 84 Therefore let there always be non-being,
79 85 so we may see their subtlety,
80 86 And let there always be being,
81 87 so we may see their result.
82 88 The two are the same,
83 89 But after they are produced,
84 90 they have different names.
85 91
86 92 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
87 93
88 94 """)
89 95
90 96 MERGED_RESULT = split_lines("""\
91 97 The Way that can be told of is not the eternal Way;
92 98 The name that can be named is not the eternal name.
93 99 The Nameless is the origin of Heaven and Earth;
94 100 The Named is the mother of all things.
95 101 Therefore let there always be non-being,
96 102 so we may see their subtlety,
97 103 And let there always be being,
98 104 so we may see their result.
99 105 The two are the same,
100 106 But after they are produced,
101 107 they have different names.
102 108 <<<<<<< LAO
103 109 =======
104 110
105 111 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
106 112
107 113 >>>>>>> TAO
108 114 """)
109 115
110 116 class TestMerge3(TestCase):
111 117 def log(self, msg):
112 118 pass
113 119
114 120 def test_no_changes(self):
115 121 """No conflicts because nothing changed"""
116 122 m3 = Merge3(['aaa', 'bbb'],
117 123 ['aaa', 'bbb'],
118 124 ['aaa', 'bbb'])
119 125
120 126 self.assertEquals(m3.find_unconflicted(),
121 127 [(0, 2)])
122 128
123 129 self.assertEquals(list(m3.find_sync_regions()),
124 130 [(0, 2,
125 131 0, 2,
126 132 0, 2),
127 133 (2, 2, 2, 2, 2, 2)])
128 134
129 135 self.assertEquals(list(m3.merge_regions()),
130 136 [('unchanged', 0, 2)])
131 137
132 138 self.assertEquals(list(m3.merge_groups()),
133 139 [('unchanged', ['aaa', 'bbb'])])
134 140
135 141 def test_front_insert(self):
136 142 m3 = Merge3(['zz'],
137 143 ['aaa', 'bbb', 'zz'],
138 144 ['zz'])
139 145
140 146 # todo: should use a sentinel at end as from get_matching_blocks
141 147 # to match without zz
142 148 self.assertEquals(list(m3.find_sync_regions()),
143 149 [(0, 1, 2, 3, 0, 1),
144 150 (1, 1, 3, 3, 1, 1)])
145 151
146 152 self.assertEquals(list(m3.merge_regions()),
147 153 [('a', 0, 2),
148 154 ('unchanged', 0, 1)])
149 155
150 156 self.assertEquals(list(m3.merge_groups()),
151 157 [('a', ['aaa', 'bbb']),
152 158 ('unchanged', ['zz'])])
153 159
154 160 def test_null_insert(self):
155 161 m3 = Merge3([],
156 162 ['aaa', 'bbb'],
157 163 [])
158 164 # todo: should use a sentinel at end as from get_matching_blocks
159 165 # to match without zz
160 166 self.assertEquals(list(m3.find_sync_regions()),
161 167 [(0, 0, 2, 2, 0, 0)])
162 168
163 169 self.assertEquals(list(m3.merge_regions()),
164 170 [('a', 0, 2)])
165 171
166 172 self.assertEquals(list(m3.merge_lines()),
167 173 ['aaa', 'bbb'])
168 174
169 175 def test_no_conflicts(self):
170 176 """No conflicts because only one side changed"""
171 177 m3 = Merge3(['aaa', 'bbb'],
172 178 ['aaa', '111', 'bbb'],
173 179 ['aaa', 'bbb'])
174 180
175 181 self.assertEquals(m3.find_unconflicted(),
176 182 [(0, 1), (1, 2)])
177 183
178 184 self.assertEquals(list(m3.find_sync_regions()),
179 185 [(0, 1, 0, 1, 0, 1),
180 186 (1, 2, 2, 3, 1, 2),
181 187 (2, 2, 3, 3, 2, 2)])
182 188
183 189 self.assertEquals(list(m3.merge_regions()),
184 190 [('unchanged', 0, 1),
185 191 ('a', 1, 2),
186 192 ('unchanged', 1, 2)])
187 193
188 194 def test_append_a(self):
189 195 m3 = Merge3(['aaa\n', 'bbb\n'],
190 196 ['aaa\n', 'bbb\n', '222\n'],
191 197 ['aaa\n', 'bbb\n'])
192 198
193 199 self.assertEquals(''.join(m3.merge_lines()),
194 200 'aaa\nbbb\n222\n')
195 201
196 202 def test_append_b(self):
197 203 m3 = Merge3(['aaa\n', 'bbb\n'],
198 204 ['aaa\n', 'bbb\n'],
199 205 ['aaa\n', 'bbb\n', '222\n'])
200 206
201 207 self.assertEquals(''.join(m3.merge_lines()),
202 208 'aaa\nbbb\n222\n')
203 209
204 210 def test_append_agreement(self):
205 211 m3 = Merge3(['aaa\n', 'bbb\n'],
206 212 ['aaa\n', 'bbb\n', '222\n'],
207 213 ['aaa\n', 'bbb\n', '222\n'])
208 214
209 215 self.assertEquals(''.join(m3.merge_lines()),
210 216 'aaa\nbbb\n222\n')
211 217
212 218 def test_append_clash(self):
213 219 m3 = Merge3(['aaa\n', 'bbb\n'],
214 220 ['aaa\n', 'bbb\n', '222\n'],
215 221 ['aaa\n', 'bbb\n', '333\n'])
216 222
217 223 ml = m3.merge_lines(name_a='a',
218 224 name_b='b',
219 225 start_marker='<<',
220 226 mid_marker='--',
221 227 end_marker='>>')
222 228 self.assertEquals(''.join(ml),
223 229 'aaa\n'
224 230 'bbb\n'
225 231 '<< a\n'
226 232 '222\n'
227 233 '--\n'
228 234 '333\n'
229 235 '>> b\n'
230 236 )
231 237
232 238 def test_insert_agreement(self):
233 239 m3 = Merge3(['aaa\n', 'bbb\n'],
234 240 ['aaa\n', '222\n', 'bbb\n'],
235 241 ['aaa\n', '222\n', 'bbb\n'])
236 242
237 243 ml = m3.merge_lines(name_a='a',
238 244 name_b='b',
239 245 start_marker='<<',
240 246 mid_marker='--',
241 247 end_marker='>>')
242 248 self.assertEquals(''.join(ml), 'aaa\n222\nbbb\n')
243 249
244 250
245 251 def test_insert_clash(self):
246 252 """Both try to insert lines in the same place."""
247 253 m3 = Merge3(['aaa\n', 'bbb\n'],
248 254 ['aaa\n', '111\n', 'bbb\n'],
249 255 ['aaa\n', '222\n', 'bbb\n'])
250 256
251 257 self.assertEquals(m3.find_unconflicted(),
252 258 [(0, 1), (1, 2)])
253 259
254 260 self.assertEquals(list(m3.find_sync_regions()),
255 261 [(0, 1, 0, 1, 0, 1),
256 262 (1, 2, 2, 3, 2, 3),
257 263 (2, 2, 3, 3, 3, 3)])
258 264
259 265 self.assertEquals(list(m3.merge_regions()),
260 266 [('unchanged', 0, 1),
261 267 ('conflict', 1, 1, 1, 2, 1, 2),
262 268 ('unchanged', 1, 2)])
263 269
264 270 self.assertEquals(list(m3.merge_groups()),
265 271 [('unchanged', ['aaa\n']),
266 272 ('conflict', [], ['111\n'], ['222\n']),
267 273 ('unchanged', ['bbb\n']),
268 274 ])
269 275
270 276 ml = m3.merge_lines(name_a='a',
271 277 name_b='b',
272 278 start_marker='<<',
273 279 mid_marker='--',
274 280 end_marker='>>')
275 281 self.assertEquals(''.join(ml),
276 282 '''aaa
277 283 << a
278 284 111
279 285 --
280 286 222
281 287 >> b
282 288 bbb
283 289 ''')
284 290
285 291 def test_replace_clash(self):
286 292 """Both try to insert lines in the same place."""
287 293 m3 = Merge3(['aaa', '000', 'bbb'],
288 294 ['aaa', '111', 'bbb'],
289 295 ['aaa', '222', 'bbb'])
290 296
291 297 self.assertEquals(m3.find_unconflicted(),
292 298 [(0, 1), (2, 3)])
293 299
294 300 self.assertEquals(list(m3.find_sync_regions()),
295 301 [(0, 1, 0, 1, 0, 1),
296 302 (2, 3, 2, 3, 2, 3),
297 303 (3, 3, 3, 3, 3, 3)])
298 304
299 305 def test_replace_multi(self):
300 306 """Replacement with regions of different size."""
301 307 m3 = Merge3(['aaa', '000', '000', 'bbb'],
302 308 ['aaa', '111', '111', '111', 'bbb'],
303 309 ['aaa', '222', '222', '222', '222', 'bbb'])
304 310
305 311 self.assertEquals(m3.find_unconflicted(),
306 312 [(0, 1), (3, 4)])
307 313
308 314
309 315 self.assertEquals(list(m3.find_sync_regions()),
310 316 [(0, 1, 0, 1, 0, 1),
311 317 (3, 4, 4, 5, 5, 6),
312 318 (4, 4, 5, 5, 6, 6)])
313 319
314 320 def test_merge_poem(self):
315 321 """Test case from diff3 manual"""
316 322 m3 = Merge3(TZU, LAO, TAO)
317 323 ml = list(m3.merge_lines('LAO', 'TAO'))
318 324 self.log('merge result:')
319 325 self.log(''.join(ml))
320 326 self.assertEquals(ml, MERGED_RESULT)
321 327
322 328 def test_binary(self):
323 329 self.assertRaises(error.Abort, Merge3, ['\x00'], ['a'], ['b'])
324 330
325 331 def test_dos_text(self):
326 332 base_text = 'a\r\n'
327 333 this_text = 'b\r\n'
328 334 other_text = 'c\r\n'
329 335 m3 = Merge3(base_text.splitlines(True), other_text.splitlines(True),
330 336 this_text.splitlines(True))
331 337 m_lines = m3.merge_lines('OTHER', 'THIS')
332 338 self.assertEqual('<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n'
333 339 '>>>>>>> THIS\r\n'.splitlines(True), list(m_lines))
334 340
335 341 def test_mac_text(self):
336 342 base_text = 'a\r'
337 343 this_text = 'b\r'
338 344 other_text = 'c\r'
339 345 m3 = Merge3(base_text.splitlines(True), other_text.splitlines(True),
340 346 this_text.splitlines(True))
341 347 m_lines = m3.merge_lines('OTHER', 'THIS')
342 348 self.assertEqual('<<<<<<< OTHER\rc\r=======\rb\r'
343 349 '>>>>>>> THIS\r'.splitlines(True), list(m_lines))
344 350
345 351 if __name__ == '__main__':
346 352 # hide the timer
347 353 import time
348 354 orig = time.time
349 355 try:
350 356 time.time = lambda: 0
351 357 unittest.main()
352 358 finally:
353 359 time.time = orig
354 360
General Comments 0
You need to be logged in to leave comments. Login now