Mercurial > public > mercurial-scm > hg
diff contrib/perf.py @ 47150:8d3c2f9d4af7
revlog: use a "radix" to address revlog
Instead of pointing to the index directly and to derive the other file from
that, we directly provide the radix and let the revlog determine the associated
file path internally. This is more robust and will give us more flexibility for
picking this file name in the future.
Differential Revision: https://phab.mercurial-scm.org/D10576
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 03 May 2021 12:22:36 +0200 |
parents | 396442cd7e6a |
children | eb416759af7e |
line wrap: on
line diff
--- a/contrib/perf.py Mon May 03 12:22:26 2021 +0200 +++ b/contrib/perf.py Mon May 03 12:22:36 2021 +0200 @@ -1826,7 +1826,10 @@ mercurial.revlog._prereadsize = 2 ** 24 # disable lazy parser in old hg n = scmutil.revsingle(repo, rev).node() - cl = revlog(getsvfs(repo), indexfile=b"00changelog.i") + try: + cl = revlog(getsvfs(repo), radix=b"00changelog") + except TypeError: + cl = revlog(getsvfs(repo), indexfile=b"00changelog.i") def d(): cl.rev(n) @@ -2610,6 +2613,7 @@ opener = getattr(rl, 'opener') # trick linter # compat with hg <= 5.8 + radix = getattr(rl, 'radix', None) indexfile = getattr(rl, '_indexfile', None) if indexfile is None: # compatibility with <= hg-5.8 @@ -2641,7 +2645,11 @@ allnodesrev = list(reversed(allnodes)) def constructor(): - revlog(opener, indexfile=indexfile) + if radix is not None: + revlog(opener, radix=radix) + else: + # hg <= 5.8 + revlog(opener, indexfile=indexfile) def read(): with opener(indexfile) as fh: @@ -3043,8 +3051,9 @@ datafile = getattr(orig, '_datafile', getattr(orig, 'datafile')) origdatapath = orig.opener.join(datafile) - indexname = 'revlog.i' - dataname = 'revlog.d' + radix = b'revlog' + indexname = b'revlog.i' + dataname = b'revlog.d' tmpdir = tempfile.mkdtemp(prefix='tmp-hgperf-') try: @@ -3069,9 +3078,12 @@ vfs = vfsmod.vfs(tmpdir) vfs.options = getattr(orig.opener, 'options', None) - dest = revlog( - vfs, indexfile=indexname, datafile=dataname, **revlogkwargs - ) + try: + dest = revlog(vfs, radix=radix, **revlogkwargs) + except TypeError: + dest = revlog( + vfs, indexfile=indexname, datafile=dataname, **revlogkwargs + ) if dest._inline: raise error.Abort('not supporting inline revlog (yet)') # make sure internals are initialized