##// END OF EJS Templates
debug: add debugwireargs to test argument passing over the wire...
Peter Arrenbrecht -
r13720:9c4e04fe default
parent child Browse files
Show More
@@ -0,0 +1,42 b''
1
2 Test wire protocol argument passing
3
4 Setup repo:
5
6 $ hg init repo
7
8 Local:
9
10 $ hg debugwireargs repo eins zwei
11 eins zwei None None
12
13 HTTP:
14
15 $ hg serve -R repo -p $HGPORT -d --pid-file=hg1.pid -E error.log -A access.log
16 $ cat hg1.pid >> $DAEMON_PIDS
17
18 $ hg debugwireargs http://localhost:$HGPORT/ eins zwei
19 eins zwei None None
20 $ cat access.log
21 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
22 * - - [*] "GET /?cmd=debugwireargs&one=eins&two=zwei HTTP/1.1" 200 - (glob)
23 * - - [*] "GET /?cmd=debugwireargs&one=eins&two=zwei HTTP/1.1" 200 - (glob)
24
25 SSH (try to exercise the ssh functionality with a dummy script):
26
27 $ cat <<EOF > dummyssh
28 > import sys
29 > import os
30 > os.chdir(os.path.dirname(sys.argv[0]))
31 > if sys.argv[1] != "user@dummy":
32 > sys.exit(-1)
33 > if not os.path.exists("dummyssh"):
34 > sys.exit(-1)
35 > os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"
36 > r = os.system(sys.argv[2])
37 > sys.exit(bool(r))
38 > EOF
39
40 $ hg debugwireargs --ssh "python ./dummyssh" ssh://user@dummy/repo eins zwei
41 eins zwei None None
42
@@ -1582,6 +1582,21 b' def debugwalk(ui, repo, *pats, **opts):'
1582 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1582 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1583 ui.write("%s\n" % line.rstrip())
1583 ui.write("%s\n" % line.rstrip())
1584
1584
1585 def debugwireargs(ui, repopath, *vals, **opts):
1586 repo = hg.repository(hg.remoteui(ui, opts), repopath)
1587 for opt in remoteopts:
1588 del opts[opt[1]]
1589 args = {}
1590 for k, v in opts.iteritems():
1591 if v:
1592 args[k] = v
1593 # run twice to check that we don't mess up the stream for the next command
1594 res1 = repo.debugwireargs(*vals, **args)
1595 res2 = repo.debugwireargs(*vals, **args)
1596 ui.write("%s\n" % res1)
1597 if res1 != res2:
1598 ui.warn("%s\n" % res2)
1599
1585 def diff(ui, repo, *pats, **opts):
1600 def diff(ui, repo, *pats, **opts):
1586 """diff repository (or selected files)
1601 """diff repository (or selected files)
1587
1602
@@ -4456,6 +4471,12 b' table = {'
4456 _('revision to check'), _('REV'))],
4471 _('revision to check'), _('REV'))],
4457 _('[-r REV] [REV]')),
4472 _('[-r REV] [REV]')),
4458 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
4473 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
4474 "debugwireargs":
4475 (debugwireargs,
4476 [('', 'three', '', 'three'),
4477 ('', 'four', '', 'four'),
4478 ] + remoteopts,
4479 _('REPO [OPTIONS]... [ONE [TWO]]')),
4459 "^diff":
4480 "^diff":
4460 (diff,
4481 (diff,
4461 [('r', 'rev', [],
4482 [('r', 'rev', [],
@@ -4789,6 +4810,6 b' table = {'
4789 }
4810 }
4790
4811
4791 norepo = ("clone init version help debugcommands debugcomplete"
4812 norepo = ("clone init version help debugcommands debugcomplete"
4792 " debugdate debuginstall debugfsinfo debugpushkey")
4813 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs")
4793 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
4814 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
4794 " debugdata debugindex debugindexdot")
4815 " debugdata debugindex debugindexdot")
@@ -1905,6 +1905,10 b' class localrepository(repo.repository):'
1905 def listkeys(self, namespace):
1905 def listkeys(self, namespace):
1906 return pushkey.list(self, namespace)
1906 return pushkey.list(self, namespace)
1907
1907
1908 def debugwireargs(self, one, two, three=None, four=None):
1909 '''used to test argument passing over the wire'''
1910 return "%s %s %s %s" % (one, two, three, four)
1911
1908 # used to avoid circular references so destructors work
1912 # used to avoid circular references so destructors work
1909 def aftertrans(files):
1913 def aftertrans(files):
1910 renamefiles = [tuple(t) for t in files]
1914 renamefiles = [tuple(t) for t in files]
@@ -133,6 +133,15 b' class wirerepository(repo.repository):'
133 self.ui.status(_('remote: '), l)
133 self.ui.status(_('remote: '), l)
134 return ret
134 return ret
135
135
136 def debugwireargs(self, one, two, three=None, four=None):
137 # don't pass optional arguments left at their default value
138 opts = {}
139 if three is not None:
140 opts['three'] = three
141 if four is not None:
142 opts['four'] = four
143 return self._call('debugwireargs', one=one, two=two, **opts)
144
136 # server side
145 # server side
137
146
138 class streamres(object):
147 class streamres(object):
@@ -199,6 +208,9 b' def changegroupsubset(repo, proto, bases'
199 cg = repo.changegroupsubset(bases, heads, 'serve')
208 cg = repo.changegroupsubset(bases, heads, 'serve')
200 return streamres(proto.groupchunks(cg))
209 return streamres(proto.groupchunks(cg))
201
210
211 def debugwireargs(repo, proto, one, two):
212 return repo.debugwireargs(one, two)
213
202 def heads(repo, proto):
214 def heads(repo, proto):
203 h = repo.heads()
215 h = repo.heads()
204 return encodelist(h) + "\n"
216 return encodelist(h) + "\n"
@@ -343,6 +355,7 b' commands = {'
343 'capabilities': (capabilities, ''),
355 'capabilities': (capabilities, ''),
344 'changegroup': (changegroup, 'roots'),
356 'changegroup': (changegroup, 'roots'),
345 'changegroupsubset': (changegroupsubset, 'bases heads'),
357 'changegroupsubset': (changegroupsubset, 'bases heads'),
358 'debugwireargs': (debugwireargs, 'one two'),
346 'heads': (heads, ''),
359 'heads': (heads, ''),
347 'hello': (hello, ''),
360 'hello': (hello, ''),
348 'listkeys': (listkeys, 'namespace'),
361 'listkeys': (listkeys, 'namespace'),
@@ -87,6 +87,7 b' Show debug commands if there are no othe'
87 debugstate
87 debugstate
88 debugsub
88 debugsub
89 debugwalk
89 debugwalk
90 debugwireargs
90
91
91 Do not show the alias of a debug command if there are other candidates
92 Do not show the alias of a debug command if there are other candidates
92 (this should hide rawcommit)
93 (this should hide rawcommit)
@@ -227,6 +228,7 b' Show all commands + options'
227 debugstate: nodates
228 debugstate: nodates
228 debugsub: rev
229 debugsub: rev
229 debugwalk: include, exclude
230 debugwalk: include, exclude
231 debugwireargs: three, four, ssh, remotecmd, insecure
230 grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
232 grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
231 heads: rev, topo, active, closed, style, template
233 heads: rev, topo, active, closed, style, template
232 help:
234 help:
General Comments 0
You need to be logged in to leave comments. Login now