4

如果存储库有脏子存储库,是否有任何简单的方法可以防止提交到存储库?

当子存储库与父存储库一起意外提交时,这真的很烦人。

4

2 回答 2

1

I don't know where your line for simple lands but you could do a hook like this:

for subrepo in $(find $(hg root) -type d -name .hg) ; do
  if [ "$(hg --repository ${subrepo$$.hg} status -mard)" != "" ] ; then
    echo Uncommitted subrepo changes in ${subrepo%%.hg}
    exit 1
  fi
done

Save that in something like ~/bin/dirtysubrepos and then add this to your ~/.hgrc:

[hooks]
precommit.dirtysuprepos = ~/bin/dirtysubrepos

Disclaimer: This code has never been typed anywhere except this textbox, so it almost certainly has syntax bugs.

于 2011-01-18T22:24:50.817 回答
0

出于某种原因,我无法评论 Ry4an 的答案(没有“添加评论”链接供我点击),但他的答案中有一个小错字:${subrepo$$.hg}应该是${subrepo%%.hg}.

于 2011-02-01T04:14:21.800 回答