~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/multiparent.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 04:25:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5472.
  • Revision ID: andrew.bennetts@canonical.com-20101008042510-sg9vdhmnggilzxsk
Fix stray TAB in source.

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
18
18
 
19
19
lazy_import(globals(), """
20
20
import errno
21
 
import gzip
22
21
import itertools
23
22
import os
24
23
from StringIO import StringIO
25
24
 
26
25
from bzrlib import (
27
 
    bencode,
28
26
    errors,
29
27
    patiencediff,
 
28
    trace,
30
29
    ui,
31
30
    )
 
31
from bzrlib import bencode
32
32
""")
 
33
from bzrlib.tuned_gzip import GzipFile
33
34
 
34
35
 
35
36
def topo_iter_keys(vf, keys=None):
560
561
            sio = StringIO(infile.read(count))
561
562
        finally:
562
563
            infile.close()
563
 
        zip_file = gzip.GzipFile(None, mode='rb', fileobj=sio)
 
564
        zip_file = GzipFile(None, mode='rb', fileobj=sio)
564
565
        try:
565
566
            file_version_id = zip_file.readline()
566
 
            content = zip_file.read()
567
 
            return MultiParent.from_patch(content)
 
567
            return MultiParent.from_patch(zip_file.read())
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 = gzip.GzipFile(None, mode='ab', fileobj=outfile)
 
579
                zipfile = 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 = gzip.GzipFile(None, mode='wb', fileobj=sio)
 
676
    data_file = GzipFile(None, mode='wb', fileobj=sio)
677
677
    data_file.writelines(lines)
678
678
    data_file.close()
679
679
    return sio.getvalue()