D5127: remotefilelog: consolidate and rename bundle2 capability

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Tue Oct 16 21:45:49 UTC 2018


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Bonus: we catch a spot where the shallowrepo requirement was being
  misused as the bundle2 capability.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5127

AFFECTED FILES
  hgext/remotefilelog/__init__.py
  hgext/remotefilelog/constants.py
  hgext/remotefilelog/fileserverclient.py
  hgext/remotefilelog/remotefilelogserver.py
  hgext/remotefilelog/shallowbundle.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/shallowbundle.py b/hgext/remotefilelog/shallowbundle.py
--- a/hgext/remotefilelog/shallowbundle.py
+++ b/hgext/remotefilelog/shallowbundle.py
@@ -17,6 +17,7 @@
     pycompat,
 )
 from . import (
+    constants,
     remotefilelog,
     shallowutil,
 )
@@ -100,7 +101,7 @@
 
         caps = self._bundlecaps or []
         if source == "serve" or source == "pull":
-            if 'remotefilelog' in caps:
+            if constants.BUNDLE2_CAPABLITY in caps:
                 return LocalFiles
             else:
                 # Serving to a full repo requires us to serve everything
diff --git a/hgext/remotefilelog/remotefilelogserver.py b/hgext/remotefilelog/remotefilelogserver.py
--- a/hgext/remotefilelog/remotefilelogserver.py
+++ b/hgext/remotefilelog/remotefilelogserver.py
@@ -45,7 +45,7 @@
     def generatefiles(orig, self, changedfiles, linknodes, commonrevs, source,
                       *args, **kwargs):
         caps = self._bundlecaps or []
-        if shallowrepo.requirement in caps:
+        if constants.BUNDLE2_CAPABLITY in caps:
             # only send files that don't match the specified patterns
             includepattern = None
             excludepattern = None
@@ -184,7 +184,7 @@
     def getbundleshallow(repo, proto, others):
         bundlecaps = others.get('bundlecaps', '')
         bundlecaps = set(bundlecaps.split(','))
-        bundlecaps.add('remotefilelog')
+        bundlecaps.add(constants.BUNDLE2_CAPABLITY)
         others['bundlecaps'] = ','.join(bundlecaps)
 
         return wireprotov1server.commands["getbundle"][0](repo, proto, others)
diff --git a/hgext/remotefilelog/fileserverclient.py b/hgext/remotefilelog/fileserverclient.py
--- a/hgext/remotefilelog/fileserverclient.py
+++ b/hgext/remotefilelog/fileserverclient.py
@@ -99,7 +99,7 @@
             # getbundle args before it goes across the wire. Once we get rid
             # of bundle1, we can use bundle2's _pullbundle2extraprepare to
             # do this more cleanly.
-            bundlecaps.append('remotefilelog')
+            bundlecaps.append(constants.BUNDLE2_CAPABLITY)
             if self._localrepo.includepattern:
                 patterns = '\0'.join(self._localrepo.includepattern)
                 includecap = "includepattern=" + patterns
diff --git a/hgext/remotefilelog/constants.py b/hgext/remotefilelog/constants.py
--- a/hgext/remotefilelog/constants.py
+++ b/hgext/remotefilelog/constants.py
@@ -8,6 +8,8 @@
 
 NETWORK_CAP_LEGACY_SSH_GETFILES = 'exp-remotefilelog-ssh-getfiles-1'
 
+BUNDLE2_CAPABLITY = "exp-remotefilelog-b2cap-1"
+
 FILENAMESTRUCT = '!H'
 FILENAMESIZE = struct.calcsize(FILENAMESTRUCT)
 
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -962,7 +962,7 @@
                        **kwargs):
         if not bundlecaps:
             bundlecaps = set()
-        bundlecaps.add('remotefilelog')
+        bundlecaps.add(constants.BUNDLE2_CAPABLITY)
         return orig(source, heads=heads, common=common, bundlecaps=bundlecaps,
                     **kwargs)
 



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list