Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 13411:d4de90a612f7
commit: abort if a subrepo is modified and ui.commitsubrepos=no
The default behaviour is to commit subrepositories with uncommitted changes. In
my experience this is usually undesirable:
- Changes to dependencies are often debugging leftovers
- Real changes should generally be applied on the source project directly,
tested then committed. This is not always possible, subversion subrepos may
include only a small part of the source project, without the tests.
Setting ui.commitsubrepos=no will now abort commits containing such modified
subrepositories like:
$ hg --config ui.commitsubrepos=no ci -m msg
abort: uncommitted changes in subrepo sub
I ruled out the hook solution because it does not easily take --include/exclude
options in account. Also, my main concern is whether this flag could cause
problems with extensions. If there are legitimate reasons for callers to
override this behaviour (I could not find any), they might either override at ui
level, or we could add an argument to localrepo.commit() later.
v2:
- Renamed ui.commitsubs to ui.commitsubrepos
- Mention the configuration entry in hg help subrepos
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Tue, 15 Feb 2011 22:25:48 +0100 |
parents | 14f3795a5ed7 |
children | 58c497d0e44d |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Feb 15 16:19:11 2011 -0600 +++ b/mercurial/localrepo.py Tue Feb 15 22:25:48 2011 +0100 @@ -933,6 +933,12 @@ if '.hgsubstate' not in changes[0]: changes[0].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)] + if changedsubs: + raise util.Abort(_("uncommitted changes in subrepo %s") + % changedsubs[0]) + # make sure all explicit patterns are matched if not force and match.files(): matched = set(changes[0] + changes[1] + changes[2])