~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/multiparent.py

  • Committer: Aaron Bentley
  • Date: 2007-06-15 02:31:15 UTC
  • mto: (2520.5.2 bzr.mpbundle)
  • mto: This revision was merged to the branch mainline in revision 2631.
  • Revision ID: aaron.bentley@utoronto.ca-20070615023115-cdu04pyub8dnnl7a
Do our own line splitting for mp-diffs

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
    def zipped_patch_len(self):
132
132
        return len(gzip_string(self.to_patch()))
133
133
 
 
134
    @classmethod
 
135
    def from_patch(cls, text):
 
136
        lines = text.split('\n')
 
137
        new_lines = [l + '\n' for l in lines[:-1]]
 
138
        if lines[-1] != '':
 
139
            new_lines.append(lines[-1])
 
140
        return cls._from_patch(new_lines)
 
141
 
134
142
    @staticmethod
135
 
    def from_patch(lines):
136
 
        """Produce a MultiParent from a sequence of lines"""
 
143
    def _from_patch(lines):
 
144
        """This is private because it is essential to split lines on \n only"""
137
145
        line_iter = iter(lines)
138
146
        hunks = []
139
147
        cur_line = None
470
478
        zip_file = GzipFile(None, mode='rb', fileobj=sio)
471
479
        try:
472
480
            file_version_id = zip_file.readline()
473
 
            return MultiParent.from_patch(zip_file.readlines())
 
481
            return MultiParent.from_patch(zip_file.read())
474
482
        finally:
475
483
            zip_file.close()
476
484