Move lines from hunk to new patch (hg)

I am using SourceTree to try to break a large patch into smaller patches so that they are easier to review.

Hunks may contain content that should be split into other patches so ideally I would be able to highlight a few lines from a hunk and somehow mark them for moving into a new patch.

Is there any way to move lines from one patch into a new / other patch?

This is for a Mercurial repository on OSX.

1 answer

Seems like this is not possible in SourceTree but there is a Mercurial extension that allows per hunk and per line cherry picking. At first I was put off by the fact that it has a text only interface but when I tried it I was surprised by the fact that it was so pleasant to use.

crecord is available from http://bitbucket.org/edgimar/crecord/get/tip.zip... unzip it somewhere, chmod +x * in that folder and add it to your extensions section:

[extensions]
crecord = path/to/crecord/

To use it:

$ hg qref -X .     # take changes out of current patch and back into `hg diff`
$ hg qcrecord -m "Did something!" new-patch-name.patch

The text interface is easy to use, navigate using the cursor keys and select things using space.

It would certainly be nice to be able to do this inside SourceTree though.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

570 views 1 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you