changeset 35505:2526579a30e0

lfs: allow non-lfs exchanges when the extension is only enabled on one side Once the 'lfs' requirement is added, the extension must be loaded on both sides, and changegroup3 used. But there's no reason that I can see for bailing with cryptic errors if lfs is not required, but randomly enabled somewhere.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 24 Dec 2017 01:26:36 -0500
parents 6bb940de4c4c
children fa865878a849
files hgext/lfs/wrapper.py tests/test-lfs-serve.t
diffstat 2 files changed, 12 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/lfs/wrapper.py	Sat Dec 23 23:51:40 2017 -0500
+++ b/hgext/lfs/wrapper.py	Sun Dec 24 01:26:36 2017 -0500
@@ -28,8 +28,9 @@
 
 def supportedoutgoingversions(orig, repo):
     versions = orig(repo)
-    versions.discard('01')
-    versions.discard('02')
+    if 'lfs' in repo.requirements:
+        versions.discard('01')
+        versions.discard('02')
     versions.add('03')
     return versions
 
--- a/tests/test-lfs-serve.t	Sat Dec 23 23:51:40 2017 -0500
+++ b/tests/test-lfs-serve.t	Sun Dec 24 01:26:36 2017 -0500
@@ -70,21 +70,12 @@
   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   [1]
 
-TODO: fail more gracefully, or don't mandate changegroup3 for non-lfs repos.
-
   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client1_clone
-  abort: HTTP Error 500: Internal Server Error
-  [255]
   $ grep 'lfs' $TESTTMP/client1_clone/.hg/requires $SERVER_REQUIRES
-  grep: $TESTTMP/client1_clone/.hg/requires: $ENOENT$
-  [2]
-
-TODO: fail more gracefully, or don't mandate changegroup3 for non-lfs repos.
+  [1]
 
   $ hg init $TESTTMP/client1_pull
   $ hg -R $TESTTMP/client1_pull pull -q http://localhost:$HGPORT
-  abort: HTTP Error 500: Internal Server Error
-  [255]
   $ grep 'lfs' $TESTTMP/client1_pull/.hg/requires $SERVER_REQUIRES
   [1]
 
@@ -104,10 +95,10 @@
   $ echo 'non-lfs' > nonlfs2.txt
   $ hg ci -Aqm 'non-lfs file with lfs client'
 
-TODO: fail more gracefully here
-  $ hg push -q 2>&1 | grep '^[A-Z]' || true
-  Traceback (most recent call last): (lfsremote-off !)
-  ValueError: no common changegroup version (lfsremote-off !)
+Since no lfs content has been added yet, the push is allowed, even when the
+extension is not enabled remotely.
+
+  $ hg push -q
   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   [1]
 
@@ -120,13 +111,8 @@
   $ grep 'lfs' $TESTTMP/client2_pull/.hg/requires $SERVER_REQUIRES
   [1]
 
-XXX: The difference here is the push failed above when the extension isn't
-enabled on the server.  The extension shouldn't need to mess with changegroup
-versions if there is no lfs content.  But the requirement needs to be
-consistently added before that can be ratcheted back.
   $ hg identify http://localhost:$HGPORT
-  1477875038c6 (lfsremote-on !)
-  000000000000 (lfsremote-off !)
+  1477875038c6
 
 --------------------------------------------------------------------------------
 Case #3: client with lfs content and the extension enabled; server with
@@ -157,13 +143,11 @@
   $TESTTMP/client3_pull/.hg/requires:lfs (lfsremote-on !)
   $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
 
-XXX: The difference here is the push failed above when the extension isn't
-enabled on the server.  The extension shouldn't need to mess with changegroup
-versions if there is no lfs content.  But the requirement needs to be
-consistently added before that can be ratcheted back.
+The difference here is the push failed above when the extension isn't
+enabled on the server.
   $ hg identify http://localhost:$HGPORT
   8374dc4052cb (lfsremote-on !)
-  000000000000 (lfsremote-off !)
+  1477875038c6 (lfsremote-off !)
 
 Don't bother testing the lfsremote-off cases- the server won't be able
 to launch if there's lfs content and the extension is disabled.
@@ -290,10 +274,6 @@
   ValueError: no common changegroup version
   Traceback (most recent call last):
   ValueError: no common changegroup version
-  Traceback (most recent call last):
-  ValueError: no common changegroup version
-  Traceback (most recent call last):
-  ValueError: no common changegroup version
 #else
   $ cat $TESTTMP/errors.log
 #endif