Mercurial: blocks if subrepos is dirty?

Is there any easy way to prevent committing to the repository if it has dirty subrepos?

This is really annoying when subrepo is accidentally passed along with the parent repository.

+4
source share
2 answers

I do not know where your line is for simple lands, but you can make such a hook:

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 this somehow as ~/bin/dirtysubrepos , and then add it to your ~/.hgrc :

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

Disclaimer: This code has never been entered anywhere other than this text field, so it almost certainly has syntax errors.

+1
source

I cannot comment on Ry4an's answer for any reason (there is no โ€œAdd Commentโ€ link for me to click), but there is a small typo in his answer: there is ${subrepo$$.hg} , which should be ${subrepo%%.hg} .

0
source

Source: https://habr.com/ru/post/1336060/


All Articles