diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -826,8 +826,13 @@ class localrepository(repo.repository): removedsubs.discard(s) if match(s) and wctx.sub(s).dirty(): subs.append(s) - if (subs or removedsubs) and '.hgsubstate' not in changes[0]: - changes[0].insert(0, '.hgsubstate') + if (subs or removedsubs): + # is hgsub modified and not included? + if (not match('.hgsub') and + '.hgsub' in (wctx.modified() + wctx.added())): + raise util.Abort("can't commit subrepos without .hgsub") + if '.hgsubstate' not in changes[0]: + changes[0].insert(0, '.hgsubstate') # make sure all explicit patterns are matched if not force and match.files(): diff --git a/tests/test-subrepo b/tests/test-subrepo --- a/tests/test-subrepo +++ b/tests/test-subrepo @@ -15,12 +15,15 @@ echo s = s > .hgsub hg add .hgsub hg init s echo a > s/a + +# issue2232 - committing a subrepo without .hgsub +hg ci -mbad s + hg -R s ci -Ams0 hg sum hg ci -m1 # issue 2022 - update -C - echo b > s/a hg sum hg co -C 1 diff --git a/tests/test-subrepo.out b/tests/test-subrepo.out --- a/tests/test-subrepo.out +++ b/tests/test-subrepo.out @@ -1,6 +1,7 @@ % first revision, no sub adding a % add first sub +abort: can't commit subrepos without .hgsub adding a parent: 0:f7b1eb17ad24 tip 0