2965 newid = repo.commitctx(new) |
2965 newid = repo.commitctx(new) |
2966 ms.reset() |
2966 ms.reset() |
2967 |
2967 |
2968 # Reroute the working copy parent to the new changeset |
2968 # Reroute the working copy parent to the new changeset |
2969 repo.setparents(newid, nullid) |
2969 repo.setparents(newid, nullid) |
|
2970 |
|
2971 # Fixing the dirstate because localrepo.commitctx does not update |
|
2972 # it. This is rather convenient because we did not need to update |
|
2973 # the dirstate for all the files in the new commit which commitctx |
|
2974 # could have done if it updated the dirstate. Now, we can |
|
2975 # selectively update the dirstate only for the amended files. |
|
2976 dirstate = repo.dirstate |
|
2977 |
|
2978 # Update the state of the files which were added and modified in the |
|
2979 # amend to "normal" in the dirstate. We need to use "normallookup" since |
|
2980 # the files may have changed since the command started; using "normal" |
|
2981 # would mark them as clean but with uncommitted contents. |
|
2982 normalfiles = set(wctx.modified() + wctx.added()) & filestoamend |
|
2983 for f in normalfiles: |
|
2984 dirstate.normallookup(f) |
|
2985 |
|
2986 # Update the state of files which were removed in the amend |
|
2987 # to "removed" in the dirstate. |
|
2988 removedfiles = set(wctx.removed()) & filestoamend |
|
2989 for f in removedfiles: |
|
2990 dirstate.drop(f) |
|
2991 |
2970 mapping = {old.node(): (newid,)} |
2992 mapping = {old.node(): (newid,)} |
2971 obsmetadata = None |
2993 obsmetadata = None |
2972 if opts.get(b'note'): |
2994 if opts.get(b'note'): |
2973 obsmetadata = {b'note': encoding.fromlocal(opts[b'note'])} |
2995 obsmetadata = {b'note': encoding.fromlocal(opts[b'note'])} |
2974 backup = ui.configbool(b'rewrite', b'backup-bundle') |
2996 backup = ui.configbool(b'rewrite', b'backup-bundle') |
2979 metadata=obsmetadata, |
3001 metadata=obsmetadata, |
2980 fixphase=True, |
3002 fixphase=True, |
2981 targetphase=commitphase, |
3003 targetphase=commitphase, |
2982 backup=backup, |
3004 backup=backup, |
2983 ) |
3005 ) |
2984 |
|
2985 # Fixing the dirstate because localrepo.commitctx does not update |
|
2986 # it. This is rather convenient because we did not need to update |
|
2987 # the dirstate for all the files in the new commit which commitctx |
|
2988 # could have done if it updated the dirstate. Now, we can |
|
2989 # selectively update the dirstate only for the amended files. |
|
2990 dirstate = repo.dirstate |
|
2991 |
|
2992 # Update the state of the files which were added and modified in the |
|
2993 # amend to "normal" in the dirstate. We need to use "normallookup" since |
|
2994 # the files may have changed since the command started; using "normal" |
|
2995 # would mark them as clean but with uncommitted contents. |
|
2996 normalfiles = set(wctx.modified() + wctx.added()) & filestoamend |
|
2997 for f in normalfiles: |
|
2998 dirstate.normallookup(f) |
|
2999 |
|
3000 # Update the state of files which were removed in the amend |
|
3001 # to "removed" in the dirstate. |
|
3002 removedfiles = set(wctx.removed()) & filestoamend |
|
3003 for f in removedfiles: |
|
3004 dirstate.drop(f) |
|
3005 |
3006 |
3006 return newid |
3007 return newid |
3007 |
3008 |
3008 |
3009 |
3009 def commiteditor(repo, ctx, subs, editform=b''): |
3010 def commiteditor(repo, ctx, subs, editform=b''): |