Patchwork [2,of,2] localrepo.clone: add a way to override server preferuncompressed

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 12, 2014, 10:27 p.m.
Message ID <ee4ebec13928c6ea98d0.1418423223@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/7065/
State Accepted
Headers show

Comments

Siddharth Agarwal - Dec. 12, 2014, 10:27 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1418421996 28800
#      Fri Dec 12 14:06:36 2014 -0800
# Node ID ee4ebec13928c6ea98d0bd27fdc3b9f1507ba284
# Parent  7fe7768d79b0021324ac19d4d0a161d709b93ade
localrepo.clone: add a way to override server preferuncompressed

Without this patch, if the server sets preferuncompressed, there's no way for
clients to override that and force a non-streaming clone. With this patch, we
extend the meaning of --pull to also override preferuncompressed and force a
non-streaming clone.
Pierre-Yves David - Dec. 13, 2014, 8:48 p.m.
On 12/12/2014 02:27 PM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1418421996 28800
> #      Fri Dec 12 14:06:36 2014 -0800
> # Node ID ee4ebec13928c6ea98d0bd27fdc3b9f1507ba284
> # Parent  7fe7768d79b0021324ac19d4d0a161d709b93ade
> localrepo.clone: add a way to override server preferuncompressed
>
> Without this patch, if the server sets preferuncompressed, there's no way for
> clients to override that and force a non-streaming clone. With this patch, we
> extend the meaning of --pull to also override preferuncompressed and force a
> non-streaming clone.

This reasonable and usefull,

Pushed to the clowncopter, thanks.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1726,7 +1726,7 @@ 
         finally:
             lock.release()
 
-    def clone(self, remote, heads=[], stream=False):
+    def clone(self, remote, heads=[], stream=None):
         '''clone remote repository.
 
         keyword arguments:
@@ -1741,7 +1741,7 @@ 
         # and format flags on "stream" capability, and use
         # uncompressed only if compatible.
 
-        if not stream:
+        if stream is None:
             # if the server explicitly prefers to stream (for fast LANs)
             stream = remote.capable('stream-preferred')
 
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -201,6 +201,15 @@ 
   no changes found
   updating to branch default
   5 files updated, 0 files merged, 0 files removed, 0 files unresolved
+--pull should override server's preferuncompressed
+  $ hg clone --pull http://user:pass@localhost:$HGPORT2/ dest-pull 2>&1
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 5 changes to 5 files
+  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 for http://localhost:$HGPORT2/
@@ -259,6 +268,12 @@ 
   "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D5fed3813f7f5e1824344fdc9cf8f63bb662c292d
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
   "GET /?cmd=capabilities HTTP/1.1" 200 -
+  "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks
+  "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
+  "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D
+  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d
+  "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
+  "GET /?cmd=capabilities HTTP/1.1" 200 -
   "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
   "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
   "GET /?cmd=capabilities HTTP/1.1" 200 -