~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/multiparent.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-16 19:18:39 UTC
  • mto: This revision was merged to the branch mainline in revision 6391.
  • Revision ID: jelmer@samba.org-20111216191839-eg681lxqibi1qxu1
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007-2011 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
18
18
 
19
19
lazy_import(globals(), """
20
20
import errno
 
21
import gzip
21
22
import itertools
22
23
import os
23
24
from StringIO import StringIO
24
25
 
25
26
from bzrlib import (
 
27
    bencode,
26
28
    errors,
27
29
    patiencediff,
28
 
    trace,
29
30
    ui,
30
31
    )
31
 
from bzrlib import bencode
32
32
""")
33
 
from bzrlib.tuned_gzip import GzipFile
34
33
 
35
34
 
36
35
def topo_iter_keys(vf, keys=None):
422
421
                            if not (lines == self.get_line_list([revision])[0]):
423
422
                                raise AssertionError()
424
423
                            self.clear_cache()
425
 
                    pb.update('Importing revisions',
 
424
                    pb.update(gettext('Importing revisions'),
426
425
                              (total - len(revisions)) + len(added), total)
427
426
                revisions = [r for r in revisions if r not in added]
428
427
        finally:
561
560
            sio = StringIO(infile.read(count))
562
561
        finally:
563
562
            infile.close()
564
 
        zip_file = GzipFile(None, mode='rb', fileobj=sio)
 
563
        zip_file = gzip.GzipFile(None, mode='rb', fileobj=sio)
565
564
        try:
566
565
            file_version_id = zip_file.readline()
567
 
            return MultiParent.from_patch(zip_file.read())
 
566
            content = zip_file.read()
 
567
            return MultiParent.from_patch(content)
568
568
        finally:
569
569
            zip_file.close()
570
570
 
576
576
                                    # before any write returns 0
577
577
            start = outfile.tell()
578
578
            try:
579
 
                zipfile = GzipFile(None, mode='ab', fileobj=outfile)
 
579
                zipfile = gzip.GzipFile(None, mode='ab', fileobj=outfile)
580
580
                zipfile.writelines(itertools.chain(
581
581
                    ['version %s\n' % version_id], diff.to_patch()))
582
582
            finally:
673
673
 
674
674
def gzip_string(lines):
675
675
    sio = StringIO()
676
 
    data_file = GzipFile(None, mode='wb', fileobj=sio)
 
676
    data_file = gzip.GzipFile(None, mode='wb', fileobj=sio)
677
677
    data_file.writelines(lines)
678
678
    data_file.close()
679
679
    return sio.getvalue()