D4788: narrow: don't do the dirstate dance if ellipses is not enabled
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Fri Sep 28 20:58:42 UTC 2018
pulkit created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4788
AFFECTED FILES
hgext/narrow/narrowcommands.py
tests/test-narrow-widen-no-ellipsis.t
CHANGE DETAILS
diff --git a/tests/test-narrow-widen-no-ellipsis.t b/tests/test-narrow-widen-no-ellipsis.t
--- a/tests/test-narrow-widen-no-ellipsis.t
+++ b/tests/test-narrow-widen-no-ellipsis.t
@@ -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 at 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
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -254,6 +254,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 = narrowwirepeer.ELLIPSESCAP in remote.capabilities()
+
def pullbundle2extraprepare_widen(orig, pullop, kwargs):
orig(pullop, kwargs)
# The old{in,ex}cludepats have already been set by orig()
@@ -272,15 +280,17 @@
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)
+ if ellipsesremote:
+ 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:
+ with ds.parentchange():
+ ds.setparents(p1, p2)
repo.setnewnarrowpats()
actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()}
To: pulkit, durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list