~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Roundtrip tree roots in bundles

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
        old_label = ''
229
229
        new_label = ''
230
230
 
 
231
        def bundle_path(path):
 
232
            if path != '':
 
233
                return path
 
234
            else:
 
235
                return '.'
 
236
 
231
237
        def do_diff(file_id, old_path, new_path, action):
232
238
            def tree_lines(tree, require_text=False):
233
239
                if file_id in tree:
255
261
        def finish_action(action, file_id, kind, meta_modified, text_modified,
256
262
                          old_path, new_path):
257
263
            entry = new_tree.inventory[file_id]
258
 
            if entry.revision != default_revision_id:
 
264
            if (entry.revision != default_revision_id and 
 
265
                entry.revision is not None):
259
266
                action.add_property('last-changed', entry.revision)
260
267
            if meta_modified:
261
268
                action.add_bool_property('executable', entry.executable)
266
273
            else:
267
274
                action.write(self.to_file)
268
275
 
269
 
        delta = compare_trees(old_tree, new_tree, want_unchanged=True)
 
276
        delta = compare_trees(old_tree, new_tree, want_unchanged=True,
 
277
                              include_root=True)
270
278
        for path, file_id, kind in delta.removed:
271
279
            action = Action('removed', [kind, path]).write(self.to_file)
272
280
 
273
281
        for path, file_id, kind in delta.added:
274
 
            action = Action('added', [kind, path], [('file-id', file_id)])
 
282
            if path == '':
 
283
                pass
 
284
            action = Action('added', [kind, bundle_path(path)], 
 
285
                            [('file-id', file_id)])
275
286
            meta_modified = (kind=='file' and 
276
287
                             new_tree.is_executable(file_id))
277
288
            finish_action(action, file_id, kind, meta_modified, True,
279
290
 
280
291
        for (old_path, new_path, file_id, kind,
281
292
             text_modified, meta_modified) in delta.renamed:
282
 
            action = Action('renamed', [kind, old_path], [(new_path,)])
 
293
            action = Action('renamed', [kind, bundle_path(old_path)], 
 
294
                            [(bundle_path(new_path),)])
283
295
            finish_action(action, file_id, kind, meta_modified, text_modified,
284
296
                          old_path, new_path)
285
297
 
286
298
        for (path, file_id, kind,
287
299
             text_modified, meta_modified) in delta.modified:
288
 
            action = Action('modified', [kind, path])
 
300
            action = Action('modified', [kind, bundle_path(path)])
289
301
            finish_action(action, file_id, kind, meta_modified, text_modified,
290
302
                          path, path)
291
303
 
296
308
                continue
297
309
            old_rev = getattr(old_tree.inventory[ie.file_id], 'revision', None)
298
310
            if new_rev != old_rev:
299
 
                action = Action('modified', [ie.kind, 
300
 
                                             new_tree.id2path(ie.file_id)])
301
 
                action.add_property('last-changed', ie.revision)
 
311
                action = Action('modified', 
 
312
                    [ie.kind, bundle_path(new_tree.id2path(ie.file_id))])
 
313
                if ie.revision is not None:
 
314
                    action.add_property('last-changed', ie.revision)
302
315
                action.write(self.to_file)