Mercurial > hg
annotate tests/test-revlog-raw.py @ 34192:da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
uncommit extension in fb-hgext adds a uncommit command which by default
uncommits a changeset and move all the changes to the working directory. If
file names are passed, uncommit moves the changes from those files to the
working directory and left the changeset with remaining committed files.
The uncommit extension in fb-hgext does not creates an empty commit like the one
in evolve extension unless user has specified ui.alllowemptycommit to True.
The test file added is a combination of tests from test-uncommit.t,
test-uncommit-merge.t and test-uncommit-bookmark.t from fb-hgext.
.. feature::
A new uncommit extension which provides `hg uncommit` using which one can
uncommit part or all of the changeset. This command undoes the effect of a
local commit, returning the affected files to their uncommitted state.
Differential Revision: https://phab.mercurial-scm.org/D529
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Thu, 24 Aug 2017 22:55:56 +0530 |
parents | c8b6ed51386b |
children | 1db9abf407c5 |
rev | line source |
---|---|
31748
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
1 # test revlog interaction about raw data (flagprocessor) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
2 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
3 from __future__ import absolute_import, print_function |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
4 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
5 import sys |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
6 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
7 from mercurial import ( |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
8 encoding, |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
9 node, |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
10 revlog, |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
11 transaction, |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
12 vfs, |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
13 ) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
14 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
15 # TESTTMP is optional. This makes it convenient to run without run-tests.py |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
16 tvfs = vfs.vfs(encoding.environ.get('TESTTMP', b'/tmp')) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
17 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
18 # Enable generaldelta otherwise revlog won't use delta as expected by the test |
31764
15707e58fc3d
test-revlog-raw: remove duplicated option
Jun Wu <quark@fb.com>
parents:
31763
diff
changeset
|
19 tvfs.options = {'generaldelta': True, 'revlogv1': True} |
31748
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
20 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
21 # The test wants to control whether to use delta explicitly, based on |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
22 # "storedeltachains". |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
23 revlog.revlog._isgooddelta = lambda self, d, textlen: self.storedeltachains |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
24 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
25 def abort(msg): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
26 print('abort: %s' % msg) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
27 # Return 0 so run-tests.py could compare the output. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
28 sys.exit() |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
29 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
30 # Register a revlog processor for flag EXTSTORED. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
31 # |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
32 # It simply prepends a fixed header, and replaces '1' to 'i'. So it has |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
33 # insertion and replacement, and may be interesting to test revlog's line-based |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
34 # deltas. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
35 _extheader = b'E\n' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
36 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
37 def readprocessor(self, rawtext): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
38 # True: the returned text could be used to verify hash |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
39 text = rawtext[len(_extheader):].replace(b'i', b'1') |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
40 return text, True |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
41 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
42 def writeprocessor(self, text): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
43 # False: the returned rawtext shouldn't be used to verify hash |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
44 rawtext = _extheader + text.replace(b'1', b'i') |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
45 return rawtext, False |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
46 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
47 def rawprocessor(self, rawtext): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
48 # False: do not verify hash. Only the content returned by "readprocessor" |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
49 # can be used to verify hash. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
50 return False |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
51 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
52 revlog.addflagprocessor(revlog.REVIDX_EXTSTORED, |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
53 (readprocessor, writeprocessor, rawprocessor)) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
54 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
55 # Utilities about reading and appending revlog |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
56 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
57 def newtransaction(): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
58 # A transaction is required to write revlogs |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
59 report = lambda msg: None |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
60 return transaction.transaction(report, tvfs, {'plain': tvfs}, b'journal') |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
61 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
62 def newrevlog(name=b'_testrevlog.i', recreate=False): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
63 if recreate: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
64 tvfs.tryunlink(name) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
65 rlog = revlog.revlog(tvfs, name) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
66 return rlog |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
67 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
68 def appendrev(rlog, text, tr, isext=False, isdelta=True): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
69 '''Append a revision. If isext is True, set the EXTSTORED flag so flag |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
70 processor will be used (and rawtext is different from text). If isdelta is |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
71 True, force the revision to be a delta, otherwise it's full text. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
72 ''' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
73 nextrev = len(rlog) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
74 p1 = rlog.node(nextrev - 1) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
75 p2 = node.nullid |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
76 if isext: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
77 flags = revlog.REVIDX_EXTSTORED |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
78 else: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
79 flags = revlog.REVIDX_DEFAULT_FLAGS |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
80 # Change storedeltachains temporarily, to override revlog's delta decision |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
81 rlog.storedeltachains = isdelta |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
82 try: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
83 rlog.addrevision(text, tr, nextrev, p1, p2, flags=flags) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
84 return nextrev |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
85 except Exception as ex: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
86 abort('rev %d: failed to append: %s' % (nextrev, ex)) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
87 finally: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
88 # Restore storedeltachains. It is always True, see revlog.__init__ |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
89 rlog.storedeltachains = True |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
90 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
91 def addgroupcopy(rlog, tr, destname=b'_destrevlog.i', optimaldelta=True): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
92 '''Copy revlog to destname using revlog.addgroup. Return the copied revlog. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
93 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
94 This emulates push or pull. They use changegroup. Changegroup requires |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
95 repo to work. We don't have a repo, so a dummy changegroup is used. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
96 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
97 If optimaldelta is True, use optimized delta parent, so the destination |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
98 revlog could probably reuse it. Otherwise it builds sub-optimal delta, and |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
99 the destination revlog needs more work to use it. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
100 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
101 This exercises some revlog.addgroup (and revlog._addrevision(text=None)) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
102 code path, which is not covered by "appendrev" alone. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
103 ''' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
104 class dummychangegroup(object): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
105 @staticmethod |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
106 def deltachunk(pnode): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
107 pnode = pnode or node.nullid |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
108 parentrev = rlog.rev(pnode) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
109 r = parentrev + 1 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
110 if r >= len(rlog): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
111 return {} |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
112 if optimaldelta: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
113 deltaparent = parentrev |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
114 else: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
115 # suboptimal deltaparent |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
116 deltaparent = min(0, parentrev) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
117 return {'node': rlog.node(r), 'p1': pnode, 'p2': node.nullid, |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
118 'cs': rlog.node(rlog.linkrev(r)), 'flags': rlog.flags(r), |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
119 'deltabase': rlog.node(deltaparent), |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
120 'delta': rlog.revdiff(deltaparent, r)} |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
121 |
34148
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
122 def deltaiter(self, linkmapper): |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
123 chain = None |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
124 for chunkdata in iter(lambda: self.deltachunk(chain), {}): |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
125 node = chunkdata['node'] |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
126 p1 = chunkdata['p1'] |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
127 p2 = chunkdata['p2'] |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
128 cs = chunkdata['cs'] |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
129 deltabase = chunkdata['deltabase'] |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
130 delta = chunkdata['delta'] |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
131 flags = chunkdata['flags'] |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
132 |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
133 link = linkmapper(cs) |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
134 chain = node |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
135 |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
136 yield (node, p1, p2, link, deltabase, delta, flags) |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
137 |
31748
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
138 def linkmap(lnode): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
139 return rlog.rev(lnode) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
140 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
141 dlog = newrevlog(destname, recreate=True) |
34148
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
142 dummydeltas = dummychangegroup().deltaiter(linkmap) |
c8b6ed51386b
changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents:
33625
diff
changeset
|
143 dlog.addgroup(dummydeltas, tr) |
31748
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
144 return dlog |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
145 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
146 def lowlevelcopy(rlog, tr, destname=b'_destrevlog.i'): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
147 '''Like addgroupcopy, but use the low level revlog._addrevision directly. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
148 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
149 It exercises some code paths that are hard to reach easily otherwise. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
150 ''' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
151 dlog = newrevlog(destname, recreate=True) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
152 for r in rlog: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
153 p1 = rlog.node(r - 1) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
154 p2 = node.nullid |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
155 if r == 0: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
156 text = rlog.revision(r, raw=True) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
157 cachedelta = None |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
158 else: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
159 # deltaparent is more interesting if it has the EXTSTORED flag. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
160 deltaparent = max([0] + [p for p in range(r - 2) if rlog.flags(p)]) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
161 text = None |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
162 cachedelta = (deltaparent, rlog.revdiff(deltaparent, r)) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
163 flags = rlog.flags(r) |
33625
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
164 ifh = dfh = None |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
165 try: |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
166 ifh = dlog.opener(dlog.indexfile, 'a+') |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
167 if not dlog._inline: |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
168 dfh = dlog.opener(dlog.datafile, 'a+') |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
169 dlog._addrevision(rlog.node(r), text, tr, r, p1, p2, flags, |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
170 cachedelta, ifh, dfh) |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
171 finally: |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
172 if dfh is not None: |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
173 dfh.close() |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
174 if ifh is not None: |
6788e648efcf
test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents:
31764
diff
changeset
|
175 ifh.close() |
31748
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
176 return dlog |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
177 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
178 # Utilities to generate revisions for testing |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
179 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
180 def genbits(n): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
181 '''Given a number n, generate (2 ** (n * 2) + 1) numbers in range(2 ** n). |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
182 i.e. the generated numbers have a width of n bits. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
183 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
184 The combination of two adjacent numbers will cover all possible cases. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
185 That is to say, given any x, y where both x, and y are in range(2 ** n), |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
186 there is an x followed immediately by y in the generated sequence. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
187 ''' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
188 m = 2 ** n |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
189 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
190 # Gray Code. See https://en.wikipedia.org/wiki/Gray_code |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
191 gray = lambda x: x ^ (x >> 1) |
31763
8a0c47982ade
test-revlog-raw: fix "genbits" implementation
Jun Wu <quark@fb.com>
parents:
31748
diff
changeset
|
192 reversegray = dict((gray(i), i) for i in range(m)) |
31748
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
193 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
194 # Generate (n * 2) bit gray code, yield lower n bits as X, and look for |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
195 # the next unused gray code where higher n bits equal to X. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
196 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
197 # For gray codes whose higher bits are X, a[X] of them have been used. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
198 a = [0] * m |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
199 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
200 # Iterate from 0. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
201 x = 0 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
202 yield x |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
203 for i in range(m * m): |
31763
8a0c47982ade
test-revlog-raw: fix "genbits" implementation
Jun Wu <quark@fb.com>
parents:
31748
diff
changeset
|
204 x = reversegray[x] |
31748
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
205 y = gray(a[x] + x * m) & (m - 1) |
31763
8a0c47982ade
test-revlog-raw: fix "genbits" implementation
Jun Wu <quark@fb.com>
parents:
31748
diff
changeset
|
206 assert a[x] < m |
31748
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
207 a[x] += 1 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
208 x = y |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
209 yield x |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
210 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
211 def gentext(rev): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
212 '''Given a revision number, generate dummy text''' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
213 return b''.join(b'%d\n' % j for j in range(-1, rev % 5)) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
214 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
215 def writecases(rlog, tr): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
216 '''Write some revisions interested to the test. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
217 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
218 The test is interested in 3 properties of a revision: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
219 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
220 - Is it a delta or a full text? (isdelta) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
221 This is to catch some delta application issues. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
222 - Does it have a flag of EXTSTORED? (isext) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
223 This is to catch some flag processor issues. Especially when |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
224 interacted with revlog deltas. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
225 - Is its text empty? (isempty) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
226 This is less important. It is intended to try to catch some careless |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
227 checks like "if text" instead of "if text is None". Note: if flag |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
228 processor is involved, raw text may be not empty. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
229 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
230 Write 65 revisions. So that all combinations of the above flags for |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
231 adjacent revisions are covered. That is to say, |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
232 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
233 len(set( |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
234 (r.delta, r.ext, r.empty, (r+1).delta, (r+1).ext, (r+1).empty) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
235 for r in range(len(rlog) - 1) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
236 )) is 64. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
237 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
238 Where "r.delta", "r.ext", and "r.empty" are booleans matching properties |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
239 mentioned above. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
240 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
241 Return expected [(text, rawtext)]. |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
242 ''' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
243 result = [] |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
244 for i, x in enumerate(genbits(3)): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
245 isdelta, isext, isempty = bool(x & 1), bool(x & 2), bool(x & 4) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
246 if isempty: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
247 text = b'' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
248 else: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
249 text = gentext(i) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
250 rev = appendrev(rlog, text, tr, isext=isext, isdelta=isdelta) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
251 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
252 # Verify text, rawtext, and rawsize |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
253 if isext: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
254 rawtext = writeprocessor(None, text)[0] |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
255 else: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
256 rawtext = text |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
257 if rlog.rawsize(rev) != len(rawtext): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
258 abort('rev %d: wrong rawsize' % rev) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
259 if rlog.revision(rev, raw=False) != text: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
260 abort('rev %d: wrong text' % rev) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
261 if rlog.revision(rev, raw=True) != rawtext: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
262 abort('rev %d: wrong rawtext' % rev) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
263 result.append((text, rawtext)) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
264 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
265 # Verify flags like isdelta, isext work as expected |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
266 if bool(rlog.deltaparent(rev) > -1) != isdelta: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
267 abort('rev %d: isdelta is ineffective' % rev) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
268 if bool(rlog.flags(rev)) != isext: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
269 abort('rev %d: isext is ineffective' % rev) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
270 return result |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
271 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
272 # Main test and checking |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
273 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
274 def checkrevlog(rlog, expected): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
275 '''Check if revlog has expected contents. expected is [(text, rawtext)]''' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
276 # Test using different access orders. This could expose some issues |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
277 # depending on revlog caching (see revlog._cache). |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
278 for r0 in range(len(rlog) - 1): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
279 r1 = r0 + 1 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
280 for revorder in [[r0, r1], [r1, r0]]: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
281 for raworder in [[True], [False], [True, False], [False, True]]: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
282 nlog = newrevlog() |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
283 for rev in revorder: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
284 for raw in raworder: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
285 t = nlog.revision(rev, raw=raw) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
286 if t != expected[rev][int(raw)]: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
287 abort('rev %d: corrupted %stext' |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
288 % (rev, raw and 'raw' or '')) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
289 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
290 def maintest(): |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
291 expected = rl = None |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
292 with newtransaction() as tr: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
293 rl = newrevlog(recreate=True) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
294 expected = writecases(rl, tr) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
295 checkrevlog(rl, expected) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
296 print('local test passed') |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
297 # Copy via revlog.addgroup |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
298 rl1 = addgroupcopy(rl, tr) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
299 checkrevlog(rl1, expected) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
300 rl2 = addgroupcopy(rl, tr, optimaldelta=False) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
301 checkrevlog(rl2, expected) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
302 print('addgroupcopy test passed') |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
303 # Copy via revlog.clone |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
304 rl3 = newrevlog(name='_destrevlog3.i', recreate=True) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
305 rl.clone(tr, rl3) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
306 checkrevlog(rl3, expected) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
307 print('clone test passed') |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
308 # Copy via low-level revlog._addrevision |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
309 rl4 = lowlevelcopy(rl, tr) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
310 checkrevlog(rl4, expected) |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
311 print('lowlevelcopy test passed') |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
312 |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
313 try: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
314 maintest() |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
315 except Exception as ex: |
985de02b5b9d
revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
316 abort('crashed: %s' % ex) |