mercurial/debugcommands.py
changeset 36527 44dc34b8d17b
parent 36492 6e90c59b6da1
child 36528 72e487851a53
equal deleted inserted replaced
36526:7cc4a9b9732a 36527:44dc34b8d17b
    71     treediscovery,
    71     treediscovery,
    72     upgrade,
    72     upgrade,
    73     url as urlmod,
    73     url as urlmod,
    74     util,
    74     util,
    75     vfs as vfsmod,
    75     vfs as vfsmod,
       
    76     wireprotoserver,
    76 )
    77 )
    77 
    78 
    78 release = lockmod.release
    79 release = lockmod.release
    79 
    80 
    80 command = registrar.command()
    81 command = registrar.command()
  2228     if not opts['show_revs']:
  2229     if not opts['show_revs']:
  2229         return
  2230         return
  2230     for c in revs:
  2231     for c in revs:
  2231         ui.write("%d\n" % c)
  2232         ui.write("%d\n" % c)
  2232 
  2233 
       
  2234 @command('debugserve', [
       
  2235     ('', 'sshstdio', False, _('run an SSH server bound to process handles')),
       
  2236     ('', 'logiofd', '', _('file descriptor to log server I/O to')),
       
  2237     ('', 'logiofile', '', _('file to log server I/O to')),
       
  2238 ], '')
       
  2239 def debugserve(ui, repo, **opts):
       
  2240     """run a server with advanced settings
       
  2241 
       
  2242     This command is similar to :hg:`serve`. It exists partially as a
       
  2243     workaround to the fact that ``hg serve --stdio`` must have specific
       
  2244     arguments for security reasons.
       
  2245     """
       
  2246     opts = pycompat.byteskwargs(opts)
       
  2247 
       
  2248     if not opts['sshstdio']:
       
  2249         raise error.Abort(_('only --sshstdio is currently supported'))
       
  2250 
       
  2251     logfh = None
       
  2252 
       
  2253     if opts['logiofd'] and opts['logiofile']:
       
  2254         raise error.Abort(_('cannot use both --logiofd and --logiofile'))
       
  2255 
       
  2256     if opts['logiofd']:
       
  2257         # Line buffered because output is line based.
       
  2258         logfh = os.fdopen(int(opts['logiofd']), 'ab', 1)
       
  2259     elif opts['logiofile']:
       
  2260         logfh = open(opts['logiofile'], 'ab', 1)
       
  2261 
       
  2262     s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
       
  2263     s.serve_forever()
       
  2264 
  2233 @command('debugsetparents', [], _('REV1 [REV2]'))
  2265 @command('debugsetparents', [], _('REV1 [REV2]'))
  2234 def debugsetparents(ui, repo, rev1, rev2=None):
  2266 def debugsetparents(ui, repo, rev1, rev2=None):
  2235     """manually set the parents of the current working directory
  2267     """manually set the parents of the current working directory
  2236 
  2268 
  2237     This is useful for writing repository conversion tools, but should
  2269     This is useful for writing repository conversion tools, but should