Mercurial > public > mercurial-scm > hg
diff hgext/mq.py @ 14010:d7b4d421b56c
mq: prevent traceback when qfinish patches not in series.
When mq status entry referencing a patches that is not in series `hg qfinish
-a` used to issue a traceback. This states is inconsistent but might happen
regularly when people misuse hg up -mq.
This changeset prevent hg from crashing. The faulty entry is finished anyway and
a warning is issued.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 25 Apr 2011 14:03:12 +0200 |
parents | d13913355390 |
children | 4f19242dac6c |
line wrap: on
line diff
--- a/hgext/mq.py Mon Apr 25 13:03:26 2011 +0300 +++ b/hgext/mq.py Mon Apr 25 14:03:12 2011 +0200 @@ -737,11 +737,29 @@ os.unlink(self.join(p)) if numrevs: + qfinished = self.applied[:numrevs] del self.applied[:numrevs] self.applied_dirty = 1 - for i in sorted([self.find_series(p) for p in patches], reverse=True): - del self.full_series[i] + unknown = [] + + for (i, p) in sorted([(self.find_series(p), p) for p in patches], + reverse=True): + if i is not None: + del self.full_series[i] + else: + unknown.append(p) + + if unknown: + if numrevs: + rev = dict((entry.name, entry.node) for entry in qfinished) + for p in unknown: + msg = _('revision %s refers to unknown patches: %s\n') + self.ui.warn(msg % (short(rev[p]), p)) + else: + msg = _('unknown patches: %s\n') + raise util.Abort(''.join(msg % p for p in unknown)) + self.parse_series() self.series_dirty = 1