~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-06-11 01:26:03 UTC
  • mfrom: (1732.2.7 bzr.mbp.check)
  • Revision ID: pqm@pqm.ubuntu.com-20060611012603-c00c68cf5b2505d7
(mbp) split out check into repo & branch methods

Show diffs side-by-side

added added

removed removed

Lines of Context:
557
557
        if parent:
558
558
            destination.set_parent(parent)
559
559
 
 
560
    @needs_read_lock
 
561
    def check(self):
 
562
        """Check consistency of the branch.
 
563
 
 
564
        In particular this checks that revisions given in the revision-history
 
565
        do actually match up in the revision graph, and that they're all 
 
566
        present in the repository.
 
567
 
 
568
        :return: A BranchCheckResult.
 
569
        """
 
570
        mainline_parent_id = None
 
571
        for revision_id in self.revision_history():
 
572
            try:
 
573
                revision = self.repository.get_revision(revision_id)
 
574
            except errors.NoSuchRevision, e:
 
575
                raise BzrCheckError("mainline revision {%s} not in repository"
 
576
                        % revision_id)
 
577
            # In general the first entry on the revision history has no parents.
 
578
            # But it's not illegal for it to have parents listed; this can happen
 
579
            # in imports from Arch when the parents weren't reachable.
 
580
            if mainline_parent_id is not None:
 
581
                if mainline_parent_id not in revision.parent_ids:
 
582
                    raise BzrCheckError("previous revision {%s} not listed among "
 
583
                                        "parents of {%s}"
 
584
                                        % (mainline_parent_id, revision_id))
 
585
            mainline_parent_id = revision_id
 
586
        return BranchCheckResult(self)
 
587
 
560
588
 
561
589
class BranchFormat(object):
562
590
    """An encapsulation of the initialization and open routines for a format.
1365
1393
        return result
1366
1394
 
1367
1395
 
 
1396
class BranchCheckResult(object):
 
1397
    """Results of checking branch consistency.
 
1398
 
 
1399
    :see: Branch.check
 
1400
    """
 
1401
 
 
1402
    def __init__(self, branch):
 
1403
        self.branch = branch
 
1404
 
 
1405
    def report_results(self, verbose):
 
1406
        """Report the check results via trace.note.
 
1407
        
 
1408
        :param verbose: Requests more detailed display of what was checked,
 
1409
            if any.
 
1410
        """
 
1411
        note('checked branch %s format %s',
 
1412
             self.branch.base,
 
1413
             self.branch._format)
 
1414
 
 
1415
 
1368
1416
######################################################################
1369
1417
# predicates
1370
1418