如何使用 Mercurial 队列或 histedit 禁用 pretxncommit 挂钩?
我的本地 Mercurial 存储库中有一些 pretxncommit 挂钩,这些挂钩用于检查提交消息是否包含对票证的引用和其他一些健全性检查。
我的问题是,当我尝试使用 Mercurial 队列时,像 qnew
这样的命令尝试运行这些挂钩,并且其中一个票证检查失败,我在 histedit
中也看到了同样的问题> 和类似的扩展。
为什么要使用这些命令执行 pretxncommit 挂钩?他们是否运行某种内部提交?
如何使这些挂钩仅在提交时运行?
I have some pretxncommit hooks in my local mercurial repository, those hooks are used to check that the commit message includes a reference to a ticket and some other sanity checks.
My problem is that when I try to use mercurial queues, commands like qnew
try to run these hooks and the one of the ticket checking fails, I have seen the same problem with histedit
and similar extensions.
Why are pretxncommit hooks executed with these commands? Do they run some kind of internal commit?
How can I make these hooks to be run only on commits?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,qnew 创建一个真正的提交,从而调用所有相关的提交挂钩。您可以通过在应用 MQ 补丁时暂时禁用 MQ 并查看日志来亲自确认这一点。
没有办法让 pretxncommit 钩子只适用于某些命令,除非用其他钩子临时操纵某些东西:
这里我们的 pretxncommit 钩子确保在运行其(简单的)钩子之前特定文件不存在,并且 pre-/ post-qnew 挂钩创建文件并清理它。
Yes, a qnew creates a real commit and thus invokes all the relevant commit hooks. You can confirm this for yourself by temporarily disabling MQ while you have an MQ patch applied and looking at the log.
There is no way to make the pretxncommit hook apply to only some commands except by jury-rigging something with other hooks:
Here our pretxncommit hook makes sure a specific file doesn't exist before running its (trivial) hook, and the pre-/post-qnew hooks create the file and clean it up.
https://stackoverflow.com/a/19349636/350713 中的函数
abort_commit_to_wrong_branch
显示了一种仅在“真实”提交而不是 MQ 提交上运行挂钩的方法。
这个想法是检查
repo
中的属性_committingpatch
。如果
repo
具有“_committingpatch”属性,则它是正在进行的 MQ 提交。相关行是
在函数
newcommit
中提到的http://hg.intevation.org/mercurial/船员/文件/7032dcff290c/hgext/mq.py#l293
The function
abort_commit_to_wrong_branch
in https://stackoverflow.com/a/19349636/350713shows an approach to run a hook only on a "real" commit, not an MQ commit.
The idea is to check for the attribute
_committingpatch
inrepo
.If
repo
has '_committingpatch' attribute, then it is an MQ commit in progress.The relevant line is
This is mentioned in the function
newcommit
inhttp://hg.intevation.org/mercurial/crew/file/7032dcff290c/hgext/mq.py#l293
qparent/qbase 标签的或参见 WC。史密斯。就像(来自头部的脏东西,而不是来自测试的脏东西) hg id -tr 。
或者(也许是精神错乱)- 当您使用 MQ 时,您总是使用 qtip,不是吗?
of the qparent/qbase tag or see at WC. Smth. like (dirty from head, not from test) hg id -tr .
Or (maybe delirium) - when you work with MQ, you work with qtip always, sn't it?