~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2006-05-20 17:52:58 UTC
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: aaron.bentley@utoronto.ca-20060520175258-d1a320d0120d8b64
Refactored action writing

Show diffs side-by-side

added added

removed removed

Lines of Context:
253
253
            if ie.revision != default_revision_id:
254
254
                action.add_property('last-changed', ie.revision)
255
255
 
 
256
        def finish_action(action, file_id, kind, meta_modified, text_modified,
 
257
                          old_path, new_path):
 
258
            do_revision(file_id, action)
 
259
            if meta_modified:
 
260
                do_meta(file_id, action)
 
261
            if text_modified and kind == "symlink":
 
262
                do_target(new_tree.inventory[file_id].symlink_target, action)
 
263
            if text_modified and kind == "file":
 
264
                do_diff(old_path, file_id, new_path, text_modified, action)
 
265
            else:
 
266
                action.write(self.to_file)
 
267
 
256
268
        delta = compare_trees(old_tree, new_tree, want_unchanged=False)
257
269
 
258
 
        def w(text):
259
 
            self.to_file.write(text.encode('utf-8'))
260
 
 
261
270
        for path, file_id, kind in delta.removed:
262
271
            action = Action('removed', [kind, path]).write(self.to_file)
263
272
 
264
273
        for path, file_id, kind in delta.added:
265
274
            action = Action('added', [kind, path], [('file-id', file_id)])
266
 
            do_revision(file_id, action)
267
 
            if kind == 'file':
268
 
                do_meta(file_id, action)
269
 
            if kind == 'symlink':
270
 
                do_target(new_tree.inventory[file_id].symlink_target, action)
271
 
            if kind == 'file':
272
 
                do_diff(DEVNULL, file_id, path, kind, action)
273
 
            else:
274
 
                action.write(self.to_file)
275
 
 
 
275
            finish_action(action, file_id, kind, True, True,
 
276
                          DEVNULL, path)
276
277
 
277
278
        for (old_path, new_path, file_id, kind,
278
279
             text_modified, meta_modified) in delta.renamed:
279
280
            action = Action('renamed', [kind, old_path], [(new_path,)])
280
 
            do_revision(file_id, action)
281
 
            if meta_modified:
282
 
                do_meta(file_id)
283
 
            if text_modified and kind == "symlink":
284
 
                do_target(new_tree.inventory[file_id].symlink_target, action)
285
 
            if text_modified and kind == "file":
286
 
                do_diff(old_path, file_id, new_path, text_modified, action)
287
 
            else:
288
 
                action.write(self.to_file)
 
281
            finish_action(action, file_id, kind, meta_modified, text_modified,
 
282
                          old_path, new_path)
289
283
 
290
284
        for (path, file_id, kind,
291
285
             text_modified, meta_modified) in delta.modified:
292
 
            # TODO: Handle meta_modified
293
 
            #prop_str = get_prop_change(meta_modified)
294
286
            action = Action('modified', [kind, path])
295
 
            do_revision(file_id, action)
296
 
            if meta_modified:
297
 
                do_meta(file_id, action)
298
 
            if text_modified and kind == "symlink":
299
 
                do_target(new_tree.inventory[file_id].symlink_target, action)
300
 
            if text_modified and kind == "file":
301
 
                do_diff(path, file_id, path, kind, action)
302
 
            else:
303
 
                action.write(self.to_file)
 
287
            finish_action(action, file_id, kind, meta_modified, text_modified,
 
288
                          path, path)