~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

Handle to_paths correctly when parent of file is not in specified_ids

Show diffs side-by-side

added added

removed removed

Lines of Context:
480
480
        from_entries_by_dir = list(from_tree.inventory.iter_entries_by_dir(
481
481
            specific_file_ids=specific_file_ids))
482
482
        from_data = dict((e.file_id, (p, e)) for p, e in from_entries_by_dir)
483
 
        to_entries_by_dir = list(to_tree.inventory.iter_entries_by_dir(specific_file_ids=specific_file_ids))
 
483
        to_entries_by_dir = list(to_tree.inventory.iter_entries_by_dir(
 
484
            specific_file_ids=specific_file_ids))
484
485
        num_entries = len(from_entries_by_dir) + len(to_entries_by_dir)
485
486
        entry_count = 0
486
487
        for to_path, to_entry in to_entries_by_dir:
532
533
                yield (file_id, to_path, changed_content, versioned, parent,
533
534
                       name, kind, executable)
534
535
 
 
536
        def get_to_path(from_entry):
 
537
            if from_entry.parent_id is None:
 
538
                to_path = ''
 
539
            else:
 
540
                if from_entry.parent_id not in to_paths:
 
541
                    get_to_path(from_tree.inventory[from_entry.parent_id])
 
542
                to_path = osutils.pathjoin(to_paths[from_entry.parent_id],
 
543
                                           from_entry.name)
 
544
            to_paths[from_entry.file_id] = to_path
 
545
            return to_path
 
546
 
535
547
        for path, from_entry in from_entries_by_dir:
536
548
            file_id = from_entry.file_id
537
549
            if file_id in to_paths:
538
550
                continue
539
 
            if from_entry.parent_id is None:
540
 
                to_path = ''
541
 
            else:
542
 
                to_path = osutils.pathjoin(to_paths[from_entry.parent_id],
543
 
                                           from_entry.name)
544
 
            to_paths[file_id] = to_path
 
551
            to_path = get_to_path(from_entry)
545
552
            entry_count += 1
546
553
            if pb is not None:
547
554
                pb.update('comparing files', entry_count, num_entries)