How do I include a defect number when doing a mercurial commit? The way that I开发者_如何转开发'm currently doing it is to precede the commit message with the defect number so that QA can find the commits that relate to each defect.
Is there a field or tag that would allow me to add a number to each mercurial commit?
If not, is there a better way (than putting the number in the commit message) to associate a number with a commit?
There are no special fields. The only trick is that only the first line appears when you're not using verbose view.
However, some software that integrates with Mercurial parses the message in various ways. For example, Google Code will detect references to "issue n", and create a link.
There is no standard way to annotate defect ids in mercurial. To sync revision control systems and bugtracking software, you usually setup 'hooks'. These hooks are scripts that get called after a certain operation has been performed. For instance, you may have a post-commit hook that checks if your latest commit contained a string of the type 'fixed xxxx', and then automatically marks the case xxxx as fixed on your bugtracking software through an API call.
Many FOSS and commercial integrated source code revision control + bugtracking solutions already do this for you.
Commit messages are probably good, since as Matthew points out your project tracker likely has the capability to find these. For instance, Redmine will look for phrases like "Fixed #578" in your commit messages and automatically update the related issue.
You could also use revsets (the new query language) to search by keywords in commit message.
If you still don't like putting those in commit messages, you could tag the commit. Perhaps something like:
hg tag defect-578 -m "Problem with the widget on the left side of the thing fixed."
The tag can then be pushed upstream, modified, or removed as necessary.
Take a look at mercurial tags.
As for me, I always just put defect number in comment and then use log
command when I need to find it:
hg log -k 'defect#'
精彩评论