changeset 35015:7ee2d859f720

debug: add a debugcapabilities commands This new debugcommand prints the capabilities of any remote in a human friendly way. Improved bundle2 capabilities support will be introduced in the next changesets.
author Boris Feld <boris.feld@octobus.net>
date Mon, 30 Oct 2017 17:08:16 +0100
parents 5910db5d1913
children 762ea8a1f5e7
files mercurial/debugcommands.py tests/test-completion.t tests/test-debugcommands.t tests/test-help.t
diffstat 4 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Mon Oct 30 17:46:07 2017 -0400
+++ b/mercurial/debugcommands.py	Mon Oct 30 17:08:16 2017 +0100
@@ -360,6 +360,16 @@
             return _debugbundle2(ui, gen, all=all, **opts)
         _debugchangegroup(ui, gen, all=all, **opts)
 
+@command('debugcapabilities',
+        [], _('PATH'),
+        norepo=True)
+def debugcapabilities(ui, path, **opts):
+    """lists the capabilities of a remote peer"""
+    peer = hg.peer(ui, opts, path)
+    caps = peer.capabilities()
+    ui.write(('Main capabilities:\n'))
+    for c in sorted(caps):
+        ui.write(('  %s\n') % c)
 @command('debugcheckstate', [], '')
 def debugcheckstate(ui, repo):
     """validate the correctness of the current dirstate"""
--- a/tests/test-completion.t	Mon Oct 30 17:46:07 2017 -0400
+++ b/tests/test-completion.t	Mon Oct 30 17:08:16 2017 +0100
@@ -72,6 +72,7 @@
   debugapplystreamclonebundle
   debugbuilddag
   debugbundle
+  debugcapabilities
   debugcheckstate
   debugcolor
   debugcommands
@@ -249,6 +250,7 @@
   debugapplystreamclonebundle: 
   debugbuilddag: mergeable-file, overwritten-file, new-file
   debugbundle: all, part-type, spec
+  debugcapabilities: 
   debugcheckstate: 
   debugcolor: style
   debugcommands: 
--- a/tests/test-debugcommands.t	Mon Oct 30 17:46:07 2017 -0400
+++ b/tests/test-debugcommands.t	Mon Oct 30 17:08:16 2017 +0100
@@ -156,3 +156,15 @@
   from h hidden in g at:
    debugstacktrace.py:6 in f
    debugstacktrace.py:9 in g
+
+Test debugcapabilities command:
+
+  $ hg debugcapabilities ./debugrevlog/
+  Main capabilities:
+    branchmap
+    bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
+    getbundle
+    known
+    lookup
+    pushkey
+    unbundle
--- a/tests/test-help.t	Mon Oct 30 17:46:07 2017 -0400
+++ b/tests/test-help.t	Mon Oct 30 17:08:16 2017 +0100
@@ -895,6 +895,8 @@
                  builds a repo with a given DAG from scratch in the current
                  empty repo
    debugbundle   lists the contents of a bundle
+   debugcapabilities
+                 lists the capabilities of a remote peer
    debugcheckstate
                  validate the correctness of the current dirstate
    debugcolor    show available color, effects or style