hgext/narrow/narrowcommands.py
changeset 42415 c767e655ffda
parent 42345 7d4ee14ff92d
child 42416 8381b7067f17
--- a/hgext/narrow/narrowcommands.py	Tue Jun 04 17:24:35 2019 +0800
+++ b/hgext/narrow/narrowcommands.py	Wed May 22 02:59:48 2019 +0530
@@ -146,7 +146,7 @@
         kwargs['excludepats'] = exclude
     # calculate known nodes only in ellipses cases because in non-ellipses cases
     # we have all the nodes
-    if wireprototypes.ELLIPSESCAP in pullop.remote.capabilities():
+    if wireprototypes.ELLIPSESCAP1 in pullop.remote.capabilities():
         kwargs['known'] = [node.hex(ctx.node()) for ctx in
                            repo.set('::%ln', pullop.common)
                            if ctx.node() != node.nullid]
@@ -253,7 +253,14 @@
     # 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 = wireprototypes.ELLIPSESCAP in remote.capabilities()
+    remotecap = remote.capabilities()
+    ellipsesremote = any(cap in remotecap
+                         for cap in wireprototypes.SUPPORTED_ELLIPSESCAP)
+
+    # check whether we are talking to a server which supports old version of
+    # ellipses capabilities
+    isoldellipses = (ellipsesremote and wireprototypes.ELLIPSESCAP1 in
+                     remotecap and wireprototypes.ELLIPSESCAP not in remotecap)
 
     def pullbundle2extraprepare_widen(orig, pullop, kwargs):
         orig(pullop, kwargs)
@@ -279,8 +286,31 @@
             with ds.parentchange():
                 ds.setparents(node.nullid, node.nullid)
             with wrappedextraprepare:
-                with repo.ui.configoverride(overrides, 'widen'):
+                if isoldellipses:
                     exchange.pull(repo, remote, heads=common)
+                else:
+                    known = [node.hex(ctx.node()) for ctx in
+                                       repo.set('::%ln', common)
+                                       if ctx.node() != node.nullid]
+
+                    with remote.commandexecutor() as e:
+                        bundle = e.callcommand('narrow_widen', {
+                            'oldincludes': oldincludes,
+                            'oldexcludes': oldexcludes,
+                            'newincludes': newincludes,
+                            'newexcludes': newexcludes,
+                            'cgversion': '03',
+                            'commonheads': common,
+                            'known': known,
+                            'ellipses': True,
+                        }).result()
+                    trmanager = exchange.transactionmanager(repo, 'widen',
+                                                            remote.url())
+                    with trmanager:
+                        op = bundle2.bundleoperation(repo,
+                                trmanager.transaction, source='widen')
+                        bundle2.processbundle(repo, bundle, op=op)
+
             with ds.parentchange():
                 ds.setparents(p1, p2)
         else: