Mercurial > public > mercurial-scm > hg-stable
diff mercurial/subrepo.py @ 13174:be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
This patch prevents MQ from creating an inconsistent subrepo state. If
the .hgsub file has been changed, and none of the subrepos have
uncommitted changes, creating or updating a patch (using qnew, qrefresh,
or qrecord) will update .hgsubstate accordingly.
If any subrepos _do_ have uncommitted changes, qnew/qrefresh/qrecord
will abort.
Thanks to pmezard for proposing this solution.
author | Kevin Bullock <kbullock@ringworld.org> |
---|---|
date | Tue, 07 Dec 2010 22:14:43 -0600 |
parents | 84cec5895d01 |
children | c4d857f5405d |
line wrap: on
line diff
--- a/mercurial/subrepo.py Tue Dec 07 22:14:43 2010 -0600 +++ b/mercurial/subrepo.py Tue Dec 07 22:14:43 2010 -0600 @@ -236,9 +236,10 @@ class abstractsubrepo(object): - def dirty(self): - """returns true if the dirstate of the subrepo does not match - current stored state + def dirty(self, ignoreupdate=False): + """returns true if the dirstate of the subrepo is dirty or does not + match current stored state. If ignoreupdate is true, only check + whether the subrepo has uncommitted changes in its dirstate. """ raise NotImplementedError @@ -390,12 +391,13 @@ s = subrepo(ctx, subpath) s.archive(ui, archiver, os.path.join(prefix, self._path)) - def dirty(self): + def dirty(self, ignoreupdate=False): r = self._state[1] - if r == '': + if r == '' and not ignoreupdate: # no state recorded return True w = self._repo[None] - if w.p1() != self._repo[r]: # version checked out change + # version checked out changed? + if w.p1() != self._repo[r] and not ignoreupdate: return True return w.dirty() # working directory changed @@ -538,9 +540,10 @@ return True, True return bool(changes), False - def dirty(self): - if self._wcrev() == self._state[1] and not self._wcchanged()[0]: - return False + def dirty(self, ignoreupdate=False): + if not self._wcchanged()[0]: + if self._wcrev() == self._state[1] and not ignoreupdate: + return False return True def commit(self, text, user, date):