~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/serializer/v07.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
                base_tree = last_rev_tree
178
178
            else:
179
179
                base_tree = self.source.revision_tree(base_id)
180
 
 
 
180
            force_binary = (i != 0)
181
181
            self._write_revision(rev, rev_tree, base_id, base_tree, 
182
 
                                 explicit_base)
 
182
                                 explicit_base, force_binary)
183
183
 
184
184
            last_rev_id = base_id
185
185
            last_rev_tree = base_tree
186
186
 
187
187
    def _write_revision(self, rev, rev_tree, base_rev, base_tree, 
188
 
                        explicit_base):
 
188
                        explicit_base, force_binary):
189
189
        """Write out the information for a revision."""
190
190
        def w(key, value):
191
191
            self._write(key, value, indent=1)
195
195
        w('date', format_highres_date(rev.timestamp, rev.timezone))
196
196
        self.to_file.write('\n')
197
197
 
198
 
        self._write_delta(rev_tree, base_tree, rev.revision_id)
 
198
        self._write_delta(rev_tree, base_tree, rev.revision_id, force_binary)
199
199
 
200
200
        w('revision id', rev.revision_id)
201
201
        w('sha1', StrictTestament.from_revision(self.source, 
222
222
        self.to_file.write(' // '.join(p_texts).encode('utf-8'))
223
223
        self.to_file.write('\n')
224
224
 
225
 
    def _write_delta(self, new_tree, old_tree, default_revision_id):
 
225
    def _write_delta(self, new_tree, old_tree, default_revision_id, 
 
226
                     force_binary):
226
227
        """Write out the changes between the trees."""
227
228
        DEVNULL = '/dev/null'
228
229
        old_label = ''
234
235
            else:
235
236
                return '.'
236
237
 
237
 
        def do_diff(file_id, old_path, new_path, action):
 
238
        def do_diff(file_id, old_path, new_path, action, force_binary):
238
239
            def tree_lines(tree, require_text=False):
239
240
                if file_id in tree:
240
241
                    tree_file = tree.get_file(file_id)
245
246
                    return []
246
247
 
247
248
            try:
 
249
                if force_binary:
 
250
                    raise errors.BinaryFile()
248
251
                old_lines = tree_lines(old_tree, require_text=True)
249
252
                new_lines = tree_lines(new_tree, require_text=True)
250
253
                action.write(self.to_file)
269
272
            if text_modified and kind == "symlink":
270
273
                action.add_property('target', entry.symlink_target)
271
274
            if text_modified and kind == "file":
272
 
                do_diff(file_id, old_path, new_path, action)
 
275
                do_diff(file_id, old_path, new_path, action, force_binary)
273
276
            else:
274
277
                action.write(self.to_file)
275
278