Mercurial挂钩无法正常执行 [英] Mercurial hook not executing properly

查看:71
本文介绍了Mercurial挂钩无法正常执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行这应该是一件非常简单的事情,但是由于某种原因,它将无法与我的Mercurial存储库一起使用.我只想让远程存储库在有人按下时自动运行hg update.所以我的.hg/hgrc文件中有这个文件:

This should be a very simple thing to have run, but for some reason it won't work with my Mercurial repository. All I want is for the remote repo to automatically run hg update whenever someone pushes to it. So I have this in my .hg/hgrc file:

[hook]
changegroup = hg update

简单,对吧?但是由于某种原因,它永远不会执行.我还尝试编写执行此操作的shell脚本. .hg/hgrc看起来像这样:

Simple, right? But for some reason, this never executes. I also tried writing a shell script that did this. .hg/hgrc looked like this:

[hooks]
changegroup = /home/marc/bin/hg-update

和hg-update看起来像这样:

and hg-update looked like this:

#!/bin/sh
hg help >> /home/marc/works.txt;
hg update >> /home/marc/works.txt;
exit 0;

但是,这不会更新. hg help的内容被写到works.txt,但是对于hg update则什么也不写.有什么明显的我想念的地方吗?这已经困扰了我好几天了,但我似乎无法使其正常工作.

But again, this doesn't update. The contents of hg help are written out to works.txt, but nothing is written out for hg update. Is there something obvious I'm missing here? This has been plaguing me for days and I just can't seem to get it to work.

更新

再次如此,即使我在.hg/hgrc中有这些echo行,在我的工作站上使用命令行上的-v开关推送到远程仓库也不会打印任何冗长的消息.但是,当我从同一文件系统上的存储库克隆中进行推送时(我通过SSH登录),这就是我得到的:

Okay so again, using the -v switch on the command line from my workstation pushing to the remote repo doesn't print any verbose messages even when I have those echo lines in .hg/hgrc. However, when I do a push from a clone of the repo on the same filesystem (I'm logged in via SSH), this is what I get:


bash-3.00$ hg -v push ../test-repo/
pushing to ../test-repo/
searching for changes
1 changesets found
running hook prechangegroup: echo "Remote repo is at `hg tip -q`"
echo "Remote repo wdir is at `hg parents -q`"
Remote repo is at 821:1f2656753c98
Remote repo wdir is at 821:1f2656753c98
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
running hook changegroup: echo "Updating.... `hg update -v`"
echo "Remote repo is at `hg tip -q`"
echo "Remote repo wdir is at `hg parents -q`"
Updating.... resolving manifests
getting license.txt
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Remote repo is at 822:389a6c7276c6
Remote repo wdir is at 822:389a6c7276c6

所以它可以工作,但是只有当我从同一个文件系统中推送时,它才能再次工作.如果我尝试通过网络从另一个工作站推送到存储库,则无法使用.

So it works, but again only when I push from the same filesystem. It doesn't work if I try pushing to the repo from another workstation over the network.

推荐答案

我花了一些时间自己研究一下.我认为问题的答案已简要描述

I spent some time researching this myself. I think the answer to problem is described concisely here:

由于stdout,输出必须重定向到stderr(或/dev/null) 用于数据流.

Output has to be redirected to stderr (or /dev/null), because stdout is used for the data stream.

基本上,您没有重定向到stderr,因此污染了stdout.

Basically, you're not redirecting to stderr, and hence polluting stdout.

这篇关于Mercurial挂钩无法正常执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆