wireprotoserver: move narrow capabilities to wireprototypes.py
authorPulkit Goyal <pulkit@yandex-team.ru>
Fri, 05 Oct 2018 22:31:12 +0300
changeset 40074 f7011b44d205
parent 40073 e92454e69dc3
child 40075 ad8d8dc9be3f
wireprotoserver: move narrow capabilities to wireprototypes.py This is done because wireprotoserver import wireprotov1server, so you cannot import wireprotoserver in wireprotov1server to use the capabilities constants. Differential Revision: https://phab.mercurial-scm.org/D4890
hgext/narrow/narrowcommands.py
hgext/narrow/narrowrepo.py
hgext/narrow/narrowwirepeer.py
mercurial/wireprotoserver.py
mercurial/wireprototypes.py
--- a/hgext/narrow/narrowcommands.py	Fri Oct 05 22:19:19 2018 +0300
+++ b/hgext/narrow/narrowcommands.py	Fri Oct 05 22:31:12 2018 +0300
@@ -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)
--- a/hgext/narrow/narrowrepo.py	Fri Oct 05 22:19:19 2018 +0300
+++ b/hgext/narrow/narrowrepo.py	Fri Oct 05 22:31:12 2018 +0300
@@ -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
--- a/hgext/narrow/narrowwirepeer.py	Fri Oct 05 22:19:19 2018 +0300
+++ b/hgext/narrow/narrowwirepeer.py	Fri Oct 05 22:31:12 2018 +0300
@@ -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):
--- a/mercurial/wireprotoserver.py	Fri Oct 05 22:19:19 2018 +0300
+++ b/mercurial/wireprotoserver.py	Fri Oct 05 22:31:12 2018 +0300
@@ -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
 
--- a/mercurial/wireprototypes.py	Fri Oct 05 22:19:19 2018 +0300
+++ b/mercurial/wireprototypes.py	Fri Oct 05 22:31:12 2018 +0300
@@ -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: {