Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 14536:52cbeb5a651b
subrepo: be more careful with deletions of .hgsub and .hgsubstate (issue2844)
We shouldn't try to process subrepos if .hgsub isn't present and we
should remove .hgsubstate if .hgsub is marked for removal.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 06 Jun 2011 15:17:40 -0500 |
parents | e7a1814854b9 |
children | 48ec0763afbb |
line wrap: on
line diff
--- a/mercurial/localrepo.py Sun Jun 05 22:26:01 2011 +0200 +++ b/mercurial/localrepo.py Mon Jun 06 15:17:40 2011 -0500 @@ -944,18 +944,28 @@ # 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 or removedsubs): - 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') + if '.hgsub' in wctx: + # only manage subrepos and .hgsubstate if .hgsub is present + 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 or removedsubs): + 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') + if '.hgsubstate' in changes[2]: + changes[2].remove('.hgsubstate') + elif '.hgsub' in changes[2]: + # clean up .hgsubstate when .hgsub is removed + if ('.hgsubstate' in wctx and + '.hgsubstate' not in changes[0] + changes[1] + changes[2]): + changes[2].insert(0, '.hgsubstate') if subs and not self.ui.configbool('ui', 'commitsubrepos', True): changedsubs = [s for s in subs if wctx.sub(s).dirty(True)]