Specific Commit Messages for Various Files in Mercurial
In My Mercurial Repository, I have 4 files I modified,
When I make a Commit, The commit message applied to all Files I modified, but, 开发者_如何学运维there are any form to write a specific commit message for every file I modified in the commit screen??
Ideally, every changeset should contain some specific change, be it something as small as fixing a small bug by correcting a single line in a file, or something as big as changing the signature of a function all over the codebase.
This allows you to do things like transplanting a changeset to a different branch later, which is only easy when your changesets are not polluted by unrelated stuff.
(By the way, this is the main difference between modern DVCS like Mercurial or Git, which track changes, and older systems like SVN, which track revisions.)
If you feel like you need to write separate comments for every file, this might mean you're actually committing several unrelated changes at once, which isn't good practice.
On the other hand, if it's not the case, you can of course write a multi-line message:
User can no longer add the same product twice (issue123)
add_product.py: added server-side validation
scripts.js: added client-side validation
If you are using the command line, you can commit changes to individual files by passing them on the hg commit
command line:
> hg st
M file1.cpp
M file1.h
M file2.cpp
M file2.h
> hg commit -m "Some changes" file1.cpp file1.h
> hg st
M file2.cpp
M file2.h
You can do the same thing using TortoiseHg by only "checking" the files you want checked in in the thg commit
window - or more precisely, by unchecking those you don't want committed.
Note however that this will create several changesets, one for each commit. If this is not what you want, then I would agree with Helgi.
In a previous version of TortoiseHg (back when it was written using tk, so not that long ago), it was actually possible to select individual "chunks" of changes to a file and commit them separately. However this is not available in the current version, and as far as I am aware is not planned for a while.
Actually, the commit message applies to the changeset, which contains changes to the files you modified.
You could make multi-line messages if you want to address the changes to each file:
new features, fixed bugs, etc.
file1.txt: fixed bug 1234
file2.txt: refactored body of Foobar()
file3.txt: did Rot13 on the entire file, twice
file4.txt: added overload of Bar() to except a second Foo object
I don't recommend doing a changeset for each file, however, even though that is possible.
精彩评论