简体   繁体   English

Mercurial - 如何在Windows上配置多行挂钩

[英]Mercurial - How to configure multiline hook on Windows

Running Windows 7, configuring a commit hook in my .hgrc file. 运行Windows 7,在我的.hgrc文件中配置提交挂钩。

The hook calls an external powershell script and passes it a few parameters. 钩子调用外部PowerShell脚本并传递一些参数。 When I put all the parameters on one long line, the script receives them just fine. 当我将所有参数放在一个长行上时,脚本会很好地接收它们。 However, when I try to put each parameter on its own line, the hook can't figure out that they are all part of the same call to my external script. 但是,当我尝试将每个参数放在它自己的行上时,钩子无法弄清楚它们都是对我的外部脚本的同一调用的一部分。

[hooks] [钩]

commit.working_one_liner = PowerShell.exe -ExecutionPolicy Bypass -File .\MyScript.ps1 -hg %HG% -updatedToChangeset %HG_NODE% -dbName 'Test'

commit.multi_line_hook_not_working = PowerShell.exe 
    -ExecutionPolicy Bypass
    -File .\MyScript.ps1
    -hg %HG%
    -updatedToChangeset %HG_NODE%
    -dbName 'Test'

According to the Hg documentation , I should be able to do this: 根据Hg文档 ,我应该能够这样做:

"A configuration file consists of sections, led by a [section] header and followed by name = value entries (sometimes called configuration keys): “配置文件由部分组成,由[section]标头引导,后跟name = value条目(有时称为配置键):

[spam]
eggs=ham
green=
   eggs

Each line contains one entry. 每行包含一个条目。 If the lines that follow are indented, they are treated as continuations of that entry. 如果后面的行是缩进的,则将它们视为该条目的延续。 Leading whitespace is removed from values. 从值中删除前导空格。 Empty lines are skipped. 空行被跳过。 Lines beginning with # or ; 以#或;开头的行 are ignored and may be used to provide comments." 被忽略,可能用于提供评论。“

Despite indenting, the multi_line_hook seems to ignore everything after the first line. 尽管缩进,但multi_line_hook似乎忽略了第一行之后的所有内容。 I've tried various escape characters (`, ^, \\, etc.) after each new line. 我在每一行后尝试了各种转义字符(`,^,\\等)。 Any ideas what I'm missing here? 我在这里缺少什么想法?

The example from the documentation only works for the first line to follow and not the rest. 文档中的示例仅适用于第一行,而不适用于其余行。

I don't have access to windows at the moment, but on linux I need to use a backslash: 我目前无法访问Windows,但在linux上我需要使用反斜杠:

 [hooks] commit.working = echo \\ test 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM