~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

Provide a revision.get_history(repository) method for generating a synthetic revision history.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
                raise ValueError("invalid property value %r for %r" % 
79
79
                                 (name, value))
80
80
 
 
81
    def get_history(self, repository):
 
82
        """Return the canonical line-of-history for this revision.
 
83
 
 
84
        If ghosts are present this may differ in result from a ghost-free
 
85
        repository.
 
86
        """
 
87
        current_revision = self
 
88
        reversed_result = []
 
89
        while current_revision is not None:
 
90
            reversed_result.append(current_revision.revision_id)
 
91
            if not len (current_revision.parent_ids):
 
92
                reversed_result.append(None)
 
93
                current_revision = None
 
94
            else:
 
95
                next_revision_id = current_revision.parent_ids[0]
 
96
                current_revision = repository.get_revision(next_revision_id)
 
97
        reversed_result.reverse()
 
98
        return reversed_result
 
99
 
81
100
 
82
101
def is_ancestor(revision_id, candidate_id, branch):
83
102
    """Return true if candidate_id is an ancestor of revision_id.