Mercurial:包括预先提交更改的文件 [英] mercurial: including precommit-changed file

查看:106
本文介绍了Mercurial:包括预先提交更改的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

On commit to repository I have a hook defined in Mercurial:

[hooks]
precommit.exportDB=exportDB.bat

这将从我的数据库中创建/更新一个SQL转储,应该包含在提交中. 但是:尽管这可行,但是Sql被标记为新的,但不是现在提交的变更集的一部分. 我如何自动将其包括进来,使其进入一组已更改的文件中?

This creates/updates a SQL-dump from my database, which should be included in the commit. BUT: although this works, the Sql is marked as new, but not part of the now commiting changeset. How can I automatically include it so it gets into the set of changed files?

希望这很有道理...

Hope this makes sense...

Thx 莱因哈德

推荐答案

这听起来很疯狂,但是您可以分两步完成.首先将您的precommit钩子更改为pre-commit钩子-是的,两者都存在并且不同.没有破折号,提交已经开始,并且已经获得了一些锁定.破折号会在提交开始之前发生,您仍然可以hg add新文件.

This'll sound crazy, but you can do it in two steps. First change your precommit hook to a pre-commit hook -- yup, both exist and they're different. Without the dash the commit has already started and some lock has been acquired. With the dash it happens before the commit starts and you can still hg add the new file.

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

On a unix like that total change would be:

[hooks]
pre-commit.exportDB=exportDB.sh && hg add resulting.sql

大概在Windows上也有类似的东西,或者您可以将hg add做为批处理文件的最后一行.

presumably there's something similar on Windows, or you could make the hg add the last line of the batch file.

P.S.不要提交生成的文件. :)

P.S. Don't commit generated files. :)

更新:

我刚刚对此进行了测试,并且按照我的建议进行了工作:

I just tested this and it works as I suggested:

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"(表示清除"-已添加并提交).

Notice that before the commit only 'afile' is added and 'otherfile' is unknown, and after the commit both files are 'C' (meaning "Clean' -- they've been added and committed).

这篇关于Mercurial:包括预先提交更改的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆