diff mercurial/debugcommands.py @ 35929:5f029d03cf71

debugcommands: introduce debugpeer command `hg debugpeer <path>` will establish a connection to a peer repository and print information about it. If you add --debug, it will log low-level protocol request info. This will be useful for upcoming tests around protocol handshaking. Differential Revision: https://phab.mercurial-scm.org/D2025
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 03 Feb 2018 12:01:01 -0800
parents 2da4144e6716
children 8eb13f5d5d3f
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Sun Feb 04 12:47:37 2018 -0800
+++ b/mercurial/debugcommands.py	Sat Feb 03 12:01:01 2018 -0800
@@ -1693,6 +1693,25 @@
     ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
     ui.write('\n')
 
+@command('debugpeer', [], _('PATH'), norepo=True)
+def debugpeer(ui, path):
+    """establish a connection to a peer repository"""
+    # Always enable peer request logging. Requires --debug to display
+    # though.
+    overrides = {
+        ('devel', 'debug.peer-request'): True,
+    }
+
+    with ui.configoverride(overrides):
+        peer = hg.peer(ui, {}, path)
+
+        local = peer.local() is not None
+        canpush = peer.canpush()
+
+        ui.write(_('url: %s\n') % peer.url())
+        ui.write(_('local: %s\n') % (_('yes') if local else _('no')))
+        ui.write(_('pushable: %s\n') % (_('yes') if canpush else _('no')))
+
 @command('debugpickmergetool',
         [('r', 'rev', '', _('check for files in this revision'), _('REV')),
          ('', 'changedelete', None, _('emulate merging change and delete')),