# HG changeset patch # User Peter Arrenbrecht # Date 2011-04-29 12:54:01 # Node ID 58e58406ed190ce59c78de13e82da1f6bc47f06c # Parent 30ccb7d03864189356db39a0e1019268bc14c416 wireproto: add test for new optional arg missing on server New argument is silently ignored by both HTTP and SSH servers. This means we can, for instance, add new flags to getbundle() to request advanced features (like lightweight-copy-aware bundles), and older servers will silently ignore this request and send back a plain bundle. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4558,6 +4558,7 @@ table = { (debugwireargs, [('', 'three', '', 'three'), ('', 'four', '', 'four'), + ('', 'five', '', 'five'), ] + remoteopts, _('REPO [OPTIONS]... [ONE [TWO]]')), "^diff": diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1921,9 +1921,9 @@ class localrepository(repo.repository): def listkeys(self, namespace): return pushkey.list(self, namespace) - def debugwireargs(self, one, two, three=None, four=None): + def debugwireargs(self, one, two, three=None, four=None, five=None): '''used to test argument passing over the wire''' - return "%s %s %s %s" % (one, two, three, four) + return "%s %s %s %s %s" % (one, two, three, four, five) # used to avoid circular references so destructors work def aftertrans(files): diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -159,7 +159,7 @@ class wirerepository(repo.repository): self.ui.status(_('remote: '), l) return ret - def debugwireargs(self, one, two, three=None, four=None): + def debugwireargs(self, one, two, three=None, four=None, five=None): # don't pass optional arguments left at their default value opts = {} if three is not None: diff --git a/tests/test-wireproto.t b/tests/test-wireproto.t --- a/tests/test-wireproto.t +++ b/tests/test-wireproto.t @@ -8,11 +8,13 @@ Setup repo: Local: $ hg debugwireargs repo eins zwei --three drei --four vier - eins zwei drei vier + eins zwei drei vier None $ hg debugwireargs repo eins zwei --four vier - eins zwei None vier + eins zwei None vier None $ hg debugwireargs repo eins zwei - eins zwei None None + eins zwei None None None + $ hg debugwireargs repo eins zwei --five fuenf + eins zwei None None fuenf HTTP: @@ -20,11 +22,13 @@ HTTP: $ cat hg1.pid >> $DAEMON_PIDS $ hg debugwireargs http://localhost:$HGPORT/ un deux trois quatre - un deux trois quatre + un deux trois quatre None $ hg debugwireargs http://localhost:$HGPORT/ eins zwei --four vier - eins zwei None vier + eins zwei None vier None $ hg debugwireargs http://localhost:$HGPORT/ eins zwei - eins zwei None None + eins zwei None None None + $ hg debugwireargs http://localhost:$HGPORT/ eins zwei --five fuenf + eins zwei None None None $ cat access.log * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) * - - [*] "GET /?cmd=debugwireargs&four=quatre&one=un&three=trois&two=deux HTTP/1.1" 200 - (glob) @@ -35,6 +39,9 @@ HTTP: * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) * - - [*] "GET /?cmd=debugwireargs&one=eins&two=zwei HTTP/1.1" 200 - (glob) * - - [*] "GET /?cmd=debugwireargs&one=eins&two=zwei HTTP/1.1" 200 - (glob) + * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) + * - - [*] "GET /?cmd=debugwireargs&one=eins&two=zwei HTTP/1.1" 200 - (glob) + * - - [*] "GET /?cmd=debugwireargs&one=eins&two=zwei HTTP/1.1" 200 - (glob) SSH (try to exercise the ssh functionality with a dummy script): @@ -52,9 +59,11 @@ SSH (try to exercise the ssh functionali > EOF $ hg debugwireargs --ssh "python ./dummyssh" ssh://user@dummy/repo uno due tre quattro - uno due tre quattro + uno due tre quattro None $ hg debugwireargs --ssh "python ./dummyssh" ssh://user@dummy/repo eins zwei --four vier - eins zwei None vier + eins zwei None vier None $ hg debugwireargs --ssh "python ./dummyssh" ssh://user@dummy/repo eins zwei - eins zwei None None + eins zwei None None None + $ hg debugwireargs --ssh "python ./dummyssh" ssh://user@dummy/repo eins zwei --five fuenf + eins zwei None None None