diff hgext/narrow/narrowcommands.py @ 40070:8feae5b989bc

narrow: the first version of narrow_widen wireprotocol command This patch introduces a wireprotocol command narrow_widen() which will be used to widen a narrow copy using `hg tracked` command provided by narrow extension. The wireprotocol command takes the old and new includes and excludes, common heads, changegroup version, known revs, and a boolean ellipses and generates a bundle2 of the required data and send it. The clients receives the bundle2 and applies that. A bundle2 instead of changegroup because in future we might want to add more things to send while widening. Thanks for martinvonz for the suggestion. I am not sure whether we need changegroup version as an argument to the command as I *think* narrow needs changegroup3 already. The tests shows that we don't exchange phase data now while widening which is nice. Also we don't check for pushkeys, rbc-cache, bookmarks etc. This does not support ellipses cases for now but will be supported in future patches. Since we send bundle2, it won't be hard to plug the ellipses logic in here. The existing code for widening a non-ellipses case is also dropped in this patch. Differential Revision: https://phab.mercurial-scm.org/D4813
author Pulkit Goyal <pulkit@yandex-team.ru>
date Fri, 28 Sep 2018 23:42:31 +0300
parents 1a4c1a3cc3f5
children f7011b44d205
line wrap: on
line diff
--- a/hgext/narrow/narrowcommands.py	Fri Oct 05 21:43:57 2018 +0900
+++ b/hgext/narrow/narrowcommands.py	Fri Sep 28 23:42:31 2018 +0300
@@ -11,6 +11,7 @@
 
 from mercurial.i18n import _
 from mercurial import (
+    bundle2,
     cmdutil,
     commands,
     discovery,
@@ -265,7 +266,6 @@
         # The old{in,ex}cludepats have already been set by orig()
         kwargs['includepats'] = newincludes
         kwargs['excludepats'] = newexcludes
-        kwargs['widen'] = True
     wrappedextraprepare = extensions.wrappedfunction(exchange,
         '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
 
@@ -290,9 +290,23 @@
             with ds.parentchange():
                 ds.setparents(p1, p2)
         else:
-            with wrappedextraprepare,\
+            with remote.commandexecutor() as e:
+                bundle = e.callcommand('narrow_widen', {
+                    'oldincludes': oldincludes,
+                    'oldexcludes': oldexcludes,
+                    'newincludes': newincludes,
+                    'newexcludes': newexcludes,
+                    'cgversion': '03',
+                    'commonheads': common,
+                    'known': [],
+                    'ellipses': False,
+                }).result()
+
+            with repo.transaction('widening') as tr,\
                  repo.ui.configoverride(overrides, 'widen'):
-                exchange.pull(repo, remote, heads=common)
+                tgetter = lambda: tr
+                bundle2.processbundle(repo, bundle,
+                        transactiongetter=tgetter)
 
         repo.setnewnarrowpats()
         actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()}