如何使用 Mercurial 挂钩的相对路径名
我的工作副本顶层有一个脚本,我想将其用作 Mercurial 挂钩。如果我使用钩子的绝对路径名,那么一切都很好,但我想要一个相对路径名,这样整个东西就可以轻松移动,在其他工作副本中使用,并且其他开发人员可以按原样复制 hgrc。
/space/project/.hg/hgrc 包含
[hooks]
update = genid
genid 脚本位于 /space/project/genid
如果我在 /space/project 中,但如果我当前目录是 /space/project/src/tools 则调用钩子就好了'hg update' 将给出错误,因为找不到钩子。
I have a script that is in the top level of my working copy and would like to use it as a Mercurial hook. If I use an absolute pathname to the hook then everything is fine, but I want a relative pathname so the whole thing can be easily moved around, used in other working copies and other developers can copy the hgrc as is.
/space/project/.hg/hgrc contains
[hooks]
update = genid
The genid script is at /space/project/genid
The hook is invoked just fine if I am in /space/project but if my current directory is /space/project/src/tools then 'hg update' will give an error as the hook cannot be found.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Python 挂钩不能使用相对路径。脚本钩子可以像这样:
Python hooks cannot use a relative path. Script hooks can like this:
在某些情况下,环境变量会在 Mercurial 配置中扩展。所以你可以检查一下是否可以使用环境变量。
请参阅 https://www.mercurial-scm.org/wiki/TipsAndTricks< 中的常见问题解答 (12) /a>
In certain cases, environment variables are expanded in mercurial configuration. So you can check out if you can use a environment variable.
See Faq (12) in https://www.mercurial-scm.org/wiki/TipsAndTricks
我有同样的问题并且无法解决。不过解决方法很简单!我在存储库中对文件进行了版本控制,并将其复制到我的 .hg 文件夹中!不理想,但不太可能更改,其他存储库用户仍然可以获得该文件的副本
I had the same problem and couldnt resolve it. The workaround was easy though! I versioned the file in the repo and just copied it to my .hg folder! Not ideal but it isnt that likely to change and other repo users can still get a copy of the file