Search code examples
mercurial

Easiest way to split a change set in mercurial


I'm comfortable using git, but have been exploring Mercurial lately out of curiosity based on a friends opinion that it is better in some ways.

One of the first things I noticed however is that Mercurial does not appear to have an index as git does. I tend to make more changes then I should sometimes and after editing the file I will use git add -p to split the patch into separate commits. If the changes are in different files I could probably use MQ, but otherwise it looks like I need to undo changes first.

Is there maybe an extension for Mercurial that provides index-like functionality?


Solution

  • You're correct that there's no git-style index. You can use hg record (distributed with Mercurial) or hg crecord. Both let you choose on a per-file or per-hunk basis when committing. crecord is a more sophisticated, but requires curses.

    UPDATE (2016-11-19)

    The functionality of the crecord extension now is available in core Mercurial. Also the usage is better integrated. The preferred way to commit selected hunks is

    $ hg commit --interactive
    

    By default this behaves like the old record command. To get the curses based interface like in the old crecord command, set this in your HGRC:

    [ui]
    interface = curses