Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mercurial:包括预提交更改的文件_Mercurial_Mercurial Hook - Fatal编程技术网

mercurial:包括预提交更改的文件

mercurial:包括预提交更改的文件,mercurial,mercurial-hook,Mercurial,Mercurial Hook,在提交到存储库时,我在Mercurial中定义了一个钩子: [hooks] precommit.exportDB=exportDB.bat 这将从我的数据库创建/更新SQL转储,该转储应包含在提交中。 但是:尽管这样做有效,Sql被标记为新的,但不是现在提交的变更集的一部分。 如何自动将其包含在已更改的文件集中 希望这有意义 Thx 莱因哈德这听起来很疯狂,但你可以分两步完成。首先将您的预提交钩子更改为预提交钩子——是的,两者都存在,而且它们不同。在没有破折号的情况下,提交已经开始,并且获得了

在提交到存储库时,我在Mercurial中定义了一个钩子:

[hooks]
precommit.exportDB=exportDB.bat
这将从我的数据库创建/更新SQL转储,该转储应包含在提交中。 但是:尽管这样做有效,Sql被标记为新的,但不是现在提交的变更集的一部分。 如何自动将其包含在已更改的文件集中

希望这有意义

Thx
莱因哈德

这听起来很疯狂,但你可以分两步完成。首先将您的
预提交
钩子更改为
预提交
钩子——是的,两者都存在,而且它们不同。在没有破折号的情况下,提交已经开始,并且获得了一些锁。使用破折号,它发生在提交开始之前,您仍然可以添加新文件

在这样的unix上,总的更改是:

[hooks]
pre-commit.exportDB=exportDB.sh && hg add resulting.sql
大概Windows上也有类似的功能,或者您可以将
hgadd
作为批处理文件的最后一行

注意:不要提交生成的文件。:)

更新:

我刚刚测试了这个,它按照我的建议工作:

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

请注意,在提交之前,只添加了'afile','otherfile'是未知的,而在提交之后,两个文件都是'C'(意思是“Clean'——它们已被添加并提交).

thx获取预提交技巧。我还在脚本末尾添加了“hg add newfile.sql”。但这只会触发另一个连续提交,因此它不在第一个变更集中…是的,这是可行的-但我尝试在windows上使用TortoiseHG进行一键式更新QLDump和提交更改。这造成了问题,因为新添加的le没有进入变更集,可能是因为单击“提交”时,在创建新文件之前,文件列表已经存在。再次感谢您的时间和努力!!