How do I make files with a specific extension be added to a commit automatically?
I'm trying to figure out how to automaticall开发者_Go百科y add all files of a certain extension (for example *.tex) to the commit dialogue (the checkbox should already be checked! I don't want to search for the new files every single time)
I tried adding *.tex to the auto-commit list (=comma separated list) but that doesn't do anything.
Mercurial has so called hooks to do stuff automatically on certain events. See also the hgrc documentation and the Mercurial wiki page on Hooks.
Your task can be done with a pre-commit hook, defined in your repository's hgrc file:
[hooks]
pre-commit = hg add -I "*.tex"
Before a commit, this hook automatically adds all not yet tracked tex files in the root of the repository's current working directory. Adjust the value of the -I
option or add more -I
options to specify more complex patterns of files to add automatically.
Note: I don't use TortoiseHG, so I cannot say if this hook causes any checkboxes to be pre-selected. Anyway, it should also work if you commit with TortoiseHG.
In hg as console application this very simple solution works, too:
hg add "*.tex"
精彩评论