善变的 - 我想添加一些自定义的code被运行后提交 [英] mercurial - I want to add some custom code to be run after commit
问题描述
我在哪里可以放置后,每犯我做与善变code来运行?具体来说,我想保持一个名为最新的在我的项目的根.hg文件夹内 - 该文件将持有的版本号和散列code为最近提交。基于同样的话题,我怎么能得到那些在python?
where could I place code to be run after every commit I make with mercurial? Specifically, I would like to maintain a file called latest inside the .hg folder in the root of my project - that file will hold the revision number and hash code for the most recent commit. On that same topic, how can I get those in python?
# get mercurial version hash
ver = ?
# get mercurial revision number
rev = ?
# is there a shortcut to this folder through mercurial?
f = open('/path/to/.hg/latest', 'w')
f.write('ver=%s\nrev=%d' % ( str(ver), int(rev) ) )
f.close
修改:
我能够完成上述带有挂钩(在.hg / hgrc):
EDIT: I was able to accomplish the above with hooks (in .hg/hgrc):
[hooks]
precommit= echo node=`hg tip --template {node}` > tip && echo rev=`hg tip --template {rev}` >> tip && hg add tip
与尖端信息的文件创建成功,但我也想将其添加到当前与提交汞添加提示
,这就是善变的进程得到坚持等待由未决显然举行提交的锁。有没有办法来解决它使得在/ pre创建的文件提交被添加到了吗?谢谢。
The file with the tip info is created successfully, but I would also like to add it to the current commit with hg add tip
, which is where the mercurial process gets stuck waiting for the lock apparently held by the pending commit. Is there a way to work around it such that the file created during/pre commit is added to it? thanks.
推荐答案
的 http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html
具体你似乎想提交钩子其中有一个教程
specifically you seem to want the commit hook which there is a tutorial for
当然,这听起来像你真正想要的是汞尖
of course it sounds like what you really want is hg tip
这篇关于善变的 - 我想添加一些自定义的code被运行后提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!