Mercurial > hg-stable
comparison hgext/narrow/narrowcommands.py @ 39964: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 | a24f4638d6c1 |
children | 06e75fbf9d6b |
comparison
equal
deleted
inserted
replaced
39963:fa2395659828 | 39964:693dda764efe |
---|---|
249 repo.destroyed() | 249 repo.destroyed() |
250 | 250 |
251 def _widen(ui, repo, remote, commoninc, newincludes, newexcludes): | 251 def _widen(ui, repo, remote, commoninc, newincludes, newexcludes): |
252 newmatch = narrowspec.match(repo.root, newincludes, newexcludes) | 252 newmatch = narrowspec.match(repo.root, newincludes, newexcludes) |
253 | 253 |
254 # for now we assume that if a server has ellipses enabled, we will be | |
255 # exchanging ellipses nodes. In future we should add ellipses as a client | |
256 # side requirement (maybe) to distinguish a client is shallow or not and | |
257 # then send that information to server whether we want ellipses or not. | |
258 # Theoretically a non-ellipses repo should be able to use narrow | |
259 # functionality from an ellipses enabled server | |
260 ellipsesremote = wireprotoserver.ELLIPSESCAP in remote.capabilities() | |
261 | |
254 def pullbundle2extraprepare_widen(orig, pullop, kwargs): | 262 def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
255 orig(pullop, kwargs) | 263 orig(pullop, kwargs) |
256 # The old{in,ex}cludepats have already been set by orig() | 264 # The old{in,ex}cludepats have already been set by orig() |
257 kwargs['includepats'] = newincludes | 265 kwargs['includepats'] = newincludes |
258 kwargs['excludepats'] = newexcludes | 266 kwargs['excludepats'] = newexcludes |
267 repo.setnewnarrowpats = setnewnarrowpats | 275 repo.setnewnarrowpats = setnewnarrowpats |
268 # silence the devel-warning of applying an empty changegroup | 276 # silence the devel-warning of applying an empty changegroup |
269 overrides = {('devel', 'all-warnings'): False} | 277 overrides = {('devel', 'all-warnings'): False} |
270 | 278 |
271 with ui.uninterruptable(): | 279 with ui.uninterruptable(): |
272 ds = repo.dirstate | |
273 p1, p2 = ds.p1(), ds.p2() | |
274 with ds.parentchange(): | |
275 ds.setparents(node.nullid, node.nullid) | |
276 common = commoninc[0] | 280 common = commoninc[0] |
277 with wrappedextraprepare, repo.ui.configoverride(overrides, 'widen'): | 281 if ellipsesremote: |
278 exchange.pull(repo, remote, heads=common) | 282 ds = repo.dirstate |
279 with ds.parentchange(): | 283 p1, p2 = ds.p1(), ds.p2() |
280 ds.setparents(p1, p2) | 284 with ds.parentchange(): |
285 ds.setparents(node.nullid, node.nullid) | |
286 with wrappedextraprepare,\ | |
287 repo.ui.configoverride(overrides, 'widen'): | |
288 exchange.pull(repo, remote, heads=common) | |
289 with ds.parentchange(): | |
290 ds.setparents(p1, p2) | |
291 else: | |
292 with wrappedextraprepare,\ | |
293 repo.ui.configoverride(overrides, 'widen'): | |
294 exchange.pull(repo, remote, heads=common) | |
281 | 295 |
282 repo.setnewnarrowpats() | 296 repo.setnewnarrowpats() |
283 actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()} | 297 actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()} |
284 addgaction = actions['g'].append | 298 addgaction = actions['g'].append |
285 | 299 |