rebase: scope parent change into a changing_parents context
If we are actually altering the working copy (i.e. we are not in memory), we
should properly scope the working copy update.
--- a/hgext/rebase.py Sat Feb 18 04:10:08 2023 +0100
+++ b/hgext/rebase.py Mon Feb 20 12:06:03 2023 +0100
@@ -1513,12 +1513,14 @@
p1ctx = repo[p1]
if wctx.isinmemory():
wctx.setbase(p1ctx)
+ scope = util.nullcontextmanager
else:
if repo[b'.'].rev() != p1:
repo.ui.debug(b" update to %d:%s\n" % (p1, p1ctx))
mergemod.clean_update(p1ctx)
else:
repo.ui.debug(b" already in destination\n")
+ scope = lambda: repo.dirstate.changing_parents(repo)
# This is, alas, necessary to invalidate workingctx's manifest cache,
# as well as other data we litter on it in other places.
wctx = repo[None]
@@ -1528,26 +1530,27 @@
if base is not None:
repo.ui.debug(b" detach base %d:%s\n" % (base, repo[base]))
- # See explanation in merge.graft()
- mergeancestor = repo.changelog.isancestor(p1ctx.node(), ctx.node())
- stats = mergemod._update(
- repo,
- rev,
- branchmerge=True,
- force=True,
- ancestor=base,
- mergeancestor=mergeancestor,
- labels=[b'dest', b'source', b'parent of source'],
- wc=wctx,
- )
- wctx.setparents(p1ctx.node(), repo[p2].node())
- if collapse:
- copies.graftcopies(wctx, ctx, p1ctx)
- else:
- # If we're not using --collapse, we need to
- # duplicate copies between the revision we're
- # rebasing and its first parent.
- copies.graftcopies(wctx, ctx, ctx.p1())
+ with scope():
+ # See explanation in merge.graft()
+ mergeancestor = repo.changelog.isancestor(p1ctx.node(), ctx.node())
+ stats = mergemod._update(
+ repo,
+ rev,
+ branchmerge=True,
+ force=True,
+ ancestor=base,
+ mergeancestor=mergeancestor,
+ labels=[b'dest', b'source', b'parent of source'],
+ wc=wctx,
+ )
+ wctx.setparents(p1ctx.node(), repo[p2].node())
+ if collapse:
+ copies.graftcopies(wctx, ctx, p1ctx)
+ else:
+ # If we're not using --collapse, we need to
+ # duplicate copies between the revision we're
+ # rebasing and its first parent.
+ copies.graftcopies(wctx, ctx, ctx.p1())
if stats.unresolvedcount > 0:
if wctx.isinmemory():