diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -787,10 +787,14 @@ class localrepository(repo.repository): # check subrepos subs = [] + removedsubs = set() + for p in wctx.parents(): + removedsubs.update(s for s in p.substate if match(s)) for s in wctx.substate: + removedsubs.discard(s) if match(s) and wctx.sub(s).dirty(): subs.append(s) - if subs and '.hgsubstate' not in changes[0]: + if (subs or removedsubs) and '.hgsubstate' not in changes[0]: changes[0].insert(0, '.hgsubstate') # make sure all explicit patterns are matched @@ -830,7 +834,7 @@ class localrepository(repo.repository): edited = (text != cctx._text) # commit subs - if subs: + if subs or removedsubs: state = wctx.substate.copy() for s in subs: self.ui.status(_('committing subrepository %s\n') % s) diff --git a/tests/test-subrepo b/tests/test-subrepo --- a/tests/test-subrepo +++ b/tests/test-subrepo @@ -162,6 +162,28 @@ hg up 5 hg merge 4 # try to merge default into br again cd .. +echo % test subrepo delete from .hgsubstate +hg init testdelete +mkdir testdelete/nested testdelete/nested2 +hg init testdelete/nested +hg init testdelete/nested2 +echo test > testdelete/nested/foo +echo test > testdelete/nested2/foo +hg -R testdelete/nested add +hg -R testdelete/nested2 add +hg -R testdelete/nested ci -m test +hg -R testdelete/nested2 ci -m test +echo nested = nested > testdelete/.hgsub +echo nested2 = nested2 >> testdelete/.hgsub +hg -R testdelete add +hg -R testdelete ci -m "nested 1 & 2 added" +echo nested = nested > testdelete/.hgsub +hg -R testdelete ci -m "nested 2 deleted" +cat testdelete/.hgsubstate | sed "s:.* ::" +hg -R testdelete remove testdelete/.hgsub +hg -R testdelete ci -m ".hgsub deleted" +cat testdelete/.hgsubstate + echo % test repository cloning mkdir mercurial mercurial2 hg init nested_absolute diff --git a/tests/test-subrepo.out b/tests/test-subrepo.out --- a/tests/test-subrepo.out +++ b/tests/test-subrepo.out @@ -247,6 +247,13 @@ committing subrepository s 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) +% test subrepo delete from .hgsubstate +adding testdelete/nested/foo +adding testdelete/nested2/foo +adding testdelete/.hgsub +committing subrepository nested2 +committing subrepository nested +nested % test repository cloning adding nested_absolute/foo adding nested_relative/foo2