~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Robert Collins
  • Date: 2009-05-08 02:06:36 UTC
  • mto: This revision was merged to the branch mainline in revision 4593.
  • Revision ID: robertc@robertcollins.net-20090508020636-f5w6t5ry2g1xluyo
Extract repository access in WorkingTree._check to be data driven, adding a new _get_check_refs method to support this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
290
290
        self._control_files.break_lock()
291
291
        self.branch.break_lock()
292
292
 
 
293
    def _get_check_refs(self):
 
294
        """Return the references needed to perform a check of this tree.
 
295
        
 
296
        The default implementation returns no refs, and is only suitable for
 
297
        trees that have no local caching and can commit on ghosts at any time.
 
298
 
 
299
        :seealso: bzrlib.check for details about check_refs.
 
300
        """
 
301
        return []
 
302
 
293
303
    def requires_rich_root(self):
294
304
        return self._format.requires_rich_root
295
305
 
2513
2523
        return un_resolved, resolved
2514
2524
 
2515
2525
    @needs_read_lock
2516
 
    def _check(self):
 
2526
    def _check(self, references):
 
2527
        """Check the tree for consistency.
 
2528
 
 
2529
        :param references: A dict with keys matching the items returned by
 
2530
            self._get_check_refs(), and values from looking those keys up in
 
2531
            the repository.
 
2532
        """
2517
2533
        tree_basis = self.basis_tree()
2518
2534
        tree_basis.lock_read()
2519
2535
        try:
2520
 
            repo_basis = self.branch.repository.revision_tree(
2521
 
                self.last_revision())
 
2536
            repo_basis = references[('trees', self.last_revision())]
2522
2537
            if len(list(repo_basis.iter_changes(tree_basis))) > 0:
2523
2538
                raise errors.BzrCheckError(
2524
2539
                    "Mismatched basis inventory content.")
2570
2585
        if self._inventory is None:
2571
2586
            self.read_working_inventory()
2572
2587
 
 
2588
    def _get_check_refs(self):
 
2589
        """Return the references needed to perform a check of this tree."""
 
2590
        return [('trees', self.last_revision())]
 
2591
 
2573
2592
    def lock_tree_write(self):
2574
2593
        """See WorkingTree.lock_tree_write().
2575
2594
 
2632
2651
                mode=self.bzrdir._get_file_mode())
2633
2652
            return True
2634
2653
 
 
2654
    def _get_check_refs(self):
 
2655
        """Return the references needed to perform a check of this tree."""
 
2656
        return [('trees', self.last_revision())]
 
2657
 
2635
2658
    @needs_tree_write_lock
2636
2659
    def set_conflicts(self, conflicts):
2637
2660
        self._put_rio('conflicts', conflicts.to_stanzas(),