D4890: wireprotoserver: move narrow capabilities to wireprototypes.py

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Fri Oct 5 20:17:30 UTC 2018


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

REVISION SUMMARY
  This is done because wireprotoserver import wireprotov1server, so you cannot
  import wireprotoserver in wireprotov1server to use the capabilities constants.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowrepo.py
  hgext/narrow/narrowwirepeer.py
  mercurial/wireprotoserver.py
  mercurial/wireprototypes.py

CHANGE DETAILS

diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -28,6 +28,9 @@
 SSHV2 = 'exp-ssh-v2-0002'
 HTTP_WIREPROTO_V2 = 'exp-http-v2-0002'
 
+NARROWCAP = 'exp-narrow-1'
+ELLIPSESCAP = 'exp-ellipses-1'
+
 # All available wire protocol transports.
 TRANSPORTS = {
     SSHV1: {
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -38,9 +38,6 @@
 HGTYPE2 = 'application/mercurial-0.2'
 HGERRTYPE = 'application/hg-error'
 
-NARROWCAP = 'exp-narrow-1'
-ELLIPSESCAP = 'exp-ellipses-1'
-
 SSHV1 = wireprototypes.SSHV1
 SSHV2 = wireprototypes.SSHV2
 
diff --git a/hgext/narrow/narrowwirepeer.py b/hgext/narrow/narrowwirepeer.py
--- a/hgext/narrow/narrowwirepeer.py
+++ b/hgext/narrow/narrowwirepeer.py
@@ -15,7 +15,6 @@
     match as matchmod,
     narrowspec,
     pycompat,
-    wireprotoserver,
     wireprototypes,
     wireprotov1peer,
     wireprotov1server,
@@ -28,9 +27,9 @@
 def addnarrowcap(orig, repo, proto):
     """add the narrow capability to the server"""
     caps = orig(repo, proto)
-    caps.append(wireprotoserver.NARROWCAP)
+    caps.append(wireprototypes.NARROWCAP)
     if repo.ui.configbool('experimental', 'narrowservebrokenellipses'):
-        caps.append(wireprotoserver.ELLIPSESCAP)
+        caps.append(wireprototypes.ELLIPSESCAP)
     return caps
 
 def reposetup(repo):
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -8,7 +8,7 @@
 from __future__ import absolute_import
 
 from mercurial import (
-    wireprotoserver,
+    wireprototypes,
 )
 
 from . import (
@@ -26,8 +26,8 @@
 
         def peer(self):
             peer = super(narrowrepository, self).peer()
-            peer._caps.add(wireprotoserver.NARROWCAP)
-            peer._caps.add(wireprotoserver.ELLIPSESCAP)
+            peer._caps.add(wireprototypes.NARROWCAP)
+            peer._caps.add(wireprototypes.ELLIPSESCAP)
             return peer
 
     repo.__class__ = narrowrepository
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -30,7 +30,7 @@
     repoview,
     sparse,
     util,
-    wireprotoserver,
+    wireprototypes,
 )
 
 table = {}
@@ -134,7 +134,7 @@
     if repository.NARROW_REQUIREMENT not in repo.requirements:
         return orig(pullop, kwargs)
 
-    if wireprotoserver.NARROWCAP not in pullop.remote.capabilities():
+    if wireprototypes.NARROWCAP not in pullop.remote.capabilities():
         raise error.Abort(_("server does not support narrow clones"))
     orig(pullop, kwargs)
     kwargs['narrow'] = True
@@ -145,7 +145,7 @@
     kwargs['excludepats'] = exclude
     # calculate known nodes only in ellipses cases because in non-ellipses cases
     # we have all the nodes
-    if wireprotoserver.ELLIPSESCAP in pullop.remote.capabilities():
+    if wireprototypes.ELLIPSESCAP in pullop.remote.capabilities():
         kwargs['known'] = [node.hex(ctx.node()) for ctx in
                            repo.set('::%ln', pullop.common)
                            if ctx.node() != node.nullid]
@@ -259,7 +259,7 @@
     # then send that information to server whether we want ellipses or not.
     # Theoretically a non-ellipses repo should be able to use narrow
     # functionality from an ellipses enabled server
-    ellipsesremote = wireprotoserver.ELLIPSESCAP in remote.capabilities()
+    ellipsesremote = wireprototypes.ELLIPSESCAP in remote.capabilities()
 
     def pullbundle2extraprepare_widen(orig, pullop, kwargs):
         orig(pullop, kwargs)
@@ -427,7 +427,7 @@
         # check narrow support before doing anything if widening needs to be
         # performed. In future we should also abort if client is ellipses and
         # server does not support ellipses
-        if widening and wireprotoserver.NARROWCAP not in remote.capabilities():
+        if widening and wireprototypes.NARROWCAP not in remote.capabilities():
             raise error.Abort(_("server does not support narrow clones"))
 
         commoninc = discovery.findcommonincoming(repo, remote)



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


More information about the Mercurial-devel mailing list