changeset 39963:693dda764efe

narrow: don't do the dirstate dance if ellipses is not enabled I believe we set dirstate parents to nullid before widening pull because in ellipses cases, the parent might be stripped off with a new changeset. However the second ds.setparents() call invalidate my assumption. I am not sure why we do this. So here is a patch. This patch also adds tests showing we break nothing in non-ellipses cases. Differential Revision: https://phab.mercurial-scm.org/D4788
author Pulkit Goyal <pulkit@yandex-team.ru>
date Sun, 30 Sep 2018 18:59:27 +0300
parents fa2395659828
children 06e75fbf9d6b
files hgext/narrow/narrowcommands.py tests/test-narrow-widen-no-ellipsis.t
diffstat 2 files changed, 28 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/narrow/narrowcommands.py	Fri Sep 28 19:21:24 2018 +0300
+++ b/hgext/narrow/narrowcommands.py	Sun Sep 30 18:59:27 2018 +0300
@@ -251,6 +251,14 @@
 def _widen(ui, repo, remote, commoninc, newincludes, newexcludes):
     newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
 
+    # for now we assume that if a server has ellipses enabled, we will be
+    # exchanging ellipses nodes. In future we should add ellipses as a client
+    # side requirement (maybe) to distinguish a client is shallow or not and
+    # 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()
+
     def pullbundle2extraprepare_widen(orig, pullop, kwargs):
         orig(pullop, kwargs)
         # The old{in,ex}cludepats have already been set by orig()
@@ -269,15 +277,21 @@
     overrides = {('devel', 'all-warnings'): False}
 
     with ui.uninterruptable():
-        ds = repo.dirstate
-        p1, p2 = ds.p1(), ds.p2()
-        with ds.parentchange():
-            ds.setparents(node.nullid, node.nullid)
         common = commoninc[0]
-        with wrappedextraprepare, repo.ui.configoverride(overrides, 'widen'):
-            exchange.pull(repo, remote, heads=common)
-        with ds.parentchange():
-            ds.setparents(p1, p2)
+        if ellipsesremote:
+            ds = repo.dirstate
+            p1, p2 = ds.p1(), ds.p2()
+            with ds.parentchange():
+                ds.setparents(node.nullid, node.nullid)
+            with wrappedextraprepare,\
+                 repo.ui.configoverride(overrides, 'widen'):
+                exchange.pull(repo, remote, heads=common)
+            with ds.parentchange():
+                ds.setparents(p1, p2)
+        else:
+            with wrappedextraprepare,\
+                 repo.ui.configoverride(overrides, 'widen'):
+                exchange.pull(repo, remote, heads=common)
 
         repo.setnewnarrowpats()
         actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()}
--- a/tests/test-narrow-widen-no-ellipsis.t	Fri Sep 28 19:21:24 2018 +0300
+++ b/tests/test-narrow-widen-no-ellipsis.t	Sun Sep 30 18:59:27 2018 +0300
@@ -88,6 +88,9 @@
 added upstream revisions.
 
   $ cd narrow
+  $ hg id -n
+  2
+
   $ hg tracked --addinclude widest/f --debug
   comparing with ssh://user@dummy/master
   running python "*dummyssh" *user@dummy* *hg -R master serve --stdio* (glob)
@@ -127,6 +130,9 @@
   $ cat widest/f
   widest
 
+  $ hg id -n
+  2
+
 Pull down the newly added upstream revision.
 
   $ hg pull