Mercurial > hg
comparison mercurial/shelve.py @ 49961: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 | 1b044a63a98a |
comparison
equal
deleted
inserted
replaced
49960:c166b212bdee | 49961:7a8bfc05b691 |
---|---|
635 match = _optimized_match(repo, node) | 635 match = _optimized_match(repo, node) |
636 _shelvecreatedcommit(repo, node, name, match) | 636 _shelvecreatedcommit(repo, node, name, match) |
637 | 637 |
638 ui.status(_(b'shelved as %s\n') % name) | 638 ui.status(_(b'shelved as %s\n') % name) |
639 if opts[b'keep']: | 639 if opts[b'keep']: |
640 with repo.dirstate.parentchange(repo): | 640 with repo.dirstate.changing_parents(repo): |
641 scmutil.movedirstate(repo, parent, match) | 641 scmutil.movedirstate(repo, parent, match) |
642 else: | 642 else: |
643 hg.update(repo, parent.node()) | 643 hg.update(repo, parent.node()) |
644 ms = mergestatemod.mergestate.read(repo) | 644 ms = mergestatemod.mergestate.read(repo) |
645 if not ms.unresolvedcount(): | 645 if not ms.unresolvedcount(): |
860 ) | 860 ) |
861 | 861 |
862 shelvectx = repo[state.parents[1]] | 862 shelvectx = repo[state.parents[1]] |
863 pendingctx = state.pendingctx | 863 pendingctx = state.pendingctx |
864 | 864 |
865 with repo.dirstate.parentchange(repo): | 865 with repo.dirstate.changing_parents(repo): |
866 repo.setparents(state.pendingctx.node(), repo.nullid) | 866 repo.setparents(state.pendingctx.node(), repo.nullid) |
867 repo.dirstate.write(repo.currenttransaction()) | 867 repo.dirstate.write(repo.currenttransaction()) |
868 | 868 |
869 targetphase = _target_phase(repo) | 869 targetphase = _target_phase(repo) |
870 overrides = {(b'phases', b'new-commit'): targetphase} | 870 overrides = {(b'phases', b'new-commit'): targetphase} |
871 with repo.ui.configoverride(overrides, b'unshelve'): | 871 with repo.ui.configoverride(overrides, b'unshelve'): |
872 with repo.dirstate.parentchange(repo): | 872 with repo.dirstate.changing_parents(repo): |
873 repo.setparents(state.parents[0], repo.nullid) | 873 repo.setparents(state.parents[0], repo.nullid) |
874 newnode, ispartialunshelve = _createunshelvectx( | 874 newnode, ispartialunshelve = _createunshelvectx( |
875 ui, repo, shelvectx, basename, interactive, opts | 875 ui, repo, shelvectx, basename, interactive, opts |
876 ) | 876 ) |
877 | 877 |
1066 activebookmark, | 1066 activebookmark, |
1067 interactive, | 1067 interactive, |
1068 ) | 1068 ) |
1069 raise error.ConflictResolutionRequired(b'unshelve') | 1069 raise error.ConflictResolutionRequired(b'unshelve') |
1070 | 1070 |
1071 with repo.dirstate.parentchange(repo): | 1071 with repo.dirstate.changing_parents(repo): |
1072 repo.setparents(tmpwctx.node(), repo.nullid) | 1072 repo.setparents(tmpwctx.node(), repo.nullid) |
1073 newnode, ispartialunshelve = _createunshelvectx( | 1073 newnode, ispartialunshelve = _createunshelvectx( |
1074 ui, repo, shelvectx, basename, interactive, opts | 1074 ui, repo, shelvectx, basename, interactive, opts |
1075 ) | 1075 ) |
1076 | 1076 |