Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Committing only some files in Mercurial

Many times I'm making two different changes to files in my repository, I want those changes to be treated as two consecutive commits.

For example, in repository

  • prog.c
  • prog.h
  • README.txt

While fixing a bug prog.c and prog.h, I fixed a typo in README.txt. Now I want to commit the change to prog.c with its own commit message, and the change to README.txt afterwards.

In git, I could easily do that with the index

git add prog.c prog.h
git commit -m 'bug #1234'
git commit README.txt -m 'some typos fixed'

What's the best way to do that in Mercurial?

Clarification: I used (before the edit) a toy example where each changeset spans over a single file. But I want the general answer, what should I do when there are many files in each changeset.

like image 521
Elazar Leibovich Avatar asked Dec 28 '09 10:12

Elazar Leibovich


2 Answers

hg commit -m "bug #1234" prog.c prog.h

then

hg commit -m "some typos fixed" README.txt
like image 105
Jerome Avatar answered Nov 11 '22 14:11

Jerome


I LOVE the crecord mercurial extension for this purpose: it gives me file by file (and chunk by chunk, and line by line) control over what exactly I want in this commit.

like image 32
RyanWilcox Avatar answered Nov 11 '22 12:11

RyanWilcox