问题描述
在某些情况下,我需要强制Mercurial用户在允许任何hg commit
之前运行hg pull -u
,即hg pull
表示传入队列为空—而且我也希望该人正在使用分支的头部版本.
I have in some cases a need to enforce that Mercurial-users have run hg pull -u
before any hg commit
can be allowed, i.e., hg pull
will mean that the incoming queue is empty — and furthermore I also want that the person is using the head version of the branch.
如何设置这样的限制?
(我完全意识到这与DVCS设计核心的某些部分背道而驰)
(I am fully aware that this goes against parts of the DVCS design core)
推荐答案
您可以要求开发人员进行安装
You could ask your developers to install
[hooks]
pre-commit = hg pull -u
在其配置文件中(由于此工作流程是特定于存储库的,因此可能应安装在每个存储库的.hg/hgrc
文件中.)
in their config files (it should probably be installed in the per-repository .hg/hgrc
file since this workflow is repository specific).
这使Mercurial有点像Subversion:您的开发人员将只有一个出色的变更集.但是请注意,只要有人推送到服务器,hg pull -u
就无法更新到新的分支提示,因为它将跨分支(拓扑分支)这样做.因此,此时需要适当的合并(或重新设置,请参见hg pull --rebase
).
This makes Mercurial a little Subversion-like: your developers will only have one outstanding changeset. But note as soon as someone pushes to the server, hg pull -u
cannot update to the new branch tip since it will cross branches (topological branches) to do so. So a proper merge will be needed at that point (or a rebase, see hg pull --rebase
).
这篇关于Mercurial:强制执行"hg pull -u"在"hg commit"之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!