Rev 3066: Use iter_records_from_file rather than ContainerReader to make bundle in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Dec 3 01:20:15 GMT 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3066
revision-id:pqm at pqm.ubuntu.com-20071203012007-1tfytfzp7piacl7q
parent: pqm at pqm.ubuntu.com-20071202151118-zcl7ezt2c7k5rkos
parent: andrew.bennetts at canonical.com-20071110151108-u50wd5e732aeerl9
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2007-12-03 01:20:07 +0000
message:
  Use iter_records_from_file rather than ContainerReader to make bundle
  	reading a bit faster. (Andrew Bennetts)
modified:
  bzrlib/bundle/serializer/v4.py v10.py-20070611062757-5ggj7k18s9dej0fr-1
    ------------------------------------------------------------
    revno: 2916.2.18
    revision-id:andrew.bennetts at canonical.com-20071110151108-u50wd5e732aeerl9
    parent: andrew.bennetts at canonical.com-20071110145614-bxpv031fq77cjg5j
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: faster-bundles
    timestamp: Sat 2007-11-10 10:11:08 -0500
    message:
      Use iter_records_from_file rather than ContainerReader.
    modified:
      bzrlib/bundle/serializer/v4.py v10.py-20070611062757-5ggj7k18s9dej0fr-1
=== modified file 'bzrlib/bundle/serializer/v4.py'
--- a/bzrlib/bundle/serializer/v4.py	2007-11-10 14:53:13 +0000
+++ b/bzrlib/bundle/serializer/v4.py	2007-11-10 15:11:08 +0000
@@ -160,14 +160,17 @@
             source_file = iterablefile.IterableFile(self.iter_decode(fileobj))
         else:
             source_file = StringIO(bz2.decompress(fileobj.read()))
-        self._container = pack.ContainerReader(source_file)
+        self._container_file = source_file
 
     @staticmethod
     def iter_decode(fileobj):
         """Iterate through decoded fragments of the file"""
         decompressor = bz2.BZ2Decompressor()
         for line in fileobj:
-            yield decompressor.decompress(line)
+            try:
+                yield decompressor.decompress(line)
+            except EOFError:
+                return
 
     @staticmethod
     def decode_name(name):
@@ -199,17 +202,16 @@
         :return: a generator of (bytes, metadata, content_kind, revision_id,
             file_id)
         """
-        iterator = self._container.iter_records()
-        for names, meta_bytes in iterator:
+        iterator = pack.iter_records_from_file(self._container_file)
+        for names, bytes in iterator:
             if len(names) != 1:
                 raise errors.BadBundle('Record has %d names instead of 1'
                                        % len(names))
-            metadata = bencode.bdecode(meta_bytes(None))
+            metadata = bencode.bdecode(bytes)
             if metadata['storage_kind'] == 'header':
                 bytes = None
             else:
                 _unused, bytes = iterator.next()
-                bytes = bytes(None)
             yield (bytes, metadata) + self.decode_name(names[0][0])
 
 




More information about the bazaar-commits mailing list