D5126: remotefilelog: rename capability for legacy ssh file fetching method

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


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

REVISION SUMMARY
  I think I want to delete this, but for now we'll just rename this so
  it's easy to tell apart from other strings that have the same value.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/__init__.py
  hgext/remotefilelog/constants.py
  hgext/remotefilelog/fileserverclient.py
  hgext/remotefilelog/remotefilelogserver.py
  tests/test-remotefilelog-pull-noshallow.t
  tests/test-remotefilelog-push-pull.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-push-pull.t b/tests/test-remotefilelog-push-pull.t
--- a/tests/test-remotefilelog-push-pull.t
+++ b/tests/test-remotefilelog-push-pull.t
@@ -23,13 +23,13 @@
 
   $ cd master
   $ echo 'hello' | hg -R . serve --stdio | grep capa | identifyrflcaps
+  exp-remotefilelog-ssh-getfiles-1
   getfile
   getflogheads
-  remotefilelog
   $ echo 'capabilities' | hg -R . serve --stdio | identifyrflcaps ; echo
+  exp-remotefilelog-ssh-getfiles-1
   getfile
   getflogheads
-  remotefilelog
   
 # pull to shallow from full
 
diff --git a/tests/test-remotefilelog-pull-noshallow.t b/tests/test-remotefilelog-pull-noshallow.t
--- a/tests/test-remotefilelog-pull-noshallow.t
+++ b/tests/test-remotefilelog-pull-noshallow.t
@@ -36,13 +36,13 @@
 
   $ cd master
   $ echo 'hello' | hg -R . serve --stdio | grep capa | identifyrflcaps
+  exp-remotefilelog-ssh-getfiles-1
   getfile
   getflogheads
-  remotefilelog
   $ echo 'capabilities' | hg -R . serve --stdio | identifyrflcaps ; echo
+  exp-remotefilelog-ssh-getfiles-1
   getfile
   getflogheads
-  remotefilelog
   
 
 Pull to the child repository.  Use our custom setupremotefilelog extension
diff --git a/hgext/remotefilelog/remotefilelogserver.py b/hgext/remotefilelog/remotefilelogserver.py
--- a/hgext/remotefilelog/remotefilelogserver.py
+++ b/hgext/remotefilelog/remotefilelogserver.py
@@ -29,6 +29,7 @@
     wireprotov1server,
 )
 from .  import (
+    constants,
     shallowrepo,
     shallowutil,
 )
@@ -197,7 +198,7 @@
             ui.configbool('remotefilelog', 'server'))):
             if isinstance(proto, _sshv1server):
                 # legacy getfiles method which only works over ssh
-                caps.append(shallowrepo.requirement)
+                caps.append(constants.NETWORK_CAP_LEGACY_SSH_GETFILES)
             caps.append('getflogheads')
             caps.append('getfile')
         return caps
diff --git a/hgext/remotefilelog/fileserverclient.py b/hgext/remotefilelog/fileserverclient.py
--- a/hgext/remotefilelog/fileserverclient.py
+++ b/hgext/remotefilelog/fileserverclient.py
@@ -78,7 +78,8 @@
         def _updatecallstreamopts(self, command, opts):
             if command != 'getbundle':
                 return
-            if 'remotefilelog' not in self.capabilities():
+            if (constants.NETWORK_CAP_LEGACY_SSH_GETFILES
+                not in self.capabilities()):
                 return
             if not util.safehasattr(self, '_localrepo'):
                 return
@@ -377,9 +378,8 @@
                 try:
                     with self._connect() as conn:
                         remote = conn.peer
-                        # TODO: deduplicate this with the constant in
-                        #       shallowrepo
-                        if remote.capable("remotefilelog"):
+                        if remote.capable(
+                                constants.NETWORK_CAP_LEGACY_SSH_GETFILES):
                             if not isinstance(remote, _sshv1peer):
                                 raise error.Abort('remotefilelog requires ssh '
                                                   'servers')
diff --git a/hgext/remotefilelog/constants.py b/hgext/remotefilelog/constants.py
--- a/hgext/remotefilelog/constants.py
+++ b/hgext/remotefilelog/constants.py
@@ -6,6 +6,8 @@
 
 REQUIREMENT = "remotefilelog"
 
+NETWORK_CAP_LEGACY_SSH_GETFILES = 'exp-remotefilelog-ssh-getfiles-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
@@ -114,6 +114,7 @@
     util,
 )
 from . import (
+    constants,
     debugcommands,
     fileserverclient,
     remotefilectx,
@@ -282,7 +283,7 @@
             # patterns.
             def stream_out_shallow(orig):
                 caps = remote.capabilities()
-                if shallowrepo.requirement in caps:
+                if constants.NETWORK_CAP_LEGACY_SSH_GETFILES in caps:
                     opts = {}
                     if repo.includepattern:
                         opts['includepattern'] = '\0'.join(repo.includepattern)



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


More information about the Mercurial-devel mailing list