~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

Improve common_ancestor performance.

Show diffs side-by-side

added added

removed removed

Lines of Context:
425
425
        return self.get_revision(revision_id).inventory_sha1
426
426
 
427
427
    @needs_read_lock
 
428
    def get_revision_graph(self, revision_id=None):
 
429
        """Return a dictionary containing the revision graph.
 
430
        
 
431
        :return: a dictionary of revision_id->revision_parents_list.
 
432
        """
 
433
        weave = self.get_inventory_weave()
 
434
        all_revisions = self._eliminate_revisions_not_present(weave.names())
 
435
        entire_graph = dict([(node, weave.parent_names(node)) for 
 
436
                             node in all_revisions])
 
437
        if revision_id is None:
 
438
            return entire_graph
 
439
        elif revision_id not in entire_graph:
 
440
            raise errors.NoSuchRevision(self, revision_id)
 
441
        else:
 
442
            # add what can be reached from revision_id
 
443
            result = {}
 
444
            pending = set([revision_id])
 
445
            while len(pending) > 0:
 
446
                node = pending.pop()
 
447
                result[node] = entire_graph[node]
 
448
                for revision_id in result[node]:
 
449
                    if revision_id not in result:
 
450
                        pending.add(revision_id)
 
451
            return result
 
452
 
 
453
    @needs_read_lock
428
454
    def get_revision_inventory(self, revision_id):
429
455
        """Return inventory of a past revision."""
430
456
        # TODO: Unify this with get_inventory()
502
528
    def get_transaction(self):
503
529
        return self.control_files.get_transaction()
504
530
 
 
531
    def revision_parents(self, revid):
 
532
        return self.get_inventory_weave().parent_names(revid)
 
533
 
505
534
    @needs_write_lock
506
535
    def set_make_working_trees(self, new_value):
507
536
        """Set the policy flag for making working trees when creating branches.