【问题标题】:A Mercurial update hook to send certain data to a text file用于将某些数据发送到文本文件的 Mercurial 更新挂钩
【发布时间】:2014-12-24 18:49:41
【问题描述】:

我猜这真的是 2 个问题:

  1. 如何获取更新挂钩来执行以下操作:

hg heads --template 'version {tags}\tbuild {rev}.{node|short}\tcommitted on {date|shortdate}'

简单地将:update = <above command> 放在 hgrc 文件的 [hooks] 部分,似乎不起作用。

  1. 如何将上面的输出重定向到文本文件?附加 > log.txt| log.txt 根本不起作用

我确定这是非常基础的,而且我的命令行知识也非常基础 - 我今天早上刚刚学会了上述所有命令!

顺便说一句,如果有帮助,我正在运行 TortoiseHg 2.6.1 和 Mercurial 2.4.1

【问题讨论】:

    标签: mercurial mercurial-hook


    【解决方案1】:
    1. 根据Hooks wiki-page

    Hooks 可以作为外部程序或内部 python 调用来实现。

    我,你不能直接在 [hooks] 部分写hg COMMAND,但可以在 shell-script 中写 yjis 命令,在钩子中调用。类似的东西

    [hooks]
    update = updatehook
    

    updatehook.sh | updatehook.bat 在 PATH 中(或带有脚本的完整路径),您可以在其中作为主要部分

    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
    

    【讨论】:

    • 太棒了,非常感谢!我确实读过关于将钩子实现为外部程序的内容,但显然没有理解它的含义。我知道,我很慢。但是您的解释清晰简洁,我现在明白发生了什么。再次感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-19
    • 2014-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多