[PATCH] debugbundle: handle the --all option for bundle2

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Apr 20 16:40:40 EDT 2016


Thanks for your patch, I really appreciate how you quickly tackle issue 
your find.

However, we are currently in feature freeze for 3.8 and this patches 
seems large enough that we would not take such churn for the sake of a 
debug command. Can you resent it after 3.8 is release (May first) for 
review?

(also, your patch seems to be missing the expected metadata header and 
decription, how did you sent it?)

Cheers

On 04/18/2016 01:56 AM, Mike Hommey wrote:
> ---
>   mercurial/commands.py | 89 +++++++++++++++++++++++++--------------------------
>   1 file changed, 43 insertions(+), 46 deletions(-)
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> index 2c25de5..a15b62b 100644
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -2089,51 +2089,56 @@ def debugbundle(ui, bundlepath, all=None, spec=None, **opts):
>           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"))
> -
> -            def showchunks(named):
> -                ui.write("\n%s\n" % named)
> -                chain = None
> -                while True:
> -                    chunkdata = gen.deltachunk(chain)
> -                    if not chunkdata:
> -                        break
> -                    node = chunkdata['node']
> -                    p1 = chunkdata['p1']
> -                    p2 = chunkdata['p2']
> -                    cs = chunkdata['cs']
> -                    deltabase = chunkdata['deltabase']
> -                    delta = chunkdata['delta']
> -                    ui.write("%s %s %s %s %s %s\n" %
> -                             (hex(node), hex(p1), hex(p2),
> -                              hex(cs), hex(deltabase), len(delta)))
> -                    chain = node
> -
> -            chunkdata = gen.changelogheader()
> -            showchunks("changelog")
> -            chunkdata = gen.manifestheader()
> -            showchunks("manifest")
> -            while True:
> -                chunkdata = gen.filelogheader()
> -                if not chunkdata:
> -                    break
> -                fname = chunkdata['filename']
> -                showchunks(fname)
> -        else:
> -            if isinstance(gen, bundle2.unbundle20):
> -                raise error.Abort(_('use debugbundle2 for this file'))
> -            chunkdata = gen.changelogheader()
> +        _debugchangegroup(ui, gen, all=all, **opts)
> +
> +def _debugchangegroup(ui, gen, all=None, indent=0, **opts):
> +    indent_string = ' ' * indent
> +    if all:
> +        ui.write("%sformat: id, p1, p2, cset, delta base, len(delta)\n"
> +                 % indent_string)
> +
> +        def showchunks(named):
> +            ui.write("\n%s%s\n" % (indent_string, named))
>               chain = None
>               while True:
>                   chunkdata = gen.deltachunk(chain)
>                   if not chunkdata:
>                       break
>                   node = chunkdata['node']
> -                ui.write("%s\n" % hex(node))
> +                p1 = chunkdata['p1']
> +                p2 = chunkdata['p2']
> +                cs = chunkdata['cs']
> +                deltabase = chunkdata['deltabase']
> +                delta = chunkdata['delta']
> +                ui.write("%s%s %s %s %s %s %s\n" %
> +                         (indent_string, hex(node), hex(p1), hex(p2),
> +                          hex(cs), hex(deltabase), len(delta)))
>                   chain = node
>   
> -def _debugbundle2(ui, gen, **opts):
> +        chunkdata = gen.changelogheader()
> +        showchunks("changelog")
> +        chunkdata = gen.manifestheader()
> +        showchunks("manifest")
> +        while True:
> +            chunkdata = gen.filelogheader()
> +            if not chunkdata:
> +                break
> +            fname = chunkdata['filename']
> +            showchunks(fname)
> +    else:
> +        if isinstance(gen, bundle2.unbundle20):
> +            raise error.Abort(_('use debugbundle2 for this file'))
> +        chunkdata = gen.changelogheader()
> +        chain = None
> +        while True:
> +            chunkdata = gen.deltachunk(chain)
> +            if not chunkdata:
> +                break
> +            node = chunkdata['node']
> +            ui.write("%s%s\n" % (indent_string, hex(node)))
> +            chain = node
> +
> +def _debugbundle2(ui, gen, all=None, **opts):
>       """lists the contents of a bundle2"""
>       if not isinstance(gen, bundle2.unbundle20):
>           raise error.Abort(_('not a bundle2 file'))
> @@ -2143,15 +2148,7 @@ def _debugbundle2(ui, gen, **opts):
>           if part.type == 'changegroup':
>               version = part.params.get('version', '01')
>               cg = changegroup.getunbundler(version, 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
> +            _debugchangegroup(ui, cg, all=all, indent=4, **opts)
>   
>   @command('debugcreatestreamclonebundle', [], 'FILE')
>   def debugcreatestreamclonebundle(ui, repo, fname):
-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list