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

REVISION SUMMARY
  This will be used in core logic to determining whether a server is ellipses
  enabled or not. And also this will ease moving narrow related things to core.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowrepo.py
  hgext/narrow/narrowwirepeer.py
  mercurial/hg.py
  mercurial/localrepo.py
  mercurial/wireprotoserver.py
  tests/test-narrow-clone.t

CHANGE DETAILS

diff --git a/tests/test-narrow-clone.t b/tests/test-narrow-clone.t
--- a/tests/test-narrow-clone.t
+++ b/tests/test-narrow-clone.t
@@ -40,11 +40,12 @@
   $ cd narrow
   $ cat .hg/requires | grep -v generaldelta
   dotencode
+  exp-ellipses
   fncache
   narrowhg-experimental
   revlogv1
+  testonly-simplestore (reposimplestore !)
   store
-  testonly-simplestore (reposimplestore !)
 
   $ hg tracked
   I path:dir/src/f10
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -39,6 +39,7 @@
 HGERRTYPE = 'application/hg-error'
 
 NARROWCAP = 'exp-narrow-1'
+ELLIPSESCAP = 'exp-ellipses-1'
 
 SSHV1 = wireprototypes.SSHV1
 SSHV2 = wireprototypes.SSHV2
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2807,6 +2807,9 @@
     if createopts.get('narrowfiles'):
         requirements.add(repository.NARROW_REQUIREMENT)
 
+    if createopts.get('ellipses'):
+        requirements.add(repository.ELLIPSES_REQUIREMENT)
+
     return requirements
 
 def filterknowncreateopts(ui, createopts):
@@ -2824,6 +2827,7 @@
     they know how to handle.
     """
     known = {
+        'ellipses',
         'narrowfiles',
         'sharedrepo',
         'sharedrelative',
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -47,6 +47,7 @@
     util,
     verify as verifymod,
     vfs as vfsmod,
+    wireprotoserver,
 )
 
 release = lock.release
@@ -578,6 +579,9 @@
 
         createopts['narrowfiles'] = True
 
+        if srcpeer.capable(wireprotoserver.ELLIPSESCAP):
+            createopts['ellipses'] = True
+
     shareopts = shareopts or {}
     sharepool = shareopts.get('pool')
     sharenamemode = shareopts.get('mode')
diff --git a/hgext/narrow/narrowwirepeer.py b/hgext/narrow/narrowwirepeer.py
--- a/hgext/narrow/narrowwirepeer.py
+++ b/hgext/narrow/narrowwirepeer.py
@@ -14,17 +14,15 @@
     wireprotov1server,
 )
 
-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(wireprotoserver.NARROWCAP)
     if repo.ui.configbool('experimental', 'narrowservebrokenellipses'):
-        caps.append(ELLIPSESCAP)
+        caps.append(wireprotoserver.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
@@ -13,7 +13,6 @@
 
 from . import (
     narrowdirstate,
-    narrowwirepeer,
 )
 
 def wraprepo(repo):
@@ -28,7 +27,7 @@
         def peer(self):
             peer = super(narrowrepository, self).peer()
             peer._caps.add(wireprotoserver.NARROWCAP)
-            peer._caps.add(narrowwirepeer.ELLIPSESCAP)
+            peer._caps.add(wireprotoserver.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
@@ -32,10 +32,6 @@
     wireprotoserver,
 )
 
-from . import (
-    narrowwirepeer,
-)
-
 table = {}
 command = registrar.command(table)
 
@@ -148,7 +144,7 @@
     kwargs['excludepats'] = exclude
     # calculate known nodes only in ellipses cases because in non-ellipses 
cases
     # we have all the nodes
-    if narrowwirepeer.ELLIPSESCAP in pullop.remote.capabilities():
+    if wireprotoserver.ELLIPSESCAP in pullop.remote.capabilities():
         kwargs['known'] = [node.hex(ctx.node()) for ctx in
                            repo.set('::%ln', pullop.common)
                            if ctx.node() != node.nullid]
diff --git a/hgext/narrow/__init__.py b/hgext/narrow/__init__.py
--- a/hgext/narrow/__init__.py
+++ b/hgext/narrow/__init__.py
@@ -53,6 +53,7 @@
 
 def featuresetup(ui, features):
     features.add(repository.NARROW_REQUIREMENT)
+    features.add(repository.ELLIPSES_REQUIREMENT)
 
 def uisetup(ui):
     """Wraps user-facing mercurial commands with narrow-aware versions."""



To: pulkit, durin42, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to