Mercurial > hg-stable
comparison mercurial/cmdutil.py @ 50023:7a8bfc05b691
dirstate: rename parentchange to changing_parents
Since the new argument breaks the API anyway, we can rename it to a better name.
The previous name `parentchange` might be seen as something active, a function
that would directly change the parents, however this is just a context manager
to frame the operation that will change the parents and adjust the
dirstate content accordingly.
In addition, the future sister method that will be about changes to tracking and
files would have a hard time fitting in the same naming scheme in a clear way.
The new naming uses a clear prefix will make it more distinct from other
dirstate methods and easier to extend with other similar contexts.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 25 Jan 2023 19:12:31 +0100 |
parents | c166b212bdee |
children | a46dfc2b58a3 |
comparison
equal
deleted
inserted
replaced
50022:c166b212bdee | 50023:7a8bfc05b691 |
---|---|
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(repo): | 641 with dirstate.changing_parents(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(repo): | 1535 with repo.dirstate.changing_parents(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(repo): | 1628 with repo.dirstate.changing_parents(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(repo): | 3027 with repo.dirstate.changing_parents(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 |