Rev 2506: Skip past the first entry while reading, in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex

John Arbash Meinel john at arbash-meinel.com
Fri May 4 23:06:33 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex

------------------------------------------------------------
revno: 2506
revision-id: john at arbash-meinel.com-20070504220621-iwla6gmrtx7iy37s
parent: john at arbash-meinel.com-20070504214853-iqaht2z8963hdlr3
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_pyrex
timestamp: Fri 2007-05-04 17:06:21 -0500
message:
  Skip past the first entry while reading,
  rather than while processing.
modified:
  bzrlib/compiled/dirstate_helpers.pyx dirstate_helpers.pyx-20070503201057-u425eni465q4idwn-3
-------------- next part --------------
=== modified file 'bzrlib/compiled/dirstate_helpers.pyx'
--- a/bzrlib/compiled/dirstate_helpers.pyx	2007-05-04 21:48:53 +0000
+++ b/bzrlib/compiled/dirstate_helpers.pyx	2007-05-04 22:06:21 +0000
@@ -249,16 +249,18 @@
 
 
 cdef void _parse_dirblocks_0_parents(object state, object fields,
-                                     int entry_size, int pos):
+                                     int entry_size):
     cdef object current_block
     cdef object entry
     cdef void * current_dirname
     cdef int new_block
     cdef int field_count
+    cdef int pos
 
     if not PyList_CheckExact(fields):
         raise TypeError('fields must be a list')
 
+    pos = 0
     field_count = len(fields)
 
     state._dirblocks = [('', []), ('', [])]
@@ -315,6 +317,12 @@
 
     def get_all_fields(self):
         """Get a list of all fields"""
+        cdef char *first
+        # The first field should be an empty string left over from the Header
+        first = self.get_next()
+        if first[0] != c'\0':
+            raise AssertionError('First character should be null not: %s'
+                                 % (first,))
         fields = []
         while not self.done():
             PyList_Append(fields, self.get_next_str())
@@ -352,7 +360,7 @@
     fields = reader.get_all_fields()
 
     # skip the first field which is the trailing null from the header.
-    cur = 1
+    cur = 0
 
     # Each line now has an extra '\n' field which is not used
     # so we just skip over it
@@ -374,7 +382,7 @@
     if num_present_parents == 0:
         # Move the iterator to the current position
         #fields = reader.get_all_fields()
-        _parse_dirblocks_0_parents(state, fields, entry_size, 1)
+        _parse_dirblocks_0_parents(state, fields, entry_size)
         state._dirblock_state = DirState.IN_MEMORY_UNMODIFIED
         return
     if num_present_parents == 1:



More information about the bazaar-commits mailing list