3

我想要一个 mercurial 钩子,它将在所有修改的文件上运行 JSLint/PyChecker/etc。但是,我无法控制所有 hg 客户端,并且希望它在推送到主存储库(我可以控制)时运行,因此在主存储库上使用 pretxnchangegroup 挂钩似乎是最好的。

如何获取将要提交的变更组中的所有变更集的列表?

我似乎有其他使用预提交钩子的解决方案,但这些对我不起作用,因为客户端可能已经有一个失败的 JSLint 提交。在这种情况下,他们应该能够修复新提交中的错误,并能够成功推送(错误提交和新提交)到服务器。服务器只需要检查每个分支上的最新变更集,以及在变更组中修改的每个文件。

4

3 回答 3

4

You're right that you want a pretxnchangegroup hook, but you don't want to check all the new revisions -- because people will fix the errors you reject in subsequent changesets but if you're checking all changesets their work will never be accepted!

Instead either just check all files in all the heads, or use the hg status --rev x:y syntax to get a list of the changed files between the revision you already have and the tip revision you're receiving, and check only those files only in the tip revision.

If you really want the list of all revisions you'd use a revset ( hg help revsets ) new in version 1.6, but you really only want to check the results, not all the revisions that get you there.

于 2010-09-01T19:42:15.620 回答
3

我刚刚写了一个 pretxnchangegroup 钩子来做这个。如果您想要当前更改组中所有已更改的文件,您可以获取这两个命令的输出的并集:

hg status --rev $HG_NODE:

(注意尾随冒号)

hg status --change $HG_NODE

在同一台机器上的两个存储库之间推送时,第一个命令似乎就足够了,但是当推送到远程存储库时,第一个命令会丢失更改组中第一个变更集中更改的文件,这是第二个命令的来源。

根据http://www.selenic.com/mercurial/hgrc.5.html,“第一个新变更集的 ID 在 $HG_NODE 中。”

于 2011-02-08T09:05:51.790 回答
0

我对此的回答是否有帮助? https://stackoverflow.com/a/8615156/1025457

它是一个 pretxnchangegroup 钩子的骨架,它遍历 changegroup 中的节点

于 2011-12-23T12:18:15.663 回答