Advocacy vs. git

Giorgos Keramidas keramida at ceid.upatras.gr
Sat Apr 25 13:52:25 CDT 2009


On Fri, 24 Apr 2009 23:19:14 -0400, Theodore Tso <tytso at mit.edu> wrote:
>On Sat, Apr 25, 2009 at 01:59:41AM +0200, Arne Babenhauserheide wrote:
>>Am Freitag 24 April 2009 23:59:02 schrieb Theodore Tso:
>>> They might be more _painful_ to use, sure.  So for me, if we must talk
>>> about "killer features", the one which is why I prefer to use git is
>>> "git commit --amend".  I will very often create a commit, and then
>>> about 30 seconds later, realize that I had typo'ed a comment, or the
>>> feature could be made even better if I made some further changes.  So
>>> at that point, I'll quickly edit the source files, make the further
>>> enhancements, and then use "git commit --amend foo.c".  I do this
>>> ***far*** more often than I use rebase.
>>
>> I kinda do the same - just that I rollback ("hg roll") and use my command
>> history to commit again (hit the up arrowkey twice + enter).
>
> Yeah, but the annoying thing about "hg rollback" is that you lose the
> commit message; you have to save it by hand, or type it all over
> again.

MQ can import the `tip' of a workspace and do most of commit --amend
with:

    hg qimport --git -r tip                     # import last commit as a patch
    hg qrefresh --edit --git                    # edit commit log
    hg qfinish tip                              # convert back to a 'real' commit

This works perfectly fine when there the tip is not a partial commit.

When there are local changes that have to be restored after the commit
editing operation, things may be slightly les user-friendly as one would
have to save the uncommitted stuff to a temporary MQ patch and restore
them later:

    hg qimport --git -r tip                     # import last commit as a patch
    hg qnew --git -m 'save local changes'       # save workspace changes
    hg qpop                                     # pop workspace changes
    hg qrefresh --edit                          # edit commit log of last commit
    hg qfinish tip                              # convert back to a commit
    hg qpush                                    # restore local changes
    hg qrefresh -X '**'                         # remove from patch diff
    hg qpop --force                             # pop temporary patch
    hg qdelete `hg qnext`                       # optionally delete tmp patch

I don't know how well "git commit --amend" handles partial commits, but
the MQ commands of the second case seem a bit too verbose.  I don't use
them too often though, so I am not sure if the extra granularity is a
good thing or something that would be nice to make easier to run.



More information about the Mercurial mailing list