/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Aaron Bentley
  • Date: 2006-11-28 05:43:25 UTC
  • mto: This revision was merged to the branch mainline in revision 2162.
  • Revision ID: aaron.bentley@utoronto.ca-20061128054325-gkhwgmkpg128evxu
Support progress bars in iter_changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
            )
89
89
 
90
90
    def _iter_changes(self, from_tree, include_unchanged=False, 
91
 
                     specific_file_ids=None):
 
91
                     specific_file_ids=None, pb=None):
92
92
        intertree = InterTree.get(from_tree, self)
93
93
        return intertree._iter_changes(from_tree, self, include_unchanged, 
94
 
                                       specific_file_ids)
 
94
                                       specific_file_ids, pb)
95
95
    
96
96
    def conflicts(self):
97
97
        """Get a list of the conflicts in the tree.
449
449
            specific_file_ids, include_root)
450
450
 
451
451
    def _iter_changes(self, from_tree, to_tree, include_unchanged, 
452
 
                      specific_file_ids):
 
452
                      specific_file_ids, pb):
453
453
        """Generate an iterator of changes between trees.
454
454
 
455
455
        A tuple is returned:
466
466
        Iteration is done in parent-to-child order, relative to the to_tree.
467
467
        """
468
468
        to_paths = {}
 
469
        from_entries_by_dir = list(from_tree.iter_entries_by_dir())
 
470
        from_data = dict((e.file_id, (p, e)) for p, e in from_entries_by_dir)
 
471
        to_entries_by_dir = list(to_tree.iter_entries_by_dir())
469
472
        if specific_file_ids is not None:
470
473
            specific_file_ids = set(specific_file_ids)
471
 
        from_entries_by_dir = list(from_tree.iter_entries_by_dir())
472
 
        from_data = dict((e.file_id, (p, e)) for p, e in from_entries_by_dir)
473
 
        for to_path, to_entry in to_tree.iter_entries_by_dir():
 
474
            num_entries = len(specific_file_ids)
 
475
        else:
 
476
            num_entries = len(from_entries_by_dir) + len(to_entries_by_dir)
 
477
        entry_count = 0
 
478
        for to_path, to_entry in to_entries_by_dir:
474
479
            file_id = to_entry.file_id
475
480
            to_paths[file_id] = to_path
476
481
            if (specific_file_ids is not None and 
477
482
                file_id not in specific_file_ids):
478
483
                continue
 
484
            entry_count += 1
479
485
            changed_content = False
480
486
            from_path, from_entry = from_data.get(file_id, (None, None))
481
487
            from_versioned = (from_entry is not None)
485
491
                from_parent = from_entry.parent_id
486
492
                from_kind, from_executable, from_stat = \
487
493
                    from_tree._comparison_data(from_entry, from_path)
 
494
                if specific_file_ids is None:
 
495
                    entry_count += 1
488
496
            else:
489
497
                from_versioned = False
490
498
                from_kind = None
512
520
            parent = (from_parent, to_entry.parent_id)
513
521
            name = (from_name, to_entry.name)
514
522
            executable = (from_executable, to_executable)
 
523
            if pb is not None:
 
524
                pb.update('comparing files', entry_count, num_entries)
515
525
            if (changed_content is not False or versioned[0] != versioned[1] 
516
526
                or parent[0] != parent[1] or name[0] != name[1] or 
517
527
                executable[0] != executable[1] or include_unchanged):
531
541
            if (specific_file_ids is not None and 
532
542
                file_id not in specific_file_ids):
533
543
                continue
 
544
            entry_count += 1
 
545
            if pb is not None:
 
546
                pb.update('comparing files', entry_count, num_entries)
534
547
            versioned = (True, False)
535
548
            parent = (from_entry.parent_id, None)
536
549
            name = (from_entry.name, None)