~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2006-05-26 06:08:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1761.
  • Revision ID: mbp@sourcefrog.net-20060526060847-20ed6bc6bf074b68
Split check into Branch.check and Repository.check

Show diffs side-by-side

added added

removed removed

Lines of Context:
537
537
        if parent:
538
538
            destination.set_parent(parent)
539
539
 
 
540
    @needs_read_lock
 
541
    def check(self):
 
542
        """Check consistency of the branch.
 
543
 
 
544
        In particular this checks that revisions given in the revision-history
 
545
        do actually match up in the revision graph, and that they're all 
 
546
        present in the repository.
 
547
 
 
548
        :return: A BranchCheckResult.
 
549
        """
 
550
        mainline_parent_id = None
 
551
        for revision_id in self.revision_history():
 
552
            try:
 
553
                revision = self.repository.get_revision(revision_id)
 
554
            except errors.NoSuchRevision, e:
 
555
                raise BzrCheckError("mainline revision {%s} not in repository"
 
556
                        % revision_id)
 
557
            # In general the first entry on the revision history has no parents.
 
558
            # But it's not illegal for it to have parents listed; this can happen
 
559
            # in imports from Arch when the parents weren't reachable.
 
560
            if mainline_parent_id is not None:
 
561
                if mainline_parent_id not in revision.parent_ids:
 
562
                    raise BzrCheckError("previous revision {%s} not listed among "
 
563
                                        "parents of {%s}"
 
564
                                        % (mainline_parent_id, revision_id))
 
565
            mainline_parent_id = revision_id
 
566
        return BranchCheckResult(self)
 
567
 
540
568
 
541
569
class BranchFormat(object):
542
570
    """An encapsulation of the initialization and open routines for a format.
1334
1362
        return result
1335
1363
 
1336
1364
 
 
1365
class BranchCheckResult(object):
 
1366
    """Results of checking branch consistency.
 
1367
 
 
1368
    :see: Branch.check
 
1369
    """
 
1370
 
 
1371
    def __init__(self, branch):
 
1372
        self.branch = branch
 
1373
 
 
1374
    def report_results(self, verbose):
 
1375
        """Report the check results via trace.note.
 
1376
        
 
1377
        :param verbose: Requests more detailed display of what was checked,
 
1378
            if any.
 
1379
        """
 
1380
        note('checked branch %s format %s',
 
1381
             self.branch.base,
 
1382
             self.branch._format)
 
1383
 
 
1384
 
1337
1385
######################################################################
1338
1386
# predicates
1339
1387