rei*_*ard 2 mercurial mercurial-hook
在提交到存储库时,我在Mercurial中定义了一个钩子:
[hooks]
precommit.exportDB=exportDB.bat
Run Code Online (Sandbox Code Playgroud)
这将从我的数据库创建/更新SQL转储,该转储应包含在提交中.但是:虽然这有效,但Sql被标记为新的,但不是现在提交的变更集的一部分.如何自动包含它以使其进入已更改的文件集?
希望这有道理......
莱克哈德
这听起来很疯狂,但你可以分两步完成.首先将你的precommit钩子改成pre-commit钩子 - 是的,两者都存在并且它们是不同的.没有破折号,提交已经开始并且已经获得了一些锁定.使用破折号它会在提交开始之前发生,您仍然可以hg add使用新文件.
在unix上,总体变化将是:
[hooks]
pre-commit.exportDB=exportDB.sh && hg add resulting.sql
Run Code Online (Sandbox Code Playgroud)
可能在Windows上有类似的东西,或者您可以创建hg add批处理文件的最后一行.
PS不提交生成的文件.:)
更新:
我刚测试了这个,它按照我的建议工作:
ry4an@four:~$ hg init reinhard
ry4an@four:~$ cd reinhard/
ry4an@four:~/reinhard$ vi .hg/hgrc
ry4an@four:~/reinhard$ cat .hg/hgrc
[hooks]
pre-commit = hg add otherfile
ry4an@four:~/reinhard$ echo text > afile
ry4an@four:~/reinhard$ echo more > otherfile
ry4an@four:~/reinhard$ hg add afile
ry4an@four:~/reinhard$ hg status
A afile
? otherfile
ry4an@four:~/reinhard$ hg commit -m 'message'
ry4an@four:~/reinhard$ hg status --all
C afile
C otherfile
Run Code Online (Sandbox Code Playgroud)
请注意,在提交之前只添加'afile'并且'otherfile'是未知的,并且在提交之后两个文件都是'C'(意思是"清理" - 它们已被添加并提交).
| 归档时间: |
|
| 查看次数: |
586 次 |
| 最近记录: |