Mercurial子存储库:防止意外的递归提交和推送 [英] Mercurial Subrepositories: Prevent accidental recursive commits and pushes

查看:75
本文介绍了Mercurial子存储库:防止意外的递归提交和推送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个团队中工作,我们在带有几个子存储库的Mercurial存储库中有一个代码:

main/
main/subrepo1/
main/subrepo1/subrepo2/

Mercurial的默认行为是,当在"main"中执行hg commit时,子存储库"subrepo1"和"subrepo2"中任何未完成的更改也将被提交.同样,当推送"main"时,"subrepo1"和"subrepo2"中的所有外发提交也将被推送.

我们发现人们经常无意间在其子存储库中提交和推送更改(因为他们忘记了更改,并且默认情况下hg status不会显示递归更改).我们还发现,这样的全局提交/推送在我们的团队中几乎总是偶然的.

Mercurial 1.7最近通过hg status -Shg outgoing -S改善了情况,这表明子存储库有所变化;但这仍然需要人们注意.

如果子仓库中有更改/提交会被提交/推送,Mercurial是否有办法使hg commithg push中止?

解决方案

Mercurial 2.0会自动阻止您提交子存储库,除非您手动为commit指定--subrepos(或-S)自变量.

例如,当子存储库中有待处理的更改时,您尝试执行提交,则会收到以下消息:

# hg commit -m 'change main repo'
abort: uncommitted changes in subrepo hello
(use --subrepos for recursive commit)

但是,可以通过在命令中添加--subrepos来成功执行提交:

# hg commit --subrepos -m 'commit subrepos'
committing subrepository hello

一些仍需注意的事情:如果您更改了子存储库当前的版本,但没有更改子存储库的内容,Mercurial会很乐意提交没有--subrepos标志的版本更改.此外,递归推送仍会在没有警告的情况下执行.

I work on a team where we have a code in a mercurial repository with several subrepositories:

main/
main/subrepo1/
main/subrepo1/subrepo2/

The default behavior of Mercurial is that when a hg commit is performed in "main", any outstanding changes in the subrepositories "subrepo1" and "subrepo2" will also be committed. Similarly, when "main" is pushed, any outgoing commits in "subrepo1" and "subrepo2" will also be pushed.

We find that people frequently inadvertently commit and push changes in their subrepositories (because they forgot they had made changes, and hg status by default does not show recursive changes). We also find that such global commits / pushes are almost always accidental in our team.

Mercurial 1.7 recently improved the situation with hg status -S and hg outgoing -S, which show changes in subrepositories; but still, this requires people to be paying attention.

Is there a way in Mercurial to make hg commit and hg push abort if there are changes/commits in subrepostories that would otherwise be committed/pushed?

解决方案

Mercurial 2.0 automatically prevents you from committing subrepositories unless you manually specify the --subrepos (or, alternatively, -S) argument to commit.

For example, you try to perform a commit while there are pending changes in a subrepository, you get the following message:

# hg commit -m 'change main repo'
abort: uncommitted changes in subrepo hello
(use --subrepos for recursive commit)

You can successfully perform the commit, however, by adding --subrepos to the command:

# hg commit --subrepos -m 'commit subrepos'
committing subrepository hello

Some things to still be careful about: If you have changed the revision a subrepository is currently at, but not the contents of the subrepository, Mercurial will happily commit the version change without the --subrepos flag. Further, recursive pushes are still performed without warning.

这篇关于Mercurial子存储库:防止意外的递归提交和推送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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