~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-04 21:25:46 UTC
  • mfrom: (4409 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4410.
  • Revision ID: john@arbash-meinel.com-20090604212546-dpmrzvg49q40tvnj
Merge bzr.dev 4409, resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1085
1085
        source_revno, source_revision_id = self.last_revision_info()
1086
1086
        if revision_id is None:
1087
1087
            revno, revision_id = source_revno, source_revision_id
1088
 
        elif source_revision_id == revision_id:
1089
 
            # we know the revno without needing to walk all of history
1090
 
            revno = source_revno
1091
1088
        else:
1092
 
            # To figure out the revno for a random revision, we need to build
1093
 
            # the revision history, and count its length.
1094
 
            # We don't care about the order, just how long it is.
1095
 
            # Alternatively, we could start at the current location, and count
1096
 
            # backwards. But there is no guarantee that we will find it since
1097
 
            # it may be a merged revision.
1098
 
            revno = len(list(self.repository.iter_reverse_revision_history(
1099
 
                                                                revision_id)))
 
1089
            graph = self.repository.get_graph()
 
1090
            try:
 
1091
                revno = graph.find_distance_to_null(revision_id, 
 
1092
                    [(source_revision_id, source_revno)])
 
1093
            except errors.GhostRevisionsHaveNoRevno:
 
1094
                # Default to 1, if we can't find anything else
 
1095
                revno = 1
1100
1096
        destination.set_last_revision_info(revno, revision_id)
1101
1097
 
1102
1098
    @needs_read_lock
1147
1143
 
1148
1144
        :return: A BranchCheckResult.
1149
1145
        """
 
1146
        ret = BranchCheckResult(self)
1150
1147
        mainline_parent_id = None
1151
1148
        last_revno, last_revision_id = self.last_revision_info()
1152
 
        real_rev_history = list(self.repository.iter_reverse_revision_history(
1153
 
                                last_revision_id))
 
1149
        real_rev_history = []
 
1150
        try:
 
1151
            for revid in self.repository.iter_reverse_revision_history(
 
1152
                last_revision_id):
 
1153
                real_rev_history.append(revid)
 
1154
        except errors.RevisionNotPresent:
 
1155
            ret.ghosts_in_mainline = True
 
1156
        else:
 
1157
            ret.ghosts_in_mainline = False
1154
1158
        real_rev_history.reverse()
1155
1159
        if len(real_rev_history) != last_revno:
1156
1160
            raise errors.BzrCheckError('revno does not match len(mainline)'
1172
1176
                                        "parents of {%s}"
1173
1177
                                        % (mainline_parent_id, revision_id))
1174
1178
            mainline_parent_id = revision_id
1175
 
        return BranchCheckResult(self)
 
1179
        return ret
1176
1180
 
1177
1181
    def _get_checkout_format(self):
1178
1182
        """Return the most suitable metadir for a checkout of this branch.
2780
2784
 
2781
2785
    def __init__(self, branch):
2782
2786
        self.branch = branch
 
2787
        self.ghosts_in_mainline = False
2783
2788
 
2784
2789
    def report_results(self, verbose):
2785
2790
        """Report the check results via trace.note.
2790
2795
        note('checked branch %s format %s',
2791
2796
             self.branch.base,
2792
2797
             self.branch._format)
 
2798
        if self.ghosts_in_mainline:
 
2799
            note('branch contains ghosts in mainline')
2793
2800
 
2794
2801
 
2795
2802
class Converter5to6(object):