# HG changeset patch # User Alexis S. L. Carvalho # Date 1202079826 7200 # Node ID b4858eb4b58f88e2df9366db167dbb3c8fa2327b # Parent 7939c71f3132ec79f420e79302c0a81cb447f20d mqrepo: don't abort if the status file has an unknown node diff -r 7939c71f3132 -r b4858eb4b58f hgext/mq.py --- a/hgext/mq.py Sun Feb 03 21:03:46 2008 -0200 +++ b/hgext/mq.py Sun Feb 03 21:03:46 2008 -0200 @@ -2096,6 +2096,12 @@ return tagscache mqtags = [(revlog.bin(patch.rev), patch.name) for patch in q.applied] + + if mqtags[-1][0] not in self.changelog.nodemap: + self.ui.warn('mq status file refers to unknown node %s\n' + % revlog.short(mqtags[-1][0])) + return tagscache + mqtags.append((mqtags[-1][0], 'qtip')) mqtags.append((mqtags[0][0], 'qbase')) mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent')) @@ -2112,11 +2118,17 @@ if not q.applied: return super(mqrepo, self)._branchtags() + cl = self.changelog + qbasenode = revlog.bin(q.applied[0].rev) + if qbasenode not in cl.nodemap: + self.ui.warn('mq status file refers to unknown node %s\n' + % revlog.short(qbasenode)) + return super(mqrepo, self)._branchtags() + self.branchcache = {} # avoid recursion in changectx - cl = self.changelog partial, last, lrev = self._readbranchcache() - qbase = cl.rev(revlog.bin(q.applied[0].rev)) + qbase = cl.rev(qbasenode) start = lrev + 1 if start < qbase: # update the cache (excluding the patches) and save it diff -r 7939c71f3132 -r b4858eb4b58f tests/test-mq --- a/tests/test-mq Sun Feb 03 21:03:46 2008 -0200 +++ b/tests/test-mq Sun Feb 03 21:03:46 2008 -0200 @@ -297,6 +297,13 @@ echo % mq tags hg log --template '{rev} {tags}\n' -r qparent:qtip +echo % bad node in status +hg qpop +hg strip -qn tip +hg tip 2>&1 | sed -e 's/unknown node .*/unknown node/' +hg branches 2>&1 | sed -e 's/unknown node .*/unknown node/' +hg qpop + cat >>$HGRCPATH <