##// END OF EJS Templates
debugcommands: add debugserve command...
Gregory Szorc -
r36544:44dc34b8 default
parent child Browse files
Show More
@@ -73,6 +73,7 b' from . import ('
73 73 url as urlmod,
74 74 util,
75 75 vfs as vfsmod,
76 wireprotoserver,
76 77 )
77 78
78 79 release = lockmod.release
@@ -2230,6 +2231,37 b' def debugrevspec(ui, repo, expr, **opts)'
2230 2231 for c in revs:
2231 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 2265 @command('debugsetparents', [], _('REV1 [REV2]'))
2234 2266 def debugsetparents(ui, repo, rev1, rev2=None):
2235 2267 """manually set the parents of the current working directory
@@ -111,6 +111,7 b' Show debug commands if there are no othe'
111 111 debugrename
112 112 debugrevlog
113 113 debugrevspec
114 debugserve
114 115 debugsetparents
115 116 debugssl
116 117 debugsub
@@ -291,6 +292,7 b' Show all commands + options'
291 292 debugrename: rev
292 293 debugrevlog: changelog, manifest, dir, dump
293 294 debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, verify-optimized
295 debugserve: sshstdio, logiofd, logiofile
294 296 debugsetparents:
295 297 debugssl:
296 298 debugsub: rev
@@ -967,6 +967,7 b' Test list of internal help commands'
967 967 debugrename dump rename information
968 968 debugrevlog show data and statistics about a revlog
969 969 debugrevspec parse and apply a revision specification
970 debugserve run a server with advanced settings
970 971 debugsetparents
971 972 manually set the parents of the current working directory
972 973 debugssl test a secure connection to a server
@@ -39,6 +39,43 b' Server should answer the "hello" command'
39 39 384
40 40 capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
41 41
42 `hg debugserve --sshstdio` works
43
44 $ cd server
45 $ hg debugserve --sshstdio << EOF
46 > hello
47 > EOF
48 384
49 capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
50
51 I/O logging works
52
53 $ hg debugserve --sshstdio --logiofd 1 << EOF
54 > hello
55 > EOF
56 o> write(4) -> None:
57 o> 384\n
58 o> write(384) -> None:
59 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
60 384
61 capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
62 o> flush() -> None
63
64 $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
65 > hello
66 > EOF
67 384
68 capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
69
70 $ cat $TESTTMP/io
71 o> write(4) -> None:
72 o> 384\n
73 o> write(384) -> None:
74 o> capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
75 o> flush() -> None
76
77 $ cd ..
78
42 79 >=0.9.1 clients send a "hello" + "between" for the null range as part of handshake.
43 80 Server should reply with capabilities and should send "1\n\n" as a successful
44 81 reply with empty response to the "between".
General Comments 0
You need to be logged in to leave comments. Login now