diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -2079,16 +2079,29 @@ @command( b'debugnodemap', - [('', b'dump', False, _(b'write a (binary) serialised nodemap on stdin'))], + [ + ( + '', + b'dump-new', + False, + _(b'write a (binary) serialised (new) nodemap on stdin'), + ), + ('', b'dump-disk', False, _(b'dump on-disk data on stdin')), + ], ) def debugnodemap(ui, repo, **opts): """write and inspect on disk nodemap """ - if opts['dump']: + if opts['dump_new']: unfi = repo.unfiltered() cl = unfi.changelog data = nodemap.persistent_data(cl.index) ui.write(data) + elif opts['dump_disk']: + unfi = repo.unfiltered() + cl = unfi.changelog + data = nodemap.persisted_data(cl) + ui.write(data) @command( diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py --- a/mercurial/revlogutils/nodemap.py +++ b/mercurial/revlogutils/nodemap.py @@ -21,6 +21,13 @@ raise error.RevlogError(b'unknown node: %s' % x) +def persisted_data(revlog): + """read the nodemap for a revlog from disk""" + if revlog.nodemap_file is None: + return None + return revlog.opener.tryread(revlog.nodemap_file) + + def setup_persistent_nodemap(tr, revlog): """Install whatever is needed transaction side to persist a nodemap on disk diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -290,7 +290,7 @@ debugmanifestfulltextcache: clear, add debugmergestate: debugnamecomplete: - debugnodemap: dump + debugnodemap: dump-new, dump-disk debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template debugp1copies: rev debugp2copies: rev diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t --- a/tests/test-persistent-nodemap.t +++ b/tests/test-persistent-nodemap.t @@ -10,9 +10,9 @@ > exp-persistent-nodemap=yes > EOF $ hg debugbuilddag .+5000 - $ hg debugnodemap --dump | f --sha256 --size + $ hg debugnodemap --dump-new | f --sha256 --size size=245760, sha256=bc400bf49f11e83bbd25630439feee6628a80a8602d2e38972eac44cc3efe10c - $ f --sha256 --bytes=256 --hexdump --size < .hg/store/00changelog.n + $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size size=245760, sha256=bc400bf49f11e83bbd25630439feee6628a80a8602d2e38972eac44cc3efe10c 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|