1

Setup

I am working on a feature A. My current uncommited changes in one file are:

 aaa
-bbb
+ccc
+ddd
 eee

However, I realize that I could and should split this into 2 commits:

  • First commit:

     aaa
    -bbb
    +ccc
     eee
    
  • Second commit:

     aaa
     ccc
    +ddd
     eee
    

Actual code is multiple change sets on multiple files.

Problem

Lines are too close to each other, and Mercurial (using TortoiseHg) considers them a single change set.

  • Commit screen has a checkboxes for single change set, not for individual lines.

  • Shelve feature also doesn't allow shelving single lines.

  • Mercurial queue commit screen doesn't have any checkboxes at all.

Only way seems to be removing all lines of the second commit manually, then create first commit, then reapply lines back manually and do second commit. This is error prone and a lot of work.

Question

Can I force mercurial to consider each row as a separate change set or shelve single lines from change set?

user694733
  • 15,208
  • 2
  • 42
  • 68
  • Do you want to split single *hunks* into parts or do you simply want to split different hunks in different commits? – planetmaker Feb 01 '17 at 13:37
  • @planetmaker Problem is that mercurial considers all changed lines which are nearby each other to be one single change. I would like to cherry pick individual lines for commit. – user694733 Feb 01 '17 at 13:41
  • 2
    related to http://stackoverflow.com/questions/33595826/is-there-an-hg-equivalent-of-git-stash-save-p-that-can-split-chunks-into-smal – Marcos Zolnowski Feb 02 '17 at 03:46
  • @MarcosZolnowski Thank you, that's exactly what I need. I'll close this as duplicate of that question. – user694733 Feb 02 '17 at 09:15

0 Answers0