Since it's the best practice to commit early, commit often I would like to be promoted with a dialog that will ask for a commit message and will commit to my local mercurial repository that I am working on.
What's the easiest way to implement such a feature? I would like to avoid writing am add-in if possible. One idea I had is to run a post build command that will execute a batch file. In turn the batch file will check if the build was successful and then it will execute:hg addremove
If nothing was either added or removed, no commit message will be requested. If any files were added or removed it will ask me for a commi开发者_如何学Got message, once the commit message has been inputted it will execute:
hg commit -m "Insert message here"
Is it possible? If so, how?
First of all, I doubt you really want to do that.
Most patterns related to version control dictates that you want to know what the change was about. I build many times during the implementation of a single bug-fix, but your question leads me to think that you would think it was OK to get N commits, most of them bad, into your version control system, with no real purpose.
Now, I agree that it is best practice to commit early, and commit often, but it is not a best practice to commit blindly and commit just because it builds. You should commit when you got something you want to preserve.
Having said that, have you tried executing the hg commit
command without any arguments whatsoever? The default behavior is to pop up a text file for editing, typically through your default text editor, and wait for you to save it with new content.
In other words, this should do what you want:
hg commit --addremove
However, and I strongly urge you to rethink this, you might question this decision at some point when you see a version history full of commits that are just endlessly editing files back and forth during some experimental development or bugfixing.
There's some good add-ins for Visual Studio out there as well, you might want to consider these instead:
- VisualHG
- HgSCC
精彩评论