Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 23888:6d8bebf4d6d4
commands.debugbundle: bundle2 support
This enables debugbundle to print supporting info for bundle2 files.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Thu, 15 Jan 2015 15:35:26 -0800 |
parents | 9994f45ba714 |
children | 5827ad0b849e |
line wrap: on
line diff
--- a/mercurial/commands.py Mon Jan 12 22:30:12 2015 -0500 +++ b/mercurial/commands.py Thu Jan 15 15:35:26 2015 -0800 @@ -21,7 +21,7 @@ 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 @@ 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 @@ 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 @@ 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"""