comparison mercurial/cmdutil.py @ 49960:c166b212bdee

dirstate: pass the repo to the `changeparent` method If we want the context to be responsible for writing (and we want it), we need to have access to a localrepository object. So we now requires a localrepository object as an argument to this context manager.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 25 Jan 2023 18:46:20 +0100
parents e78a41686464
children 7a8bfc05b691
comparison
equal deleted inserted replaced
49959:376395868b7b 49960:c166b212bdee
636 # XXX-PENDINGCHANGE: We should clarify the context in 636 # XXX-PENDINGCHANGE: We should clarify the context in
637 # which this function is called to make sure it 637 # which this function is called to make sure it
638 # already called within a `pendingchange`, However we 638 # already called within a `pendingchange`, However we
639 # are taking a shortcut here in order to be able to 639 # are taking a shortcut here in order to be able to
640 # quickly deprecated the older API. 640 # quickly deprecated the older API.
641 with dirstate.parentchange(): 641 with dirstate.parentchange(repo):
642 dirstate.update_file( 642 dirstate.update_file(
643 realname, 643 realname,
644 p1_tracked=True, 644 p1_tracked=True,
645 wc_tracked=True, 645 wc_tracked=True,
646 possibly_dirty=True, 646 possibly_dirty=True,
1530 with repo.lock(): 1530 with repo.lock():
1531 mem_ctx = new_ctx.tomemctx_for_amend(ctx) 1531 mem_ctx = new_ctx.tomemctx_for_amend(ctx)
1532 new_node = mem_ctx.commit() 1532 new_node = mem_ctx.commit()
1533 1533
1534 if repo.dirstate.p1() == ctx.node(): 1534 if repo.dirstate.p1() == ctx.node():
1535 with repo.dirstate.parentchange(): 1535 with repo.dirstate.parentchange(repo):
1536 scmutil.movedirstate(repo, repo[new_node]) 1536 scmutil.movedirstate(repo, repo[new_node])
1537 replacements = {ctx.node(): [new_node]} 1537 replacements = {ctx.node(): [new_node]}
1538 scmutil.cleanupnodes( 1538 scmutil.cleanupnodes(
1539 repo, replacements, b'uncopy', fixphase=True 1539 repo, replacements, b'uncopy', fixphase=True
1540 ) 1540 )
1623 with repo.lock(): 1623 with repo.lock():
1624 mem_ctx = new_ctx.tomemctx_for_amend(ctx) 1624 mem_ctx = new_ctx.tomemctx_for_amend(ctx)
1625 new_node = mem_ctx.commit() 1625 new_node = mem_ctx.commit()
1626 1626
1627 if repo.dirstate.p1() == ctx.node(): 1627 if repo.dirstate.p1() == ctx.node():
1628 with repo.dirstate.parentchange(): 1628 with repo.dirstate.parentchange(repo):
1629 scmutil.movedirstate(repo, repo[new_node]) 1629 scmutil.movedirstate(repo, repo[new_node])
1630 replacements = {ctx.node(): [new_node]} 1630 replacements = {ctx.node(): [new_node]}
1631 scmutil.cleanupnodes(repo, replacements, b'copy', fixphase=True) 1631 scmutil.cleanupnodes(repo, replacements, b'copy', fixphase=True)
1632 1632
1633 return 1633 return
3022 elif opts.get(b'draft'): 3022 elif opts.get(b'draft'):
3023 commitphase = phases.draft 3023 commitphase = phases.draft
3024 newid = repo.commitctx(new) 3024 newid = repo.commitctx(new)
3025 ms.reset() 3025 ms.reset()
3026 3026
3027 with repo.dirstate.parentchange(): 3027 with repo.dirstate.parentchange(repo):
3028 # Reroute the working copy parent to the new changeset 3028 # Reroute the working copy parent to the new changeset
3029 repo.setparents(newid, repo.nullid) 3029 repo.setparents(newid, repo.nullid)
3030 3030
3031 # Fixing the dirstate because localrepo.commitctx does not update 3031 # Fixing the dirstate because localrepo.commitctx does not update
3032 # it. This is rather convenient because we did not need to update 3032 # it. This is rather convenient because we did not need to update