Bug 4256 - Avoid editing commit message when folding a patch with histedit
Summary: Avoid editing commit message when folding a patch with histedit
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: histedit (show other bugs)
Version: unspecified
Hardware: All All
: wish feature
Assignee: Bugzilla
URL:
Keywords:
: 4131 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-05-20 17:07 UTC by Nathan Ridge
Modified: 2014-10-31 19:01 UTC (History)
8 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge 2014-05-20 17:07 UTC
Here's an extremely common use case of histedit for me:

  1. Write some code that belongs in a patch that's not
     the last patch I've committed (if it's the last
     patch, I'd just use amend).

  2. Commit into a temporary commit.

  3. Use histedit to fold the temporary commit into the
     commit it belongs to.

In such cases, I invariably want to keep commmit message of
the commit I'm folding into, and it's annoying to have the
commit message editor open up with:

  <my real commit message>
  ***
  <my temporary commit message>

and have to delete the latter two lines and save.

It would be nice if there were an action in histedit which
is like 'fold' but avoids this editing step and just keeps
the first patch's commit message.
Comment 1 Matt Mackall 2014-05-20 17:27 UTC
Setting priorities.

The utility to complexity ratio here is probably too low for this feature to be accepted and is probably mooted by evolve anyway. Adding people who care about this stuff for a second opinion.

You might want to investigate the evolve extension, which lets you amend anything and is the official roadmap for dealing with these sorts of workflow issues.
Comment 2 Nathan Ridge 2014-05-20 17:32 UTC
(In reply to comment #1)
I do use the evolve extension! How do you "amend anything" with it?
Comment 3 Matt Mackall 2014-05-20 18:12 UTC
1. Check out revision to amend
2. Make changes
3. Run "hg amend"

But perhaps your issue is you did step two before step one and now have to do some shuffling.
Comment 4 Nathan Ridge 2014-05-20 18:20 UTC
(In reply to comment #3)
Yeah - I don't want to have to check out the revision I'm amending into first.

A common variant on the workflow I presented in comment 0 is:

  1. Write some code, without particular regard as to
     which commit it should go into.

  2. Do some "record"'s to sort the newly written code
     into chunks that should be amended into various
     commits, yielding several temporary commits.

  3. Use histedit to fold the temporary commits into
     the respective commits where they belong. Again,
     I just want to re-use the commit messages of the
     existing commits without having to interact with
     an editor for each one.

I don't think evolve's functionality addresses this use case.
Comment 5 Martin Geisler 2014-05-21 02:34 UTC
For reference, the Git equivalent ('git rebase -i') has a 'fixup' action for this: it folds the commit into the previous commit and throws away the commit message. I found this action useful when I used it.

In my experience, the fixup commits often appear out of sequence -- I spot a typo introduced in an earlier commit while working on another piece of code.
Comment 6 Martin Geisler 2014-05-21 02:40 UTC
Maybe I ended my previous comment too early: I mention out-of-sequence commits with a dirty working copy becausethis means that you'll want to eventually reorder the commits when everything is committed. This makes 'hg histedit' the tool to use instead of the evolve-enabled 'hg amend'.
Comment 7 Augie Fackler 2014-05-21 08:51 UTC
I would actually not mind seeing this if we can come up with a good name for the verb. It's struck me as one of the missing-ish features from rebase -i that I would use periodically.

I also agree that evolution in its current form isn't really a substitute - histedit lets me do things much more gracefully after a prolonged period of hacking without committing (or making semi-arbitrary checkpoint commits).

Anyone object if I reopen the bug? It should actually be a very easy task.
Comment 8 Bryan O'Sullivan 2014-07-05 01:03 UTC
I would be happy to see this reopened.
Comment 9 Nathan Ridge 2014-07-06 23:38 UTC
Reopening as per comments 7 and 8.
Comment 10 Augie Fackler 2014-07-28 22:32 UTC
*** Bug 4131 has been marked as a duplicate of this bug. ***
Comment 11 HG Bot 2014-08-14 16:30 UTC
Fixed by http://selenic.com/repo/hg/rev/d2a5986cb89d
Mike Edgar <adgar@google.com>
histedit: add "roll" command to fold commit data and drop message (issue4256)

This new histedit command (short for "rollup") is a variant of "fold" akin to
"hg amend" for working copy: it accumulates changes without interrupting
the user and asking for an updated commit message.

(please test the fix)
Comment 12 Nathan Ridge 2014-08-17 05:05 UTC
I tested the fix; it seems to be working well. Thanks!
Comment 13 Pierre-Yves David 2014-08-18 01:03 UTC
rock & roll
Comment 14 Nathan Ridge 2014-10-31 18:43 UTC
What release is this fix targeting - 3.2?
Comment 15 Augie Fackler 2014-10-31 18:56 UTC
Yes, this should be present in 3.2, which should release tomorrow or as soon as feasible thereafter.
Comment 16 Nathan Ridge 2014-10-31 19:00 UTC
(In reply to comment #15)
Ok, thanks. Out of curiosity, is there a way I could have found that out myself? (I'm used to bug trackers having a "Target Milestone" field that gives this information.)
Comment 17 Augie Fackler 2014-10-31 19:01 UTC
http://mercurial.selenic.com/wiki/TimeBasedReleasePlan is the closest - we don't "target" a fix to a release - once a patch is in, it'll be in the next major release.