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 changegroup挂钩-指定最近的节点_Mercurial_Hook_Mercurial Hook - Fatal编程技术网

mercurial changegroup挂钩-指定最近的节点

mercurial changegroup挂钩-指定最近的节点,mercurial,hook,mercurial-hook,Mercurial,Hook,Mercurial Hook,我想使用mercurial钩子在开发人员从本地repo推送到中心远程repo时触发回归构建(在Jenkins中) 在路径/to/repo/.hg/hgrc中 [hooks] changegroup = python:jenkins.py:trigger_build 和jenkins.py: def trigger_build(ui, repo, source, hooktype, node, **Kwargs): ... changeset_to_build = node

我想使用mercurial钩子在开发人员从本地repo推送到中心远程repo时触发回归构建(在Jenkins中)

在路径/to/repo/.hg/hgrc中

[hooks]
changegroup = python:jenkins.py:trigger_build
和jenkins.py:

def trigger_build(ui, repo, source, hooktype, node, **Kwargs):
    ...
    changeset_to_build = node
    ...
但在本例中,节点指的是变更组中最早的变更集,我想开始构建和测试最新的变更集。我有一个变通方法,使用:

def trigger_build(ui, repo, source, hooktype, node, **Kwargs):
    ...
    changeset_to_build = repo['default'].hex()
    ...
这会得到适当的变更集,但我不确定这是最好的方法。有没有比这更标准的习语我不知道


谢谢

在我看来,
repo['default']
始终是默认分支机构的负责人。如果开发人员希望为其他分支生成,或者默认分支未命名为default,那么这可能是一个问题

在基于bash和的钩子中,我将使用以下内容:

#!/bin/bash
changeset_to_build=$(hg log --rev "heads(${HG_NODE}:)" --limit 1 --template "{node}")

这将是第一个在HG_节点和tip之间没有子变更集的节点;因此,即使变更组没有在默认分支中启动,jenkins也应该构建变更组的负责人。

谢谢您的回答。恐怕我不再在出现这个问题的环境中工作了,所以我不能肯定这个解决方案是否合适,但它的逻辑看起来是正确的。