changeset 5979:b4858eb4b58f

mqrepo: don't abort if the status file has an unknown node
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sun, 03 Feb 2008 21:03:46 -0200
parents 7939c71f3132
children dcda0c90125c
files hgext/mq.py tests/test-mq tests/test-mq.out
diffstat 3 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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 <<EOF
 [diff]
 git = True
--- a/tests/test-mq.out	Sun Feb 03 21:03:46 2008 -0200
+++ b/tests/test-mq.out	Sun Feb 03 21:03:46 2008 -0200
@@ -281,6 +281,18 @@
 0 qparent
 1 qbase foo
 2 qtip bar tip
+% bad node in status
+Now at: foo
+changeset:   0:cb9a9f314b8b
+mq status file refers to unknown node
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     a
+
+mq status file refers to unknown node
+default                        0:cb9a9f314b8b
+abort: working directory revision is not qtip
 new file
 
 diff --git a/new b/new