~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/multiparent.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-08-24 23:20:14 UTC
  • mfrom: (5365.5.29 2.3-btree-chk-leaf)
  • Revision ID: pqm@pqm.ubuntu.com-20100824232014-nu9owzel2zym2jk2
(jam) Use a custom C type for CHK index entries, saves memory

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2011 Canonical Ltd
 
1
# Copyright (C) 2007-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
 
 
19
17
from bzrlib.lazy_import import lazy_import
20
18
 
21
19
lazy_import(globals(), """
22
20
import errno
23
 
import gzip
24
21
import itertools
25
22
import os
26
23
from StringIO import StringIO
27
24
 
28
25
from bzrlib import (
29
 
    bencode,
30
26
    errors,
31
27
    patiencediff,
 
28
    trace,
32
29
    ui,
33
30
    )
 
31
from bzrlib import bencode
34
32
""")
 
33
from bzrlib.tuned_gzip import GzipFile
35
34
 
36
35
 
37
36
def topo_iter_keys(vf, keys=None):
423
422
                            if not (lines == self.get_line_list([revision])[0]):
424
423
                                raise AssertionError()
425
424
                            self.clear_cache()
426
 
                    pb.update(gettext('Importing revisions'),
 
425
                    pb.update('Importing revisions',
427
426
                              (total - len(revisions)) + len(added), total)
428
427
                revisions = [r for r in revisions if r not in added]
429
428
        finally:
562
561
            sio = StringIO(infile.read(count))
563
562
        finally:
564
563
            infile.close()
565
 
        zip_file = gzip.GzipFile(None, mode='rb', fileobj=sio)
 
564
        zip_file = GzipFile(None, mode='rb', fileobj=sio)
566
565
        try:
567
566
            file_version_id = zip_file.readline()
568
 
            content = zip_file.read()
569
 
            return MultiParent.from_patch(content)
 
567
            return MultiParent.from_patch(zip_file.read())
570
568
        finally:
571
569
            zip_file.close()
572
570
 
578
576
                                    # before any write returns 0
579
577
            start = outfile.tell()
580
578
            try:
581
 
                zipfile = gzip.GzipFile(None, mode='ab', fileobj=outfile)
 
579
                zipfile = GzipFile(None, mode='ab', fileobj=outfile)
582
580
                zipfile.writelines(itertools.chain(
583
581
                    ['version %s\n' % version_id], diff.to_patch()))
584
582
            finally:
675
673
 
676
674
def gzip_string(lines):
677
675
    sio = StringIO()
678
 
    data_file = gzip.GzipFile(None, mode='wb', fileobj=sio)
 
676
    data_file = GzipFile(None, mode='wb', fileobj=sio)
679
677
    data_file.writelines(lines)
680
678
    data_file.close()
681
679
    return sio.getvalue()