Patchwork [2,of,2] debug: make debug{revlog, index, data} --dir not just a flag

login
register
mail settings
Submitter via Mercurial-devel
Date June 24, 2016, 6:28 p.m.
Message ID <191c7737feb52a2be31c.1466792905@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/15605/
State Accepted
Headers show

Comments

via Mercurial-devel - June 24, 2016, 6:28 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1466791961 25200
#      Fri Jun 24 11:12:41 2016 -0700
# Node ID 191c7737feb52a2be31cbad7655610e3712a5b9d
# Parent  ae3d1555d324cbc4f77818ca3c5fca9864619ec8
debug: make debug{revlog,index,data} --dir not just a flag

The directory argument (for tree manifests) should belong to to the
--dir argument. I had mistakenly made --dir a flag. One effect of this
was that I had meant for "-m" to be optional, but instead it changed
the behavior of --dir, so with "hg debugdata -m --dir dir1 0", the -m
took over and the "dir1" got treated as a revision in the root
manifest log.
Augie Fackler - June 27, 2016, 5:02 p.m.
queued these, thanks

> On Jun 24, 2016, at 2:28 PM, Martin von Zweigbergk via Mercurial-devel <mercurial-devel@mercurial-scm.org> wrote:
> 
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1466791961 25200
> #      Fri Jun 24 11:12:41 2016 -0700
> # Node ID 191c7737feb52a2be31cbad7655610e3712a5b9d
> # Parent  ae3d1555d324cbc4f77818ca3c5fca9864619ec8
> debug: make debug{revlog,index,data} --dir not just a flag
> 
> The directory argument (for tree manifests) should belong to to the
> --dir argument. I had mistakenly made --dir a flag. One effect of this
> was that I had meant for "-m" to be optional, but instead it changed
> the behavior of --dir, so with "hg debugdata -m --dir dir1 0", the -m
> took over and the "dir1" got treated as a revision in the root
> manifest log.
> 
> diff -r ae3d1555d324 -r 191c7737feb5 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py	Fri Jun 24 11:25:55 2016 -0700
> +++ b/mercurial/cmdutil.py	Fri Jun 24 11:12:41 2016 -0700
> @@ -532,7 +532,7 @@
>         msg = _('cannot specify --changelog and --manifest at the same time')
>     elif cl and dir:
>         msg = _('cannot specify --changelog and --dir at the same time')
> -    elif cl or mf:
> +    elif cl or mf or dir:
>         if file_:
>             msg = _('cannot specify filename with --changelog or --manifest')
>         elif not repo:
> @@ -549,7 +549,7 @@
>             if 'treemanifest' not in repo.requirements:
>                 raise error.Abort(_("--dir can only be used on repos with "
>                                    "treemanifest enabled"))
> -            dirlog = repo.dirlog(file_)
> +            dirlog = repo.dirlog(dir)
>             if len(dirlog):
>                 r = dirlog
>         elif mf:
> diff -r ae3d1555d324 -r 191c7737feb5 mercurial/commands.py
> --- a/mercurial/commands.py	Fri Jun 24 11:25:55 2016 -0700
> +++ b/mercurial/commands.py	Fri Jun 24 11:12:41 2016 -0700
> @@ -216,7 +216,7 @@
> debugrevlogopts = [
>     ('c', 'changelog', False, _('open changelog')),
>     ('m', 'manifest', False, _('open manifest')),
> -    ('', 'dir', False, _('open directory manifest')),
> +    ('', 'dir', '', _('open directory manifest')),
> ]
> 
> # Commands start here, listed alphabetically
> @@ -2299,7 +2299,7 @@
> @command('debugdata', debugrevlogopts, _('-c|-m|FILE REV'))
> def debugdata(ui, repo, file_, rev=None, **opts):
>     """dump the contents of a data file revision"""
> -    if opts.get('changelog') or opts.get('manifest'):
> +    if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
>         if rev is not None:
>             raise error.CommandError('debugdata', _('invalid arguments'))
>         file_, rev = None, file_
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r ae3d1555d324 -r 191c7737feb5 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Fri Jun 24 11:25:55 2016 -0700
+++ b/mercurial/cmdutil.py	Fri Jun 24 11:12:41 2016 -0700
@@ -532,7 +532,7 @@ 
         msg = _('cannot specify --changelog and --manifest at the same time')
     elif cl and dir:
         msg = _('cannot specify --changelog and --dir at the same time')
-    elif cl or mf:
+    elif cl or mf or dir:
         if file_:
             msg = _('cannot specify filename with --changelog or --manifest')
         elif not repo:
@@ -549,7 +549,7 @@ 
             if 'treemanifest' not in repo.requirements:
                 raise error.Abort(_("--dir can only be used on repos with "
                                    "treemanifest enabled"))
-            dirlog = repo.dirlog(file_)
+            dirlog = repo.dirlog(dir)
             if len(dirlog):
                 r = dirlog
         elif mf:
diff -r ae3d1555d324 -r 191c7737feb5 mercurial/commands.py
--- a/mercurial/commands.py	Fri Jun 24 11:25:55 2016 -0700
+++ b/mercurial/commands.py	Fri Jun 24 11:12:41 2016 -0700
@@ -216,7 +216,7 @@ 
 debugrevlogopts = [
     ('c', 'changelog', False, _('open changelog')),
     ('m', 'manifest', False, _('open manifest')),
-    ('', 'dir', False, _('open directory manifest')),
+    ('', 'dir', '', _('open directory manifest')),
 ]
 
 # Commands start here, listed alphabetically
@@ -2299,7 +2299,7 @@ 
 @command('debugdata', debugrevlogopts, _('-c|-m|FILE REV'))
 def debugdata(ui, repo, file_, rev=None, **opts):
     """dump the contents of a data file revision"""
-    if opts.get('changelog') or opts.get('manifest'):
+    if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
         if rev is not None:
             raise error.CommandError('debugdata', _('invalid arguments'))
         file_, rev = None, file_