D4808: narrow: move the wireprotocol narrow capability name to core

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sun Sep 30 12:10:38 EDT 2018


pulkit updated this revision to Diff 11499.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4808?vs=11491&id=11499

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

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

CHANGE DETAILS

diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -38,6 +38,8 @@
 HGTYPE2 = 'application/mercurial-0.2'
 HGERRTYPE = 'application/hg-error'
 
+NARROWCAP = 'exp-narrow-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
@@ -10,19 +10,19 @@
 from mercurial import (
     extensions,
     hg,
+    wireprotoserver,
     wireprotov1server,
 )
 
-NARROWCAP = 'exp-narrow-1'
 ELLIPSESCAP = 'exp-ellipses-1'
 
 def uisetup():
     extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap)
 
 def addnarrowcap(orig, repo, proto):
     """add the narrow capability to the server"""
     caps = orig(repo, proto)
-    caps.append(NARROWCAP)
+    caps.append(wireprotoserver.NARROWCAP)
     if repo.ui.configbool('experimental', 'narrowservebrokenellipses'):
         caps.append(ELLIPSESCAP)
     return caps
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -7,6 +7,10 @@
 
 from __future__ import absolute_import
 
+from mercurial import (
+    wireprotoserver,
+)
+
 from . import (
     narrowdirstate,
     narrowwirepeer,
@@ -23,7 +27,7 @@
 
         def peer(self):
             peer = super(narrowrepository, self).peer()
-            peer._caps.add(narrowwirepeer.NARROWCAP)
+            peer._caps.add(wireprotoserver.NARROWCAP)
             peer._caps.add(narrowwirepeer.ELLIPSESCAP)
             return peer
 
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -29,6 +29,7 @@
     repoview,
     sparse,
     util,
+    wireprotoserver,
 )
 
 from . import (
@@ -136,7 +137,7 @@
     if repository.NARROW_REQUIREMENT not in repo.requirements:
         return orig(pullop, kwargs)
 
-    if narrowwirepeer.NARROWCAP not in pullop.remote.capabilities():
+    if wireprotoserver.NARROWCAP not in pullop.remote.capabilities():
         raise error.Abort(_("server doesn't support narrow clones"))
     orig(pullop, kwargs)
     kwargs['narrow'] = True



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


More information about the Mercurial-devel mailing list