~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2006-06-20 07:55:43 UTC
  • mfrom: (1798 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1799.
  • Revision ID: mbp@sourcefrog.net-20060620075543-b10f6575d4a4fa32
[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 = ''
229
230
        new_label = ''
230
231
 
231
 
        def do_diff(file_id, old_path, new_path, action):
 
232
        def do_diff(file_id, old_path, new_path, action, force_binary):
232
233
            def tree_lines(tree, require_text=False):
233
234
                if file_id in tree:
234
235
                    tree_file = tree.get_file(file_id)
239
240
                    return []
240
241
 
241
242
            try:
 
243
                if force_binary:
 
244
                    raise errors.BinaryFile()
242
245
                old_lines = tree_lines(old_tree, require_text=True)
243
246
                new_lines = tree_lines(new_tree, require_text=True)
244
247
                action.write(self.to_file)
262
265
            if text_modified and kind == "symlink":
263
266
                action.add_property('target', entry.symlink_target)
264
267
            if text_modified and kind == "file":
265
 
                do_diff(file_id, old_path, new_path, action)
 
268
                do_diff(file_id, old_path, new_path, action, force_binary)
266
269
            else:
267
270
                action.write(self.to_file)
268
271