annotate tests/test-absorb-filefixupstate.py @ 42341:27d6956d386b

match: use '' instead of '.' for root directory (API) I think '' is generally a better value for the root directory than '.' is. For example, os.path.join('', 'foo') => 'foo', while os.path.join('.', 'foo') => './foo'. This patch mostly makes it so we use '' internally in match.py. However, it also affects the API in visitdir(), visitchildrenset() and files(). The two former now also accept '' as input. I've updated the callers of these methods. I've also added a deprecation warning for passing '.' (for external callers). The only caller I could find that was affected by files() returning '' instead of '.' was in dirstate.walk(). I've updated that. The next few patches show some workarounds we can remove by using '' instead of '.'. Differential Revision: https://phab.mercurial-scm.org/D6401
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 15 May 2017 00:12:19 -0700
parents dcda50856843
children 2372284d9457
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1 from __future__ import absolute_import, print_function
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
2
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
3 import itertools
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
4 from mercurial import pycompat
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
5 from hgext import absorb
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
6
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
7 class simplefctx(object):
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
8 def __init__(self, content):
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
9 self.content = content
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
10
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
11 def data(self):
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
12 return self.content
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
13
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
14 def insertreturns(x):
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
15 # insert "\n"s after each single char
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
16 if isinstance(x, bytes):
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
17 return b''.join(ch + b'\n' for ch in pycompat.bytestr(x))
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
18 else:
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
19 return pycompat.maplist(insertreturns, x)
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
20
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
21 def removereturns(x):
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
22 # the revert of "insertreturns"
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
23 if isinstance(x, bytes):
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
24 return x.replace(b'\n', b'')
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
25 else:
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
26 return pycompat.maplist(removereturns, x)
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
27
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
28 def assertlistequal(lhs, rhs, decorator=lambda x: x):
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
29 if lhs != rhs:
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
30 raise RuntimeError('mismatch:\n actual: %r\n expected: %r'
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
31 % tuple(map(decorator, [lhs, rhs])))
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
32
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
33 def testfilefixup(oldcontents, workingcopy, expectedcontents, fixups=None):
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
34 """([str], str, [str], [(rev, a1, a2, b1, b2)]?) -> None
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
35
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
36 workingcopy is a string, of which every character denotes a single line.
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
37
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
38 oldcontents, expectedcontents are lists of strings, every character of
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
39 every string denots a single line.
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
40
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
41 if fixups is not None, it's the expected fixups list and will be checked.
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
42 """
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
43 expectedcontents = insertreturns(expectedcontents)
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
44 oldcontents = insertreturns(oldcontents)
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
45 workingcopy = insertreturns(workingcopy)
40187
dcda50856843 absorb: use a formatter to generate output
Mark Thomas <mbthomas@fb.com>
parents: 38988
diff changeset
46 state = absorb.filefixupstate(pycompat.maplist(simplefctx, oldcontents),
dcda50856843 absorb: use a formatter to generate output
Mark Thomas <mbthomas@fb.com>
parents: 38988
diff changeset
47 'path')
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
48 state.diffwith(simplefctx(workingcopy))
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
49 if fixups is not None:
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
50 assertlistequal(state.fixups, fixups)
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
51 state.apply()
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
52 assertlistequal(state.finalcontents, expectedcontents, removereturns)
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
53
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
54 def buildcontents(linesrevs):
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
55 # linesrevs: [(linecontent : str, revs : [int])]
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
56 revs = set(itertools.chain(*[revs for line, revs in linesrevs]))
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
57 return [b''] + [
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
58 b''.join([l for l, rs in linesrevs if r in rs])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
59 for r in sorted(revs)
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
60 ]
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
61
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
62 # input case 0: one single commit
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
63 case0 = [b'', b'11']
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
64
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
65 # replace a single chunk
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
66 testfilefixup(case0, b'', [b'', b''])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
67 testfilefixup(case0, b'2', [b'', b'2'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
68 testfilefixup(case0, b'22', [b'', b'22'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
69 testfilefixup(case0, b'222', [b'', b'222'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
70
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
71 # input case 1: 3 lines, each commit adds one line
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
72 case1 = buildcontents([
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
73 (b'1', [1, 2, 3]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
74 (b'2', [ 2, 3]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
75 (b'3', [ 3]),
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
76 ])
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
77
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
78 # 1:1 line mapping
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
79 testfilefixup(case1, b'123', case1)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
80 testfilefixup(case1, b'12c', [b'', b'1', b'12', b'12c'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
81 testfilefixup(case1, b'1b3', [b'', b'1', b'1b', b'1b3'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
82 testfilefixup(case1, b'1bc', [b'', b'1', b'1b', b'1bc'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
83 testfilefixup(case1, b'a23', [b'', b'a', b'a2', b'a23'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
84 testfilefixup(case1, b'a2c', [b'', b'a', b'a2', b'a2c'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
85 testfilefixup(case1, b'ab3', [b'', b'a', b'ab', b'ab3'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
86 testfilefixup(case1, b'abc', [b'', b'a', b'ab', b'abc'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
87
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
88 # non 1:1 edits
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
89 testfilefixup(case1, b'abcd', case1)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
90 testfilefixup(case1, b'ab', case1)
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
91
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
92 # deletion
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
93 testfilefixup(case1, b'', [b'', b'', b'', b''])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
94 testfilefixup(case1, b'1', [b'', b'1', b'1', b'1'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
95 testfilefixup(case1, b'2', [b'', b'', b'2', b'2'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
96 testfilefixup(case1, b'3', [b'', b'', b'', b'3'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
97 testfilefixup(case1, b'13', [b'', b'1', b'1', b'13'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
98
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
99 # replaces
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
100 testfilefixup(case1, b'1bb3', [b'', b'1', b'1bb', b'1bb3'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
101
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
102 # (confusing) replaces
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
103 testfilefixup(case1, b'1bbb', case1)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
104 testfilefixup(case1, b'bbbb', case1)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
105 testfilefixup(case1, b'bbb3', case1)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
106 testfilefixup(case1, b'1b', case1)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
107 testfilefixup(case1, b'bb', case1)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
108 testfilefixup(case1, b'b3', case1)
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
109
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
110 # insertions at the beginning and the end
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
111 testfilefixup(case1, b'123c', [b'', b'1', b'12', b'123c'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
112 testfilefixup(case1, b'a123', [b'', b'a1', b'a12', b'a123'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
113
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
114 # (confusing) insertions
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
115 testfilefixup(case1, b'1a23', case1)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
116 testfilefixup(case1, b'12b3', case1)
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
117
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
118 # input case 2: delete in the middle
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
119 case2 = buildcontents([
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
120 (b'11', [1, 2]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
121 (b'22', [1 ]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
122 (b'33', [1, 2]),
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
123 ])
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
124
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
125 # deletion (optimize code should make it 2 chunks)
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
126 testfilefixup(case2, b'', [b'', b'22', b''],
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
127 fixups=[(4, 0, 2, 0, 0), (4, 2, 4, 0, 0)])
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
128
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
129 # 1:1 line mapping
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
130 testfilefixup(case2, b'aaaa', [b'', b'aa22aa', b'aaaa'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
131
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
132 # non 1:1 edits
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
133 # note: unlike case0, the chunk is not "continuous" and no edit allowed
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
134 testfilefixup(case2, b'aaa', case2)
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
135
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
136 # input case 3: rev 3 reverts rev 2
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
137 case3 = buildcontents([
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
138 (b'1', [1, 2, 3]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
139 (b'2', [ 2 ]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
140 (b'3', [1, 2, 3]),
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
141 ])
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
142
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
143 # 1:1 line mapping
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
144 testfilefixup(case3, b'13', case3)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
145 testfilefixup(case3, b'1b', [b'', b'1b', b'12b', b'1b'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
146 testfilefixup(case3, b'a3', [b'', b'a3', b'a23', b'a3'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
147 testfilefixup(case3, b'ab', [b'', b'ab', b'a2b', b'ab'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
148
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
149 # non 1:1 edits
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
150 testfilefixup(case3, b'a', case3)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
151 testfilefixup(case3, b'abc', case3)
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
152
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
153 # deletion
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
154 testfilefixup(case3, b'', [b'', b'', b'2', b''])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
155
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
156 # insertion
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
157 testfilefixup(case3, b'a13c', [b'', b'a13c', b'a123c', b'a13c'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
158
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
159 # input case 4: a slightly complex case
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
160 case4 = buildcontents([
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
161 (b'1', [1, 2, 3]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
162 (b'2', [ 2, 3]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
163 (b'3', [1, 2, ]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
164 (b'4', [1, 3]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
165 (b'5', [ 3]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
166 (b'6', [ 2, 3]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
167 (b'7', [ 2 ]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
168 (b'8', [ 2, 3]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
169 (b'9', [ 3]),
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
170 ])
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
171
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
172 testfilefixup(case4, b'1245689', case4)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
173 testfilefixup(case4, b'1a2456bbb', case4)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
174 testfilefixup(case4, b'1abc5689', case4)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
175 testfilefixup(case4, b'1ab5689', [b'', b'134', b'1a3678', b'1ab5689'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
176 testfilefixup(case4, b'aa2bcd8ee', [b'', b'aa34', b'aa23d78', b'aa2bcd8ee'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
177 testfilefixup(case4, b'aa2bcdd8ee',[b'', b'aa34', b'aa23678', b'aa24568ee'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
178 testfilefixup(case4, b'aaaaaa', case4)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
179 testfilefixup(case4, b'aa258b', [b'', b'aa34', b'aa2378', b'aa258b'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
180 testfilefixup(case4, b'25bb', [b'', b'34', b'23678', b'25689'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
181 testfilefixup(case4, b'27', [b'', b'34', b'23678', b'245689'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
182 testfilefixup(case4, b'28', [b'', b'34', b'2378', b'28'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
183 testfilefixup(case4, b'', [b'', b'34', b'37', b''])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
184
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
185 # input case 5: replace a small chunk which is near a deleted line
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
186 case5 = buildcontents([
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
187 (b'12', [1, 2]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
188 (b'3', [1]),
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
189 (b'4', [1, 2]),
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
190 ])
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
191
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
192 testfilefixup(case5, b'1cd4', [b'', b'1cd34', b'1cd4'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
193
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
194 # input case 6: base "changeset" is immutable
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
195 case6 = [b'1357', b'0125678']
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
196
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
197 testfilefixup(case6, b'0125678', case6)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
198 testfilefixup(case6, b'0a25678', case6)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
199 testfilefixup(case6, b'0a256b8', case6)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
200 testfilefixup(case6, b'abcdefg', [b'1357', b'a1c5e7g'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
201 testfilefixup(case6, b'abcdef', case6)
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
202 testfilefixup(case6, b'', [b'1357', b'157'])
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
203 testfilefixup(case6, b'0123456789', [b'1357', b'0123456789'])
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
204
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
205 # input case 7: change an empty file
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
206 case7 = [b'']
38917
5111d11b8719 absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
207
38988
1aab0007a7c0 tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents: 38917
diff changeset
208 testfilefixup(case7, b'1', case7)