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,我想这真的是两个问题: 如何获取更新挂钩以执行以下操作: hg heads--template'version{tags}\tbuild{rev}.{node | short}\t于{date | shortdate}提交 简单地说:update=在hgrc文件的[hooks]部分,似乎不起作用 如何将上述输出重定向到文本文件?添加>log.txt或|log.txt根本不起作用 我确信这是非常基础的,我的命令行知识也是非常基础的——我今天早上刚刚学习了上面所有的命令 顺便说一句,如果有帮助的话,

我想这真的是两个问题:

  • 如何获取更新挂钩以执行以下操作:
  • hg heads--template'version{tags}\tbuild{rev}.{node | short}\t于{date | shortdate}提交

    简单地说:
    update=
    在hgrc文件的
    [hooks]
    部分,似乎不起作用

  • 如何将上述输出重定向到文本文件?添加
    >log.txt
    |log.txt
    根本不起作用
  • 我确信这是非常基础的,我的命令行知识也是非常基础的——我今天早上刚刚学习了上面所有的命令

    顺便说一句,如果有帮助的话,我正在运行OrtoiseHG2.6.1和Mercurial 2.4.1

  • 钩子可以实现为外部程序或内部python调用

    i、 e您不能在[hooks]部分直接编写
    hg命令,但可以在shell脚本中编写yjis命令,该脚本在hook中调用。差不多

    [hooks]
    update = updatehook
    
    使用路径中的
    updatehook.sh
    |
    updatehook.bat
    (或脚本的完整路径),其中您将

    hg heads --template "version {tags}\tbuild {rev}.{node|short}\tcommitted on {date|shortdate}\n" > SOMEPATH/log.txt
    
    (注意:在模板末尾添加了
    \n
    ——对于多头存储库,需要它)


    太棒了,非常感谢你!我确实读过关于将钩子实现为外部程序的文章,但显然不理解它的含义。我知道,我很慢。但你的解释很清楚,我现在明白了。再次感谢。
    >hg heads --template "version {tags}\tbuild {rev}.{node|short}\tcommitted on {date|shortdate}\n"
    version default/2.0 tip build 4638.4a48cef94e2e committed on 2014-12-24
    version default/master  build 4620.de0053588acf committed on 2014-12-23
    version default/1.6     build 2344.fc32e948fcba committed on 2013-01-06