Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 47608:3c0efa0eeea6
amend: adjust the dirstate within a `parentchange` context
The adjustment in the direct consequence of the amend and the associated parents
change.
Differential Revision: https://phab.mercurial-scm.org/D11032
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 08 Jul 2021 21:26:21 +0200 |
parents | 7c64688e554d |
children | 61753b1ba96f |
comparison
equal
deleted
inserted
replaced
47607:ff82edadc2e1 | 47608:3c0efa0eeea6 |
---|---|
2965 if opts.get(b'secret'): | 2965 if opts.get(b'secret'): |
2966 commitphase = phases.secret | 2966 commitphase = phases.secret |
2967 newid = repo.commitctx(new) | 2967 newid = repo.commitctx(new) |
2968 ms.reset() | 2968 ms.reset() |
2969 | 2969 |
2970 # Reroute the working copy parent to the new changeset | 2970 with repo.dirstate.parentchange(): |
2971 repo.setparents(newid, repo.nullid) | 2971 # Reroute the working copy parent to the new changeset |
2972 | 2972 repo.setparents(newid, repo.nullid) |
2973 # Fixing the dirstate because localrepo.commitctx does not update | 2973 |
2974 # it. This is rather convenient because we did not need to update | 2974 # Fixing the dirstate because localrepo.commitctx does not update |
2975 # the dirstate for all the files in the new commit which commitctx | 2975 # it. This is rather convenient because we did not need to update |
2976 # could have done if it updated the dirstate. Now, we can | 2976 # the dirstate for all the files in the new commit which commitctx |
2977 # selectively update the dirstate only for the amended files. | 2977 # could have done if it updated the dirstate. Now, we can |
2978 dirstate = repo.dirstate | 2978 # selectively update the dirstate only for the amended files. |
2979 | 2979 dirstate = repo.dirstate |
2980 # Update the state of the files which were added and modified in the | 2980 |
2981 # amend to "normal" in the dirstate. We need to use "normallookup" since | 2981 # Update the state of the files which were added and modified in the |
2982 # the files may have changed since the command started; using "normal" | 2982 # amend to "normal" in the dirstate. We need to use "normallookup" since |
2983 # would mark them as clean but with uncommitted contents. | 2983 # the files may have changed since the command started; using "normal" |
2984 normalfiles = set(wctx.modified() + wctx.added()) & filestoamend | 2984 # would mark them as clean but with uncommitted contents. |
2985 for f in normalfiles: | 2985 normalfiles = set(wctx.modified() + wctx.added()) & filestoamend |
2986 dirstate.normallookup(f) | 2986 for f in normalfiles: |
2987 | 2987 dirstate.normallookup(f) |
2988 # Update the state of files which were removed in the amend | 2988 |
2989 # to "removed" in the dirstate. | 2989 # Update the state of files which were removed in the amend |
2990 removedfiles = set(wctx.removed()) & filestoamend | 2990 # to "removed" in the dirstate. |
2991 for f in removedfiles: | 2991 removedfiles = set(wctx.removed()) & filestoamend |
2992 dirstate.drop(f) | 2992 for f in removedfiles: |
2993 dirstate.drop(f) | |
2993 | 2994 |
2994 mapping = {old.node(): (newid,)} | 2995 mapping = {old.node(): (newid,)} |
2995 obsmetadata = None | 2996 obsmetadata = None |
2996 if opts.get(b'note'): | 2997 if opts.get(b'note'): |
2997 obsmetadata = {b'note': encoding.fromlocal(opts[b'note'])} | 2998 obsmetadata = {b'note': encoding.fromlocal(opts[b'note'])} |