changeset 16361:6097ede2be4d

protocol: Add the stream-preferred capability This makes the client use the uncompressed protocol.
author Benoit Allard <benoit@aeteurope.nl>
date Wed, 04 Apr 2012 00:00:47 +0200
parents e5788269741a
children 2cdd7e63211b
files mercurial/help/config.txt mercurial/localrepo.py mercurial/wireproto.py tests/test-hgweb-commands.t tests/test-http.t
diffstat 5 files changed, 31 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help/config.txt	Wed Mar 28 16:06:20 2012 +0200
+++ b/mercurial/help/config.txt	Wed Apr 04 00:00:47 2012 +0200
@@ -979,6 +979,10 @@
     the write lock while determining what data to transfer.
     Default is True.
 
+``preferuncompressed``
+    When set, clients will try to use the uncompressed streaming
+    protocol. Default is False.
+
 ``validate``
     Whether to validate the completeness of pushed changesets by
     checking that all new file revisions specified in manifests are
--- a/mercurial/localrepo.py	Wed Mar 28 16:06:20 2012 +0200
+++ b/mercurial/localrepo.py	Wed Apr 04 00:00:47 2012 +0200
@@ -2290,6 +2290,10 @@
         # and format flags on "stream" capability, and use
         # uncompressed only if compatible.
 
+        if not stream:
+            # if the server explicitely prefer to stream (for fast LANs)
+            stream = remote.capable('stream-preferred')
+
         if stream and not heads:
             # 'stream' means remote revlog format is revlogv1 only
             if remote.capable('stream'):
--- a/mercurial/wireproto.py	Wed Mar 28 16:06:20 2012 +0200
+++ b/mercurial/wireproto.py	Wed Apr 04 00:00:47 2012 +0200
@@ -415,6 +415,8 @@
     caps = ('lookup changegroupsubset branchmap pushkey known getbundle '
             'unbundlehash batch').split()
     if _allowstream(repo.ui):
+        if repo.ui.configbool('server', 'preferuncompressed', False):
+            caps.append('stream-preferred')
         requiredformats = repo.requirements & repo.supportedformats
         # if our local revlogs are just revlogv1, add 'stream' cap
         if not requiredformats - set(('revlogv1',)):
--- a/tests/test-hgweb-commands.t	Wed Mar 28 16:06:20 2012 +0200
+++ b/tests/test-hgweb-commands.t	Wed Apr 04 00:00:47 2012 +0200
@@ -1198,10 +1198,10 @@
   	top: -1px;
   }
 
-Stop and restart with HGENCODING=cp932
+Stop and restart with HGENCODING=cp932 and preferuncompressed
 
   $ "$TESTDIR/killdaemons.py"
-  $ HGENCODING=cp932 hg serve --config server.uncompressed=False -n test \
+  $ HGENCODING=cp932 hg serve --config server.preferuncompressed=True -n test \
   >     -p $HGPORT -d --pid-file=hg.pid -E errors.log
   $ cat hg.pid >> $DAEMON_PIDS
 
@@ -1216,6 +1216,15 @@
   >     | grep '^var data ='
   var data = [["548001d11f45", [0, 1], [[0, 0, 1, -1, ""]], "\u80fd", "test", "1970-01-01", ["unstable", true], ["tip"], ["something"]], ["ba87b23d29ca", [0, 1], [[0, 0, 1, 3, "FF0000"]], "branch", "test", "1970-01-01", ["unstable", false], [], []], ["1d22e65f027e", [0, 1], [[0, 0, 1, 3, ""]], "branch", "test", "1970-01-01", ["stable", true], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1, 3, ""]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]];
 
+capabilities
+
+  $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=capabilities'; echo
+  200 Script output follows
+  
+  lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream-preferred stream unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024
+
+heads
+
 ERRORS ENCOUNTERED
 
   $ cat errors.log
--- a/tests/test-http.t	Wed Mar 28 16:06:20 2012 +0200
+++ b/tests/test-http.t	Wed Apr 04 00:00:47 2012 +0200
@@ -112,6 +112,7 @@
   [255]
 
 test http authentication
++ use the same server to test server side streaming preference
 
   $ cd test
   $ cat << EOT > userpass.py
@@ -127,7 +128,8 @@
   > def extsetup():
   >     common.permhooks.insert(0, perform_authentication)
   > EOT
-  $ hg --config extensions.x=userpass.py serve -p $HGPORT2 -d --pid-file=pid
+  $ hg --config extensions.x=userpass.py serve -p $HGPORT2 -d --pid-file=pid \
+  >    --config server.preferuncompressed=True
   $ cat pid >> $DAEMON_PIDS
 
   $ hg id http://localhost:$HGPORT2/  
@@ -149,8 +151,13 @@
   5fed3813f7f5
   $ hg id http://user@localhost:$HGPORT2/ 
   5fed3813f7f5
-  $ hg id http://user:pass@localhost:$HGPORT2/
-  5fed3813f7f5
+  $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1
+  streaming all changes
+  7 files to transfer, 916 bytes of data
+  transferred * bytes in * seconds (*/sec) (glob)
+  updating to branch default
+  5 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
   $ hg id http://user2@localhost:$HGPORT2/ 
   abort: http authorization required
   [255]