[PATCH] wireproto: add test for new optional arg missing on server

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Fri Apr 29 07:59:00 CDT 2011


# HG changeset patch
# User Peter Arrenbrecht <peter.arrenbrecht at gmail.com>
# Date 1304081641 -7200
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 @@
         (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
@@ -1916,9 +1916,9 @@
     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 @@
             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 @@
 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 @@
   $ 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 @@
   * - - [*] "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)
+  127.0.0.1 - - [29/Apr/2011 12:47:13] "GET /?cmd=capabilities HTTP/1.1" 200 -
+  127.0.0.1 - - [29/Apr/2011 12:47:13] "GET /?cmd=debugwireargs&one=eins&two=zwei HTTP/1.1" 200 -
+  127.0.0.1 - - [29/Apr/2011 12:47:13] "GET /?cmd=debugwireargs&one=eins&two=zwei HTTP/1.1" 200 -
 
 SSH (try to exercise the ssh functionality with a dummy script):
 
@@ -52,9 +59,11 @@
   > 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
 


More information about the Mercurial-devel mailing list