diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -21,7 +21,7 @@ import minirst, revset, fileset import dagparser, context, simplemerge, graphmod, copies import random import setdiscovery, treediscovery, dagutil, pvec, localrepo -import phases, obsolete, exchange +import phases, obsolete, exchange, bundle2 import ui as uimod table = {} @@ -1816,6 +1816,8 @@ def debugbundle(ui, bundlepath, all=None f = hg.openpath(ui, bundlepath) try: gen = exchange.readbundle(ui, f, bundlepath) + if isinstance(gen, bundle2.unbundle20): + return _debugbundle2(ui, gen, all=all, **opts) if all: ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n")) @@ -1848,6 +1850,8 @@ def debugbundle(ui, bundlepath, all=None fname = chunkdata['filename'] showchunks(fname) else: + if isinstance(gen, bundle2.unbundle20): + raise util.Abort(_('use debugbundle2 for this file')) chunkdata = gen.changelogheader() chain = None while True: @@ -1860,6 +1864,26 @@ def debugbundle(ui, bundlepath, all=None finally: f.close() +def _debugbundle2(ui, gen, **opts): + """lists the contents of a bundle2""" + if not isinstance(gen, bundle2.unbundle20): + raise util.Abort(_('not a bundle2 file')) + ui.write(('Stream params: %s\n' % repr(gen.params))) + for part in gen.iterparts(): + ui.write('%s -- %r\n' % (part.type, repr(part.params))) + if part.type == 'b2x:changegroup': + version = part.params.get('version', '01') + cg = changegroup.packermap[version][1](part, 'UN') + chunkdata = cg.changelogheader() + chain = None + while True: + chunkdata = cg.deltachunk(chain) + if not chunkdata: + break + node = chunkdata['node'] + ui.write(" %s\n" % hex(node)) + chain = node + @command('debugcheckstate', [], '') def debugcheckstate(ui, repo): """validate the correctness of the current dirstate""" diff --git a/tests/test-bundle2-format.t b/tests/test-bundle2-format.t --- a/tests/test-bundle2-format.t +++ b/tests/test-bundle2-format.t @@ -755,6 +755,13 @@ Support for changegroup \x87\xcd\xc9n\x8e\xaa\xb6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02H (esc) \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc) + $ hg debugbundle ../rev.hg2 + Stream params: {} + b2x:changegroup -- '{}' + 32af7686d403cf45b5d95f2d70cebea587ac806a + 9520eea781bcca16c1e15acc0ba14335a0e8e5ba + eea13746799a9e0bfd88f29d3c2e9dc9389f524f + 02de42196ebee42ef284b6780a87cdc96e8eaab6 $ hg unbundle2 < ../rev.hg2 adding changesets adding manifests