Rev 3222: Inner loop tweaks on index parsing. in http://people.ubuntu.com/~robertc/baz2.0/index.range_map

Robert Collins robertc at robertcollins.net
Fri Feb 8 05:03:39 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/index.range_map

------------------------------------------------------------
revno: 3222
revision-id:robertc at robertcollins.net-20080208050333-2k383gl4x7mlfahb
parent: robertc at robertcollins.net-20080208015653-igb6l64cr7mewh8v
committer: Robert Collins <robertc at robertcollins.net>
branch nick: index.range_map
timestamp: Fri 2008-02-08 16:03:33 +1100
message:
  Inner loop tweaks on index parsing.
modified:
  bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-1
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py	2008-02-08 01:56:53 +0000
+++ b/bzrlib/index.py	2008-02-08 05:03:33 +0000
@@ -876,7 +876,7 @@
         trailers = 0
         nodes = []
         for line in lines:
-            if line == '':
+            if not line:
                 # must be at the end
                 if self._size:
                     assert self._size == pos + 1, "%s %s" % (self._size, pos)
@@ -887,9 +887,11 @@
                 raise errors.BadIndexData(self)
             # keys are tuples
             key = tuple(elements[:self._key_length])
-            if first_key is None:
-                first_key = key
             absent, references, value = elements[-3:]
+            if absent:
+                self._keys_by_offset[pos] = (key, absent, (), value)
+                pos += len(line) + 1 # +1 for the \n
+                continue
             ref_lists = []
             for ref_string in references.split('\t'):
                 ref_lists.append(tuple([
@@ -898,14 +900,14 @@
             ref_lists = tuple(ref_lists)
             self._keys_by_offset[pos] = (key, absent, ref_lists, value)
             pos += len(line) + 1 # +1 for the \n
-            if absent:
-                continue
             if self.node_ref_lists:
                 node_value = (value, ref_lists)
             else:
                 node_value = value
             nodes.append((key, node_value))
             # print "parsed ", key
+        if len(nodes):
+            first_key = nodes[0][0]
         return first_key, key, nodes, trailers
 
     def _read_and_parse(self, readv_ranges):



More information about the bazaar-commits mailing list