debugbundle: add --part-type flag to emit only named part types
authorDanek Duvall <danek.duvall@oracle.com>
Mon, 05 Jun 2017 16:19:41 -0700
changeset 32694 3ef319e9505f
parent 32693 c401ad7fdf86
child 32695 0841382d114a
debugbundle: add --part-type flag to emit only named part types This removes the need in the tests for grep -A, which is not supported on Solaris.
mercurial/debugcommands.py
tests/test-completion.t
tests/test-obsolete-bundle-strip.t
--- a/mercurial/debugcommands.py	Mon Jun 05 20:37:45 2017 -0400
+++ b/mercurial/debugcommands.py	Mon Jun 05 16:19:41 2017 -0700
@@ -314,7 +314,10 @@
     if not isinstance(gen, bundle2.unbundle20):
         raise error.Abort(_('not a bundle2 file'))
     ui.write(('Stream params: %s\n' % repr(gen.params)))
+    parttypes = opts.get('part_type', [])
     for part in gen.iterparts():
+        if parttypes and part.type not in parttypes:
+            continue
         ui.write('%s -- %r\n' % (part.type, repr(part.params)))
         if part.type == 'changegroup':
             version = part.params.get('version', '01')
@@ -325,6 +328,7 @@
 
 @command('debugbundle',
         [('a', 'all', None, _('show all details')),
+         ('', 'part-type', [], _('show only the named part type')),
          ('', 'spec', None, _('print the bundlespec of the bundle'))],
         _('FILE'),
         norepo=True)
--- a/tests/test-completion.t	Mon Jun 05 20:37:45 2017 -0400
+++ b/tests/test-completion.t	Mon Jun 05 16:19:41 2017 -0700
@@ -247,7 +247,7 @@
   debugancestor: 
   debugapplystreamclonebundle: 
   debugbuilddag: mergeable-file, overwritten-file, new-file
-  debugbundle: all, spec
+  debugbundle: all, part-type, spec
   debugcheckstate: 
   debugcolor: style
   debugcommands: 
--- a/tests/test-obsolete-bundle-strip.t	Mon Jun 05 20:37:45 2017 -0400
+++ b/tests/test-obsolete-bundle-strip.t	Mon Jun 05 16:19:41 2017 -0700
@@ -67,7 +67,7 @@
   >     cat "${markersfile}"
   >     printf "# bundling: "
   >     hg bundle --hidden --base "parents(roots(${revs}))" --rev "${revs}" "${bundlefile}"
-  >     hg debugbundle "${bundlefile}" | grep "obsmarkers --" -A 100 | sed 1,2d > "${contentfile}"
+  >     hg debugbundle --part-type obsmarkers "${bundlefile}" | sed 1,3d > "${contentfile}"
   >     echo '### Bundled markers ###'
   >     cat "${contentfile}"
   >     echo '### diff <relevant> <bundled> ###'
@@ -86,7 +86,7 @@
   >         hg debugobsolete --hidden | sort | sed 's/^/    /' > "${prestripfile}"
   >         hg strip --hidden --rev "${revs}"
   >         hg debugobsolete --hidden | sort | sed 's/^/    /' > "${poststripfile}"
-  >         hg debugbundle .hg/strip-backup/* | grep "obsmarkers --" -A 100 | sed 1,2d > "${stripcontentfile}"
+  >         hg debugbundle --part-type obsmarkers .hg/strip-backup/* | sed 1,3d > "${stripcontentfile}"
   >         echo '### Backup markers ###'
   >         cat "${stripcontentfile}"
   >         echo '### diff <relevant> <backed-up> ###'