debug-delta-chaing: add a parameter to select revision to look at
This allows for much faster runtime when we are interrested in some revisions only.
--- a/mercurial/debugcommands.py Mon Sep 18 23:37:06 2023 +0200
+++ b/mercurial/debugcommands.py Tue Sep 19 01:24:10 2023 +0200
@@ -746,7 +746,16 @@
@command(
b'debugdeltachain',
- cmdutil.debugrevlogopts + cmdutil.formatteropts,
+ [
+ (
+ b'r',
+ b'rev',
+ [],
+ _('restrict processing to these revlog revisions'),
+ ),
+ ]
+ + cmdutil.debugrevlogopts
+ + cmdutil.formatteropts,
_(b'-c|-m|FILE'),
optionalrepo=True,
)
@@ -797,12 +806,16 @@
The sparse read can be enabled with experimental.sparse-read = True
"""
+ revs = None
+ revs_opt = opts.pop('rev', [])
+ if revs_opt:
+ revs = [int(r) for r in revs_opt]
revlog = cmdutil.openrevlog(
repo, b'debugdeltachain', file_, pycompat.byteskwargs(opts)
)
fm = ui.formatter(b'debugdeltachain', pycompat.byteskwargs(opts))
- lines = revlog_debug.debug_delta_chain(revlog)
+ lines = revlog_debug.debug_delta_chain(revlog, revs=revs)
# first entry is the header
header = next(lines)
fm.plain(header)
--- a/mercurial/revlogutils/debug.py Mon Sep 18 23:37:06 2023 +0200
+++ b/mercurial/revlogutils/debug.py Tue Sep 19 01:24:10 2023 +0200
@@ -801,7 +801,7 @@
return p1, p2, compsize, uncompsize, deltatype, chain, chain_size
-def debug_delta_chain(revlog):
+def debug_delta_chain(revlog, revs=None):
auditor = DeltaChainAuditor(revlog)
r = revlog
start = r.start
@@ -818,8 +818,14 @@
header += b'\n'
yield header
+ if revs is None:
+ all_revs = iter(r)
+ else:
+ revlog_size = len(r)
+ all_revs = sorted(rev for rev in revs if rev < revlog_size)
+
chainbases = {}
- for rev in r:
+ for rev in all_revs:
p1, p2, comp, uncomp, deltatype, chain, chainsize = auditor.revinfo(rev)
chainbase = chain[0]
chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
--- a/tests/test-completion.t Mon Sep 18 23:37:06 2023 +0200
+++ b/tests/test-completion.t Tue Sep 19 01:24:10 2023 +0200
@@ -296,7 +296,7 @@
debugdag: tags, branches, dots, spaces
debugdata: changelog, manifest, dir
debugdate: extended
- debugdeltachain: changelog, manifest, dir, template
+ debugdeltachain: rev, changelog, manifest, dir, template
debugdirstateignorepatternshash:
debugdirstate: nodates, dates, datesort, docket, all
debugdiscovery: old, nonheads, rev, seed, local-as-revs, remote-as-revs, ssh, remotecmd, insecure, template