revlog: always add the magic nullid/nullrev entry in parseindex
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sat, 15 Jan 2011 13:02:19 +0100
changeset 13265 04b302ce2781
parent 13264 8439526fb407
child 13266 a5db81b5d3e9
revlog: always add the magic nullid/nullrev entry in parseindex
mercurial/revlog.py
--- a/mercurial/revlog.py	Sat Jan 15 15:04:58 2011 +0100
+++ b/mercurial/revlog.py	Sat Jan 15 13:02:19 2011 +0100
@@ -143,6 +143,9 @@
             nodemap[e[6]] = n
             n += 1
 
+        # add the magic null revision at -1
+        index.append((0, 0, 0, -1, -1, -1, -1, nullid))
+
         return index, nodemap, None
 
     def packentry(self, entry, node, version, rev):
@@ -262,20 +265,15 @@
         self._io = revlogio()
         if self.version == REVLOGV0:
             self._io = revlogoldio()
-        if i:
-            try:
-                d = self._io.parseindex(i, self._inline)
-            except (ValueError, IndexError):
-                raise RevlogError(_("index %s is corrupted") % (self.indexfile))
-            self.index, n, self._chunkcache = d
-            if n:
-                self.nodemap = n
-            if not self._chunkcache:
-                self._chunkclear()
-
-        # add the magic null revision at -1 (if it hasn't been done already)
-        if self.index == [] or self.index[-1][7] != nullid:
-            self.index.append((0, 0, 0, -1, -1, -1, -1, nullid))
+        try:
+            d = self._io.parseindex(i, self._inline)
+        except (ValueError, IndexError):
+            raise RevlogError(_("index %s is corrupted") % (self.indexfile))
+        self.index, n, self._chunkcache = d
+        if n:
+            self.nodemap = n
+        if not self._chunkcache:
+            self._chunkclear()
 
     @util.propertycache
     def nodemap(self):