Show More
@@ -36,10 +36,15 b" def printb(data, end=b'\\n'):" | |||
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | for f in sys.argv[1:]: |
|
39 | localf = encoding.strtolocal(f) | |
|
40 | if not localf.endswith(b'.i'): | |
|
41 | print("file:", f, file=sys.stderr) | |
|
42 | print(" invalida filename", file=sys.stderr) | |
|
43 | ||
|
39 | 44 | r = revlog.revlog( |
|
40 | 45 | binopen, |
|
41 | 46 | target=(revlog_constants.KIND_OTHER, b'dump-revlog'), |
|
42 | indexfile=encoding.strtolocal(f), | |
|
47 | radix=localf[:-2], | |
|
43 | 48 | ) |
|
44 | 49 | print("file:", f) |
|
45 | 50 | for i in r: |
@@ -1826,6 +1826,9 b' def perfnodelookup(ui, repo, rev, **opts' | |||
|
1826 | 1826 | mercurial.revlog._prereadsize = 2 ** 24 # disable lazy parser in old hg |
|
1827 | 1827 | n = scmutil.revsingle(repo, rev).node() |
|
1828 | 1828 | |
|
1829 | try: | |
|
1830 | cl = revlog(getsvfs(repo), radix=b"00changelog") | |
|
1831 | except TypeError: | |
|
1829 | 1832 | cl = revlog(getsvfs(repo), indexfile=b"00changelog.i") |
|
1830 | 1833 | |
|
1831 | 1834 | def d(): |
@@ -2610,6 +2613,7 b' def perfrevlogindex(ui, repo, file_=None' | |||
|
2610 | 2613 | |
|
2611 | 2614 | opener = getattr(rl, 'opener') # trick linter |
|
2612 | 2615 | # compat with hg <= 5.8 |
|
2616 | radix = getattr(rl, 'radix', None) | |
|
2613 | 2617 | indexfile = getattr(rl, '_indexfile', None) |
|
2614 | 2618 | if indexfile is None: |
|
2615 | 2619 | # compatibility with <= hg-5.8 |
@@ -2641,6 +2645,10 b' def perfrevlogindex(ui, repo, file_=None' | |||
|
2641 | 2645 | allnodesrev = list(reversed(allnodes)) |
|
2642 | 2646 | |
|
2643 | 2647 | def constructor(): |
|
2648 | if radix is not None: | |
|
2649 | revlog(opener, radix=radix) | |
|
2650 | else: | |
|
2651 | # hg <= 5.8 | |
|
2644 | 2652 | revlog(opener, indexfile=indexfile) |
|
2645 | 2653 | |
|
2646 | 2654 | def read(): |
@@ -3043,8 +3051,9 b' def _temprevlog(ui, orig, truncaterev):' | |||
|
3043 | 3051 | |
|
3044 | 3052 | datafile = getattr(orig, '_datafile', getattr(orig, 'datafile')) |
|
3045 | 3053 | origdatapath = orig.opener.join(datafile) |
|
3046 |
|
|
|
3047 |
|
|
|
3054 | radix = b'revlog' | |
|
3055 | indexname = b'revlog.i' | |
|
3056 | dataname = b'revlog.d' | |
|
3048 | 3057 | |
|
3049 | 3058 | tmpdir = tempfile.mkdtemp(prefix='tmp-hgperf-') |
|
3050 | 3059 | try: |
@@ -3069,6 +3078,9 b' def _temprevlog(ui, orig, truncaterev):' | |||
|
3069 | 3078 | vfs = vfsmod.vfs(tmpdir) |
|
3070 | 3079 | vfs.options = getattr(orig.opener, 'options', None) |
|
3071 | 3080 | |
|
3081 | try: | |
|
3082 | dest = revlog(vfs, radix=radix, **revlogkwargs) | |
|
3083 | except TypeError: | |
|
3072 | 3084 | dest = revlog( |
|
3073 | 3085 | vfs, indexfile=indexname, datafile=dataname, **revlogkwargs |
|
3074 | 3086 | ) |
@@ -32,10 +32,11 b' while True:' | |||
|
32 | 32 | break |
|
33 | 33 | if l.startswith("file:"): |
|
34 | 34 | f = encoding.strtolocal(l[6:-1]) |
|
35 | assert f.endswith(b'.i') | |
|
35 | 36 | r = revlog.revlog( |
|
36 | 37 | opener, |
|
37 | 38 | target=(revlog_constants.KIND_OTHER, b'undump-revlog'), |
|
38 |
|
|
|
39 | radix=f[:-2], | |
|
39 | 40 | ) |
|
40 | 41 | procutil.stdout.write(b'%s\n' % f) |
|
41 | 42 | elif l.startswith("node:"): |
@@ -281,7 +281,7 b' class manifestrevlogstore(object):' | |||
|
281 | 281 | self._store = repo.store |
|
282 | 282 | self._svfs = repo.svfs |
|
283 | 283 | self._revlogs = dict() |
|
284 |
self._cl = revlog.revlog(self._svfs, |
|
|
284 | self._cl = revlog.revlog(self._svfs, radix=b'00changelog.i') | |
|
285 | 285 | self._repackstartlinkrev = 0 |
|
286 | 286 | |
|
287 | 287 | def get(self, name, node): |
@@ -341,10 +341,10 b' class manifestrevlogstore(object):' | |||
|
341 | 341 | def _revlog(self, name): |
|
342 | 342 | rl = self._revlogs.get(name) |
|
343 | 343 | if rl is None: |
|
344 |
revlogname = b'00manifesttree |
|
|
344 | revlogname = b'00manifesttree' | |
|
345 | 345 | if name != b'': |
|
346 |
revlogname = b'meta/%s/00manifest |
|
|
347 |
rl = revlog.revlog(self._svfs, |
|
|
346 | revlogname = b'meta/%s/00manifest' % name | |
|
347 | rl = revlog.revlog(self._svfs, radix=revlogname) | |
|
348 | 348 | self._revlogs[name] = rl |
|
349 | 349 | return rl |
|
350 | 350 | |
@@ -365,7 +365,7 b' class manifestrevlogstore(object):' | |||
|
365 | 365 | if options and options.get(constants.OPTION_PACKSONLY): |
|
366 | 366 | return |
|
367 | 367 | treename = b'' |
|
368 |
rl = revlog.revlog(self._svfs, |
|
|
368 | rl = revlog.revlog(self._svfs, radix=b'00manifesttree') | |
|
369 | 369 | startlinkrev = self._repackstartlinkrev |
|
370 | 370 | endlinkrev = self._repackendlinkrev |
|
371 | 371 | for rev in pycompat.xrange(len(rl) - 1, -1, -1): |
@@ -382,9 +382,9 b' class manifestrevlogstore(object):' | |||
|
382 | 382 | if path[:5] != b'meta/' or path[-2:] != b'.i': |
|
383 | 383 | continue |
|
384 | 384 | |
|
385 |
treename = path[5 : -len(b'/00manifest |
|
|
385 | treename = path[5 : -len(b'/00manifest')] | |
|
386 | 386 | |
|
387 | rl = revlog.revlog(self._svfs, indexfile=path) | |
|
387 | rl = revlog.revlog(self._svfs, indexfile=path[:-2]) | |
|
388 | 388 | for rev in pycompat.xrange(len(rl) - 1, -1, -1): |
|
389 | 389 | linkrev = rl.linkrev(rev) |
|
390 | 390 | if linkrev < startlinkrev: |
@@ -52,7 +52,7 b' from .revlogutils import (' | |||
|
52 | 52 | |
|
53 | 53 | |
|
54 | 54 | class bundlerevlog(revlog.revlog): |
|
55 |
def __init__(self, opener, target, |
|
|
55 | def __init__(self, opener, target, radix, cgunpacker, linkmapper): | |
|
56 | 56 | # How it works: |
|
57 | 57 | # To retrieve a revision, we need to know the offset of the revision in |
|
58 | 58 | # the bundle (an unbundle object). We store this offset in the index |
@@ -61,7 +61,7 b' class bundlerevlog(revlog.revlog):' | |||
|
61 | 61 | # To differentiate a rev in the bundle from a rev in the revlog, we |
|
62 | 62 | # check revision against repotiprev. |
|
63 | 63 | opener = vfsmod.readonlyvfs(opener) |
|
64 |
revlog.revlog.__init__(self, opener, target=target, |
|
|
64 | revlog.revlog.__init__(self, opener, target=target, radix=radix) | |
|
65 | 65 | self.bundle = cgunpacker |
|
66 | 66 | n = len(self) |
|
67 | 67 | self.repotiprev = n - 1 |
@@ -180,7 +180,7 b' class bundlechangelog(bundlerevlog, chan' | |||
|
180 | 180 | self, |
|
181 | 181 | opener, |
|
182 | 182 | (revlog_constants.KIND_CHANGELOG, None), |
|
183 |
self. |
|
|
183 | self.radix, | |
|
184 | 184 | cgunpacker, |
|
185 | 185 | linkmapper, |
|
186 | 186 | ) |
@@ -201,7 +201,7 b' class bundlemanifest(bundlerevlog, manif' | |||
|
201 | 201 | self, |
|
202 | 202 | opener, |
|
203 | 203 | (revlog_constants.KIND_MANIFESTLOG, dir), |
|
204 |
self._revlog. |
|
|
204 | self._revlog.radix, | |
|
205 | 205 | cgunpacker, |
|
206 | 206 | linkmapper, |
|
207 | 207 | ) |
@@ -233,7 +233,7 b' class bundlefilelog(filelog.filelog):' | |||
|
233 | 233 | opener, |
|
234 | 234 | # XXX should use the unencoded path |
|
235 | 235 | target=(revlog_constants.KIND_FILELOG, path), |
|
236 |
|
|
|
236 | radix=self._revlog.radix, | |
|
237 | 237 | cgunpacker=cgunpacker, |
|
238 | 238 | linkmapper=linkmapper, |
|
239 | 239 | ) |
@@ -396,20 +396,17 b' class changelog(revlog.revlog):' | |||
|
396 | 396 | the documentation there. |
|
397 | 397 | """ |
|
398 | 398 | |
|
399 | indexfile = b'00changelog.i' | |
|
400 | 399 | if trypending and opener.exists(b'00changelog.i.a'): |
|
401 | 400 | postfix = b'a' |
|
402 | 401 | else: |
|
403 | 402 | postfix = None |
|
404 | 403 | |
|
405 | datafile = b'00changelog.d' | |
|
406 | 404 | revlog.revlog.__init__( |
|
407 | 405 | self, |
|
408 | 406 | opener, |
|
409 | 407 | target=(revlog_constants.KIND_CHANGELOG, None), |
|
408 | radix=b'00changelog', | |
|
410 | 409 | postfix=postfix, |
|
411 | indexfile=indexfile, | |
|
412 | datafile=datafile, | |
|
413 | 410 | checkambig=True, |
|
414 | 411 | mmaplargeindex=True, |
|
415 | 412 | persistentnodemap=opener.options.get(b'persistent-nodemap', False), |
@@ -1437,7 +1437,7 b' def openstorage(repo, cmd, file_, opts, ' | |||
|
1437 | 1437 | r = revlog.revlog( |
|
1438 | 1438 | vfsmod.vfs(encoding.getcwd(), audit=False), |
|
1439 | 1439 | target=target, |
|
1440 |
|
|
|
1440 | radix=file_[:-2], | |
|
1441 | 1441 | ) |
|
1442 | 1442 | return r |
|
1443 | 1443 |
@@ -30,7 +30,7 b' class filelog(object):' | |||
|
30 | 30 | opener, |
|
31 | 31 | # XXX should use the unencoded path |
|
32 | 32 | target=(revlog_constants.KIND_FILELOG, path), |
|
33 |
|
|
|
33 | radix=b'/'.join((b'data', path)), | |
|
34 | 34 | censorable=True, |
|
35 | 35 | ) |
|
36 | 36 | # Full name of the user visible file, relative to the repository root. |
@@ -1567,7 +1567,6 b' class manifestrevlog(object):' | |||
|
1567 | 1567 | opener, |
|
1568 | 1568 | tree=b'', |
|
1569 | 1569 | dirlogcache=None, |
|
1570 | indexfile=None, | |
|
1571 | 1570 | treemanifest=False, |
|
1572 | 1571 | ): |
|
1573 | 1572 | """Constructs a new manifest revlog |
@@ -1598,10 +1597,9 b' class manifestrevlog(object):' | |||
|
1598 | 1597 | if tree: |
|
1599 | 1598 | assert self._treeondisk, b'opts is %r' % opts |
|
1600 | 1599 | |
|
1601 | if indexfile is None: | |
|
1602 | indexfile = b'00manifest.i' | |
|
1600 | radix = b'00manifest' | |
|
1603 | 1601 |
|
|
1604 |
|
|
|
1602 | radix = b"meta/" + tree + radix | |
|
1605 | 1603 | |
|
1606 | 1604 | self.tree = tree |
|
1607 | 1605 | |
@@ -1614,7 +1612,7 b' class manifestrevlog(object):' | |||
|
1614 | 1612 | self._revlog = revlog.revlog( |
|
1615 | 1613 | opener, |
|
1616 | 1614 | target=(revlog_constants.KIND_MANIFESTLOG, self.tree), |
|
1617 | indexfile=indexfile, | |
|
1615 | radix=radix, | |
|
1618 | 1616 | # only root indexfile is cached |
|
1619 | 1617 | checkambig=not bool(tree), |
|
1620 | 1618 | mmaplargeindex=True, |
@@ -289,9 +289,8 b' class revlog(object):' | |||
|
289 | 289 | self, |
|
290 | 290 | opener, |
|
291 | 291 | target, |
|
292 | radix, | |
|
292 | 293 | postfix=None, |
|
293 | indexfile=None, | |
|
294 | datafile=None, | |
|
295 | 294 | checkambig=False, |
|
296 | 295 | mmaplargeindex=False, |
|
297 | 296 | censorable=False, |
@@ -313,16 +312,19 b' class revlog(object):' | |||
|
313 | 312 | accurate value. |
|
314 | 313 | """ |
|
315 | 314 | self.upperboundcomp = upperboundcomp |
|
316 | if not indexfile.endswith(b'.i'): | |
|
317 | raise error.ProgrammingError( | |
|
318 | b"revlog's indexfile should end with `.i`" | |
|
319 | ) | |
|
320 | if datafile is None: | |
|
321 | datafile = indexfile[:-2] + b".d" | |
|
322 |
|
|
|
323 |
|
|
|
324 | if postfix is not None: | |
|
325 | indexfile = b'%s.%s' % (indexfile, postfix) | |
|
315 | ||
|
316 | self.radix = radix | |
|
317 | ||
|
318 | if postfix is None: | |
|
319 | indexfile = b'%s.i' % self.radix | |
|
320 | datafile = b'%s.d' % self.radix | |
|
321 | elif postfix == b'a': | |
|
322 | indexfile = b'%s.i.a' % self.radix | |
|
323 | datafile = b'%s.d' % self.radix | |
|
324 | else: | |
|
325 | indexfile = b'%s.i.%s' % (self.radix, postfix) | |
|
326 | datafile = b'%s.d.%s' % (self.radix, postfix) | |
|
327 | ||
|
326 | 328 | self._indexfile = indexfile |
|
327 | 329 | self._datafile = datafile |
|
328 | 330 | self.nodemap_file = None |
@@ -2900,8 +2902,8 b' class revlog(object):' | |||
|
2900 | 2902 | newrl = revlog( |
|
2901 | 2903 | self.opener, |
|
2902 | 2904 | target=self.target, |
|
2905 | radix=self.radix, | |
|
2903 | 2906 | postfix=b'tmpcensored', |
|
2904 | indexfile=self._indexfile, | |
|
2905 | 2907 | censorable=True, |
|
2906 | 2908 | ) |
|
2907 | 2909 | newrl._format_version = self._format_version |
@@ -33,7 +33,7 b' from . import (' | |||
|
33 | 33 | |
|
34 | 34 | |
|
35 | 35 | class unionrevlog(revlog.revlog): |
|
36 |
def __init__(self, opener, |
|
|
36 | def __init__(self, opener, radix, revlog2, linkmapper): | |
|
37 | 37 | # How it works: |
|
38 | 38 | # To retrieve a revision, we just need to know the node id so we can |
|
39 | 39 | # look it up in revlog2. |
@@ -45,7 +45,7 b' class unionrevlog(revlog.revlog):' | |||
|
45 | 45 | if target is None: |
|
46 | 46 | # a revlog wrapper, eg: the manifestlog that is not an actual revlog |
|
47 | 47 | target = revlog2._revlog.target |
|
48 |
revlog.revlog.__init__(self, opener, target=target, |
|
|
48 | revlog.revlog.__init__(self, opener, target=target, radix=radix) | |
|
49 | 49 | self.revlog2 = revlog2 |
|
50 | 50 | |
|
51 | 51 | n = len(self) |
@@ -164,9 +164,7 b' class unionchangelog(unionrevlog, change' | |||
|
164 | 164 | changelog.changelog.__init__(self, opener) |
|
165 | 165 | linkmapper = None |
|
166 | 166 | changelog2 = changelog.changelog(opener2) |
|
167 | unionrevlog.__init__( | |
|
168 | self, opener, self._indexfile, changelog2, linkmapper | |
|
169 | ) | |
|
167 | unionrevlog.__init__(self, opener, self.radix, changelog2, linkmapper) | |
|
170 | 168 | |
|
171 | 169 | |
|
172 | 170 | class unionmanifest(unionrevlog, manifest.manifestrevlog): |
@@ -174,7 +172,7 b' class unionmanifest(unionrevlog, manifes' | |||
|
174 | 172 | manifest.manifestrevlog.__init__(self, nodeconstants, opener) |
|
175 | 173 | manifest2 = manifest.manifestrevlog(nodeconstants, opener2) |
|
176 | 174 | unionrevlog.__init__( |
|
177 |
self, opener, self._revlog. |
|
|
175 | self, opener, self._revlog.radix, manifest2, linkmapper | |
|
178 | 176 | ) |
|
179 | 177 | |
|
180 | 178 | |
@@ -183,7 +181,7 b' class unionfilelog(filelog.filelog):' | |||
|
183 | 181 | filelog.filelog.__init__(self, opener, path) |
|
184 | 182 | filelog2 = filelog.filelog(opener2, path) |
|
185 | 183 | self._revlog = unionrevlog( |
|
186 |
opener, self._revlog. |
|
|
184 | opener, self._revlog.radix, filelog2._revlog, linkmapper | |
|
187 | 185 | ) |
|
188 | 186 | self._repo = repo |
|
189 | 187 | self.repotiprev = self._revlog.repotiprev |
@@ -79,12 +79,11 b' def newtransaction():' | |||
|
79 | 79 | return transaction.transaction(report, tvfs, {'plain': tvfs}, b'journal') |
|
80 | 80 | |
|
81 | 81 | |
|
82 |
def newrevlog(name=b'_testrevlog |
|
|
82 | def newrevlog(name=b'_testrevlog', recreate=False): | |
|
83 | 83 | if recreate: |
|
84 | tvfs.tryunlink(name) | |
|
85 | rlog = revlog.revlog( | |
|
86 | tvfs, target=(constants.KIND_OTHER, b'test'), indexfile=name | |
|
87 | ) | |
|
84 | tvfs.tryunlink(name + b'.i') | |
|
85 | target = (constants.KIND_OTHER, b'test') | |
|
86 | rlog = revlog.revlog(tvfs, target=target, radix=name) | |
|
88 | 87 | return rlog |
|
89 | 88 | |
|
90 | 89 | |
@@ -112,7 +111,7 b' def appendrev(rlog, text, tr, isext=Fals' | |||
|
112 | 111 | rlog._storedeltachains = True |
|
113 | 112 | |
|
114 | 113 | |
|
115 |
def addgroupcopy(rlog, tr, destname=b'_destrevlog |
|
|
114 | def addgroupcopy(rlog, tr, destname=b'_destrevlog', optimaldelta=True): | |
|
116 | 115 | """Copy revlog to destname using revlog.addgroup. Return the copied revlog. |
|
117 | 116 | |
|
118 | 117 | This emulates push or pull. They use changegroup. Changegroup requires |
@@ -177,7 +176,7 b" def addgroupcopy(rlog, tr, destname=b'_d" | |||
|
177 | 176 | return dlog |
|
178 | 177 | |
|
179 | 178 | |
|
180 |
def lowlevelcopy(rlog, tr, destname=b'_destrevlog |
|
|
179 | def lowlevelcopy(rlog, tr, destname=b'_destrevlog'): | |
|
181 | 180 | """Like addgroupcopy, but use the low level revlog._addrevision directly. |
|
182 | 181 | |
|
183 | 182 | It exercises some code paths that are hard to reach easily otherwise. |
@@ -427,7 +426,7 b' data = [' | |||
|
427 | 426 | |
|
428 | 427 | |
|
429 | 428 | def makesnapshot(tr): |
|
430 |
rl = newrevlog(name=b'_snaprevlog3 |
|
|
429 | rl = newrevlog(name=b'_snaprevlog3', recreate=True) | |
|
431 | 430 | for i in data: |
|
432 | 431 | appendrev(rl, i, tr) |
|
433 | 432 | return rl |
@@ -483,7 +482,7 b' def maintest():' | |||
|
483 | 482 | checkrevlog(rl2, expected) |
|
484 | 483 | print('addgroupcopy test passed') |
|
485 | 484 | # Copy via revlog.clone |
|
486 |
rl3 = newrevlog(name=b'_destrevlog3 |
|
|
485 | rl3 = newrevlog(name=b'_destrevlog3', recreate=True) | |
|
487 | 486 | rl.clone(tr, rl3) |
|
488 | 487 | checkrevlog(rl3, expected) |
|
489 | 488 | print('clone test passed') |
@@ -49,6 +49,6 b' Test for CVE-2016-3630' | |||
|
49 | 49 | >>> from mercurial import revlog, vfs |
|
50 | 50 | >>> tvfs = vfs.vfs(b'.') |
|
51 | 51 | >>> tvfs.options = {b'revlogv1': True} |
|
52 |
>>> rl = revlog.revlog(tvfs, target=(KIND_OTHER, b'test'), |
|
|
52 | >>> rl = revlog.revlog(tvfs, target=(KIND_OTHER, b'test'), radix=b'a') | |
|
53 | 53 | >>> rl.revision(1) |
|
54 | 54 | mpatchError(*'patch cannot be decoded'*) (glob) |
General Comments 0
You need to be logged in to leave comments.
Login now