/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/multiparent.py

  • Committer: John Arbash Meinel
  • Date: 2011-03-15 10:28:20 UTC
  • mto: This revision was merged to the branch mainline in revision 5725.
  • Revision ID: john@arbash-meinel.com-20110315102820-51wy8wjre5ol34mu
'bzr export' needs to use 'exact' encoding.

If we are going to be writing binary bites out of stdout, then it needs to
be in binary mode, or it will corrupt the data stream.
Oddly enough, it only seemed to fail if we set '--verbose'. I didn't
bother to track into that bug.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 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
30
30
    )
31
31
from bzrlib import bencode
32
32
""")
33
 
from bzrlib.tuned_gzip import GzipFile
 
33
from gzip import GzipFile
34
34
 
35
35
 
36
36
def topo_iter_keys(vf, keys=None):
76
76
class MultiParent(object):
77
77
    """A multi-parent diff"""
78
78
 
 
79
    __slots__ = ['hunks']
 
80
 
79
81
    def __init__(self, hunks=None):
80
82
        if hunks is not None:
81
83
            self.hunks = hunks
258
260
class NewText(object):
259
261
    """The contents of text that is introduced by this text"""
260
262
 
 
263
    __slots__ = ['lines']
 
264
 
261
265
    def __init__(self, lines):
262
266
        self.lines = lines
263
267
 
279
283
class ParentText(object):
280
284
    """A reference to text present in a parent text"""
281
285
 
 
286
    __slots__ = ['parent', 'parent_pos', 'child_pos', 'num_lines']
 
287
 
282
288
    def __init__(self, parent, parent_pos, child_pos, num_lines):
283
289
        self.parent = parent
284
290
        self.parent_pos = parent_pos
285
291
        self.child_pos = child_pos
286
292
        self.num_lines = num_lines
287
293
 
 
294
    def _as_dict(self):
 
295
        return dict(parent=self.parent, parent_pos=self.parent_pos,
 
296
                    child_pos=self.child_pos, num_lines=self.num_lines)
 
297
 
288
298
    def __repr__(self):
289
 
        return 'ParentText(%(parent)r, %(parent_pos)r, %(child_pos)r,'\
290
 
            ' %(num_lines)r)' % self.__dict__
 
299
        return ('ParentText(%(parent)r, %(parent_pos)r, %(child_pos)r,'
 
300
                ' %(num_lines)r)' % self._as_dict())
291
301
 
292
302
    def __eq__(self, other):
293
303
        if self.__class__ is not other.__class__:
294
304
            return False
295
 
        return (self.__dict__ == other.__dict__)
 
305
        return self._as_dict() == other._as_dict()
296
306
 
297
307
    def to_patch(self):
298
 
        yield 'c %(parent)d %(parent_pos)d %(child_pos)d %(num_lines)d\n'\
299
 
            % self.__dict__
 
308
        yield ('c %(parent)d %(parent_pos)d %(child_pos)d %(num_lines)d\n'
 
309
               % self._as_dict())
300
310
 
301
311
 
302
312
class BaseVersionedFile(object):
554
564
        zip_file = GzipFile(None, mode='rb', fileobj=sio)
555
565
        try:
556
566
            file_version_id = zip_file.readline()
557
 
            return MultiParent.from_patch(zip_file.read())
 
567
            content = zip_file.read()
 
568
            return MultiParent.from_patch(content)
558
569
        finally:
559
570
            zip_file.close()
560
571