mercurial/debugcommands.py
changeset 46663 a4c19a162615
parent 46655 e4e971abb6a3
child 46711 a41565bef69f
equal deleted inserted replaced
46662:db8037e38085 46663:a4c19a162615
   469 @command(b'debugcapabilities', [], _(b'PATH'), norepo=True)
   469 @command(b'debugcapabilities', [], _(b'PATH'), norepo=True)
   470 def debugcapabilities(ui, path, **opts):
   470 def debugcapabilities(ui, path, **opts):
   471     """lists the capabilities of a remote peer"""
   471     """lists the capabilities of a remote peer"""
   472     opts = pycompat.byteskwargs(opts)
   472     opts = pycompat.byteskwargs(opts)
   473     peer = hg.peer(ui, opts, path)
   473     peer = hg.peer(ui, opts, path)
   474     caps = peer.capabilities()
   474     try:
   475     ui.writenoi18n(b'Main capabilities:\n')
   475         caps = peer.capabilities()
   476     for c in sorted(caps):
   476         ui.writenoi18n(b'Main capabilities:\n')
   477         ui.write(b'  %s\n' % c)
   477         for c in sorted(caps):
   478     b2caps = bundle2.bundle2caps(peer)
   478             ui.write(b'  %s\n' % c)
   479     if b2caps:
   479         b2caps = bundle2.bundle2caps(peer)
   480         ui.writenoi18n(b'Bundle2 capabilities:\n')
   480         if b2caps:
   481         for key, values in sorted(pycompat.iteritems(b2caps)):
   481             ui.writenoi18n(b'Bundle2 capabilities:\n')
   482             ui.write(b'  %s\n' % key)
   482             for key, values in sorted(pycompat.iteritems(b2caps)):
   483             for v in values:
   483                 ui.write(b'  %s\n' % key)
   484                 ui.write(b'    %s\n' % v)
   484                 for v in values:
       
   485                     ui.write(b'    %s\n' % v)
       
   486     finally:
       
   487         peer.close()
   485 
   488 
   486 
   489 
   487 @command(
   490 @command(
   488     b'debugchangedfiles',
   491     b'debugchangedfiles',
   489     [
   492     [
  2613     }
  2616     }
  2614 
  2617 
  2615     with ui.configoverride(overrides):
  2618     with ui.configoverride(overrides):
  2616         peer = hg.peer(ui, {}, path)
  2619         peer = hg.peer(ui, {}, path)
  2617 
  2620 
  2618         local = peer.local() is not None
  2621         try:
  2619         canpush = peer.canpush()
  2622             local = peer.local() is not None
  2620 
  2623             canpush = peer.canpush()
  2621         ui.write(_(b'url: %s\n') % peer.url())
  2624 
  2622         ui.write(_(b'local: %s\n') % (_(b'yes') if local else _(b'no')))
  2625             ui.write(_(b'url: %s\n') % peer.url())
  2623         ui.write(_(b'pushable: %s\n') % (_(b'yes') if canpush else _(b'no')))
  2626             ui.write(_(b'local: %s\n') % (_(b'yes') if local else _(b'no')))
       
  2627             ui.write(
       
  2628                 _(b'pushable: %s\n') % (_(b'yes') if canpush else _(b'no'))
       
  2629             )
       
  2630         finally:
       
  2631             peer.close()
  2624 
  2632 
  2625 
  2633 
  2626 @command(
  2634 @command(
  2627     b'debugpickmergetool',
  2635     b'debugpickmergetool',
  2628     [
  2636     [
  2721     With five args, set a key to new if it currently is set to old.
  2729     With five args, set a key to new if it currently is set to old.
  2722     Reports success or failure.
  2730     Reports success or failure.
  2723     """
  2731     """
  2724 
  2732 
  2725     target = hg.peer(ui, {}, repopath)
  2733     target = hg.peer(ui, {}, repopath)
  2726     if keyinfo:
  2734     try:
  2727         key, old, new = keyinfo
  2735         if keyinfo:
  2728         with target.commandexecutor() as e:
  2736             key, old, new = keyinfo
  2729             r = e.callcommand(
  2737             with target.commandexecutor() as e:
  2730                 b'pushkey',
  2738                 r = e.callcommand(
  2731                 {
  2739                     b'pushkey',
  2732                     b'namespace': namespace,
  2740                     {
  2733                     b'key': key,
  2741                         b'namespace': namespace,
  2734                     b'old': old,
  2742                         b'key': key,
  2735                     b'new': new,
  2743                         b'old': old,
  2736                 },
  2744                         b'new': new,
  2737             ).result()
  2745                     },
  2738 
  2746                 ).result()
  2739         ui.status(pycompat.bytestr(r) + b'\n')
  2747 
  2740         return not r
  2748             ui.status(pycompat.bytestr(r) + b'\n')
  2741     else:
  2749             return not r
  2742         for k, v in sorted(pycompat.iteritems(target.listkeys(namespace))):
  2750         else:
  2743             ui.write(
  2751             for k, v in sorted(pycompat.iteritems(target.listkeys(namespace))):
  2744                 b"%s\t%s\n" % (stringutil.escapestr(k), stringutil.escapestr(v))
  2752                 ui.write(
  2745             )
  2753                     b"%s\t%s\n"
       
  2754                     % (stringutil.escapestr(k), stringutil.escapestr(v))
       
  2755                 )
       
  2756     finally:
       
  2757         target.close()
  2746 
  2758 
  2747 
  2759 
  2748 @command(b'debugpvec', [], _(b'A B'))
  2760 @command(b'debugpvec', [], _(b'A B'))
  2749 def debugpvec(ui, repo, a, b=None):
  2761 def debugpvec(ui, repo, a, b=None):
  2750     ca = scmutil.revsingle(repo, a)
  2762     ca = scmutil.revsingle(repo, a)
  4093     norepo=True,
  4105     norepo=True,
  4094 )
  4106 )
  4095 def debugwireargs(ui, repopath, *vals, **opts):
  4107 def debugwireargs(ui, repopath, *vals, **opts):
  4096     opts = pycompat.byteskwargs(opts)
  4108     opts = pycompat.byteskwargs(opts)
  4097     repo = hg.peer(ui, opts, repopath)
  4109     repo = hg.peer(ui, opts, repopath)
  4098     for opt in cmdutil.remoteopts:
  4110     try:
  4099         del opts[opt[1]]
  4111         for opt in cmdutil.remoteopts:
  4100     args = {}
  4112             del opts[opt[1]]
  4101     for k, v in pycompat.iteritems(opts):
  4113         args = {}
  4102         if v:
  4114         for k, v in pycompat.iteritems(opts):
  4103             args[k] = v
  4115             if v:
  4104     args = pycompat.strkwargs(args)
  4116                 args[k] = v
  4105     # run twice to check that we don't mess up the stream for the next command
  4117         args = pycompat.strkwargs(args)
  4106     res1 = repo.debugwireargs(*vals, **args)
  4118         # run twice to check that we don't mess up the stream for the next command
  4107     res2 = repo.debugwireargs(*vals, **args)
  4119         res1 = repo.debugwireargs(*vals, **args)
  4108     ui.write(b"%s\n" % res1)
  4120         res2 = repo.debugwireargs(*vals, **args)
  4109     if res1 != res2:
  4121         ui.write(b"%s\n" % res1)
  4110         ui.warn(b"%s\n" % res2)
  4122         if res1 != res2:
       
  4123             ui.warn(b"%s\n" % res2)
       
  4124     finally:
       
  4125         repo.close()
  4111 
  4126 
  4112 
  4127 
  4113 def _parsewirelangblocks(fh):
  4128 def _parsewirelangblocks(fh):
  4114     activeaction = None
  4129     activeaction = None
  4115     blocklines = []
  4130     blocklines = []