[PATCH stable] histedit: add "amnd" command to fold commit data and drop message (issue4256)
Augie Fackler
raf at durin42.com
Thu Aug 7 15:05:47 CDT 2014
On Aug 7, 2014, at 2:43 PM, adgar at google.com wrote:
> # HG changeset patch
> # User Mike Edgar <adgar at google.com>
> # Date 1407358301 14400
> # Wed Aug 06 16:51:41 2014 -0400
> # Node ID 8723c4a5b7256ce436bdaf8476c18b0f2c875fff
> # Parent 4354b1e35f533f72d5b6ccc76e8bc742f8cb5257
> histedit: add "amnd" command to fold commit data and drop message (issue4256)
Probably didn't mean to --flag stable this?
> This new histedit command (short for "amend") acts like "hg amend" does for
> working copy: it accumulates changes without interrupting the user and asking
> for an updated commit message.
Note for folks on the list: I'm not crazy about 'amnd' here, but 'fixup' seems like a bummer because it wouldn't have an obvious short character (f already being taken by fold). Anyone have a brilliant idea?
>
> diff -r 4354b1e35f53 -r 8723c4a5b725 hgext/histedit.py
> --- a/hgext/histedit.py Wed Aug 06 12:16:58 2014 -0500
> +++ b/hgext/histedit.py Wed Aug 06 16:51:41 2014 -0400
> @@ -36,6 +36,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> @@ -57,6 +58,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> @@ -179,6 +181,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> +# a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> @@ -293,7 +296,9 @@
> extra = commitopts.get('extra')
>
> parents = (first.p1().node(), first.p2().node())
> - editor = cmdutil.getcommiteditor(edit=True, editform='histedit.fold')
> + editor = None
> + if not commitopts.get('amend'):
> + editor = cmdutil.getcommiteditor(edit=True, editform='histedit.fold')
> new = context.memctx(repo,
> parents=parents,
> text=message,
> @@ -335,6 +340,11 @@
> _('Make changes as needed, you may commit or record as needed now.\n'
> 'When you are finished, run hg histedit --continue to resume.'))
>
> +def amend(ui, repo, ctx, ha, opts):
> + amendopts = opts.copy()
> + amendopts['amend'] = True
> + return fold(ui, repo, ctx, ha, amendopts)
> +
> def fold(ui, repo, ctx, ha, opts):
> oldctx = repo[ha]
> hg.update(repo, ctx.node())
> @@ -362,10 +372,13 @@
> username = ui.username()
> commitopts['user'] = username
> # commit message
> - newmessage = '\n***\n'.join(
> - [ctx.description()] +
> - [repo[r].description() for r in internalchanges] +
> - [oldctx.description()]) + '\n'
> + if opts.get('amend'):
> + newmessage = ctx.description()
> + else:
> + newmessage = '\n***\n'.join(
> + [ctx.description()] +
> + [repo[r].description() for r in internalchanges] +
> + [oldctx.description()]) + '\n'
> commitopts['message'] = newmessage
> # date
> commitopts['date'] = max(ctx.date(), oldctx.date())
> @@ -446,6 +459,8 @@
> 'edit': edit,
> 'f': fold,
> 'fold': fold,
> + 'a': amend,
> + 'amnd': amend,
> 'd': drop,
> 'drop': drop,
> 'm': message,
> @@ -681,7 +696,7 @@
> m, a, r, d = repo.status()[:4]
> if m or a or r or d:
> # prepare the message for the commit to comes
> - if action in ('f', 'fold'):
> + if action in ('f', 'fold', 'a', 'amnd'):
> message = 'fold-temp-revision %s' % currentnode
> else:
> message = ctx.description()
> @@ -704,15 +719,19 @@
> # to parent.
> replacements.append((ctx.node(), tuple(newchildren)))
>
> - if action in ('f', 'fold'):
> + if action in ('f', 'fold', 'a', 'amnd'):
> if newchildren:
> # finalize fold operation if applicable
> if new is None:
> new = newchildren[-1]
> else:
> newchildren.pop() # remove new from internal changes
> - parentctx, repl = finishfold(ui, repo, parentctx, ctx, new, opts,
> - newchildren)
> + foldopts = opts
> + if action in ('a', 'amnd'):
> + foldopts = foldopts.copy()
> + foldopts['amend'] = True
> + parentctx, repl = finishfold(ui, repo, parentctx, ctx, new,
> + foldopts, newchildren)
> replacements.extend(repl)
> else:
> # newchildren is empty if the fold did not result in any commit
> diff -r 4354b1e35f53 -r 8723c4a5b725 tests/test-histedit-arguments.t
> --- a/tests/test-histedit-arguments.t Wed Aug 06 12:16:58 2014 -0500
> +++ b/tests/test-histedit-arguments.t Wed Aug 06 16:51:41 2014 -0400
> @@ -57,6 +57,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> @@ -255,6 +256,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> diff -r 4354b1e35f53 -r 8723c4a5b725 tests/test-histedit-bookmark-motion.t
> --- a/tests/test-histedit-bookmark-motion.t Wed Aug 06 12:16:58 2014 -0500
> +++ b/tests/test-histedit-bookmark-motion.t Wed Aug 06 16:51:41 2014 -0400
> @@ -73,6 +73,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> @@ -133,6 +134,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> diff -r 4354b1e35f53 -r 8723c4a5b725 tests/test-histedit-commute.t
> --- a/tests/test-histedit-commute.t Wed Aug 06 12:16:58 2014 -0500
> +++ b/tests/test-histedit-commute.t Wed Aug 06 16:51:41 2014 -0400
> @@ -67,6 +67,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> @@ -344,6 +345,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> diff -r 4354b1e35f53 -r 8723c4a5b725 tests/test-histedit-fold.t
> --- a/tests/test-histedit-fold.t Wed Aug 06 12:16:58 2014 -0500
> +++ b/tests/test-histedit-fold.t Wed Aug 06 16:51:41 2014 -0400
> @@ -105,6 +105,50 @@
>
>
>
> +amend will fold without preserving the folded commit's message
> +
> + $ hg histedit d2ae7f538514 --commands - 2>&1 <<EOF | fixbundle
> + > pick d2ae7f538514 b
> + > amnd ee283cb5f2d5 e
> + > pick 6de59d13424a f
> + > pick 9c277da72c9b d
> + > EOF
> + 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
> + 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
> + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
> + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +
> +log after edit
> + $ hg logt --graph
> + @ 3:c4a9eb7989fc d
> + |
> + o 2:8e03a72b6f83 f
> + |
> + o 1:391ee782c689 b
> + |
> + o 0:cb9a9f314b8b a
> +
> +
> +description is taken from amended commit
> +
> + $ hg log --debug --rev 1
> + changeset: 1:391ee782c68930be438ccf4c6a403daedbfbffa5
> + phase: draft
> + parent: 0:cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
> + parent: -1:0000000000000000000000000000000000000000
> + manifest: 1:b5e112a3a8354e269b1524729f0918662d847c38
> + user: test
> + date: Thu Jan 01 00:00:00 1970 +0000
> + files+: b e
> + extra: branch=default
> + extra: histedit_source=d2ae7f538514cd87c17547b0de4cea71fe1af9fb,ee283cb5f2d5955443f23a27b697a04339e9a39a
> + description:
> + b
> +
> +
> +
> check saving last-message.txt
>
> $ cat > $TESTTMP/abortfolding.py <<EOF
> @@ -128,9 +172,9 @@
>> EOF
>
> $ rm -f .hg/last-message.txt
> - $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 6de59d13424a --commands - 2>&1 <<EOF | fixbundle
> - > pick 6de59d13424a f
> - > fold 9c277da72c9b d
> + $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <<EOF | fixbundle
> + > pick 8e03a72b6f83 f
> + > fold c4a9eb7989fc d
>> EOF
> 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> allow non-folding commit
> diff -r 4354b1e35f53 -r 8723c4a5b725 tests/test-histedit-obsolete.t
> --- a/tests/test-histedit-obsolete.t Wed Aug 06 12:16:58 2014 -0500
> +++ b/tests/test-histedit-obsolete.t Wed Aug 06 16:51:41 2014 -0400
> @@ -57,6 +57,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> diff -r 4354b1e35f53 -r 8723c4a5b725 tests/test-histedit-outgoing.t
> --- a/tests/test-histedit-outgoing.t Wed Aug 06 12:16:58 2014 -0500
> +++ b/tests/test-histedit-outgoing.t Wed Aug 06 16:51:41 2014 -0400
> @@ -49,6 +49,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> @@ -80,6 +81,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> @@ -103,6 +105,7 @@
> # p, pick = use commit
> # e, edit = use commit, but stop for amending
> # f, fold = use commit, but combine it with the one above
> + # a, amnd = add commit content to one above, dropping message (hg amend)
> # d, drop = remove commit from history
> # m, mess = edit message without changing commit content
> #
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20140807/5d6e228d/attachment.pgp>
More information about the Mercurial-devel
mailing list