changeset 32259:076f1ff43f0f

clone: warn when streaming was requested but couldn't be performed This helps both users and the people who support them figure out why a stream clone couldn't be performed. In an upcoming patch we're going to add a way for servers to hard abort on a full getbundle. In those cases servers might expect clients to perform a stream clone, so it's important to communicate why one couldn't be done.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 08 May 2017 20:01:06 -0700
parents 9c60d93fd3ab
children d0d9a4fca59b
files mercurial/streamclone.py tests/test-http-bundle1.t tests/test-http.t
diffstat 3 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/streamclone.py	Mon May 08 18:47:24 2017 -0700
+++ b/mercurial/streamclone.py	Mon May 08 20:01:06 2017 -0700
@@ -80,11 +80,21 @@
         streamreqs = remote.capable('streamreqs')
         # This is weird and shouldn't happen with modern servers.
         if not streamreqs:
+            pullop.repo.ui.warn(_(
+                'warning: stream clone requested but server has them '
+                'disabled\n'))
             return False, None
 
         streamreqs = set(streamreqs.split(','))
         # Server requires something we don't support. Bail.
-        if streamreqs - repo.supportedformats:
+        missingreqs = streamreqs - repo.supportedformats
+        if missingreqs:
+            pullop.repo.ui.warn(_(
+                'warning: stream clone requested but client is missing '
+                'requirements: %s\n') % ', '.join(sorted(missingreqs)))
+            pullop.repo.ui.warn(
+                _('(see https://www.mercurial-scm.org/wiki/MissingRequirement '
+                  'for more information)\n'))
             return False, None
         requirements = streamreqs
 
--- a/tests/test-http-bundle1.t	Mon May 08 18:47:24 2017 -0700
+++ b/tests/test-http-bundle1.t	Mon May 08 20:01:06 2017 -0700
@@ -58,6 +58,7 @@
 try to clone via stream, should use pull instead
 
   $ hg clone --uncompressed http://localhost:$HGPORT1/ copy2
+  warning: stream clone requested but server has them disabled
   requesting all changes
   adding changesets
   adding manifests
@@ -75,6 +76,8 @@
   > EOF
 
   $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --uncompressed http://localhost:$HGPORT/ copy3
+  warning: stream clone requested but client is missing requirements: generaldelta
+  (see https://www.mercurial-scm.org/wiki/MissingRequirement for more information)
   requesting all changes
   adding changesets
   adding manifests
--- a/tests/test-http.t	Mon May 08 18:47:24 2017 -0700
+++ b/tests/test-http.t	Mon May 08 20:01:06 2017 -0700
@@ -49,6 +49,7 @@
 try to clone via stream, should use pull instead
 
   $ hg clone --uncompressed http://localhost:$HGPORT1/ copy2
+  warning: stream clone requested but server has them disabled
   requesting all changes
   adding changesets
   adding manifests
@@ -66,6 +67,8 @@
   > EOF
 
   $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --uncompressed http://localhost:$HGPORT/ copy3
+  warning: stream clone requested but client is missing requirements: generaldelta
+  (see https://www.mercurial-scm.org/wiki/MissingRequirement for more information)
   requesting all changes
   adding changesets
   adding manifests