开发者

How to save output result of hg commands in a file?

开发者 https://www.devze.com 2023-01-06 02:58 出处:网络
I 开发者_如何学JAVAam trying to save output of Mercurial commands in a file hg init > log.txt

I 开发者_如何学JAVAam trying to save output of Mercurial commands in a file

hg init > log.txt

but its not working. Any ideas?


The output might be on standard error.

Try hg init 2>&1 > log.txt.

Note: As bjlaub noted you might have to reverse the order to hg init > log.txt 2>&1 on Windows.


Are you sure the output is not simply silent by default?

hg init, for instance, rarely (if ever?) actually prints any output. Many Mercurial commands are the same way. You can often specify -v to get more verbose output, but in the case of the example you gave, I would expect an empty log.txt to appear. Have you tried other commands? If so, what exactly is not working? Do you get an empty log.txt or no log.txt at all?


I had a similar problem with hg log. With special templates the output on console worked, but when I tried to redirect into a file, no file was created.

I used the following workaround (for windows cmd): In the batch file, use a subroutine, like shown below:

call :hgInit > log.txt
goto :eof

:hgInit
hg init
goto :eof

That worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号