Is there any simple way to prevent commits to a repository if it has dirty subrepos?
It's really annoying when a subrepo is accidentally committed along with a parent repository.
Is there any simple way to prevent commits to a repository if it has dirty subrepos?
It's really annoying when a subrepo is accidentally committed along with a parent repository.
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.
I can't comment on Ry4an's answer for some reason (no "Add comment" link for me to click on), but there's a minor typo in his answer: there's an ${subrepo$$.hg}
that should be ${subrepo%%.hg}
.