~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-07 07:44:36 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090907074436-pede7phglz90jrvf
split developer docs into their own website/chm file

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
        self._control_files.break_lock()
282
282
        self.branch.break_lock()
283
283
 
 
284
    def _get_check_refs(self):
 
285
        """Return the references needed to perform a check of this tree.
 
286
        
 
287
        The default implementation returns no refs, and is only suitable for
 
288
        trees that have no local caching and can commit on ghosts at any time.
 
289
 
 
290
        :seealso: bzrlib.check for details about check_refs.
 
291
        """
 
292
        return []
 
293
 
284
294
    def requires_rich_root(self):
285
295
        return self._format.requires_rich_root
286
296
 
603
613
 
604
614
    def get_file_size(self, file_id):
605
615
        """See Tree.get_file_size"""
 
616
        # XXX: this returns the on-disk size; it should probably return the
 
617
        # canonical size
606
618
        try:
607
619
            return os.path.getsize(self.id2abspath(file_id))
608
620
        except OSError, e:
739
751
            raise
740
752
        kind = _mapper(stat_result.st_mode)
741
753
        if kind == 'file':
742
 
            size = stat_result.st_size
743
 
            # try for a stat cache lookup
744
 
            executable = self._is_executable_from_path_and_stat(path, stat_result)
745
 
            return (kind, size, executable, self._sha_from_stat(
746
 
                path, stat_result))
 
754
            return self._file_content_summary(path, stat_result)
747
755
        elif kind == 'directory':
748
756
            # perhaps it looks like a plain directory, but it's really a
749
757
            # reference.
756
764
        else:
757
765
            return (kind, None, None, None)
758
766
 
 
767
    def _file_content_summary(self, path, stat_result):
 
768
        size = stat_result.st_size
 
769
        executable = self._is_executable_from_path_and_stat(path, stat_result)
 
770
        # try for a stat cache lookup
 
771
        return ('file', size, executable, self._sha_from_stat(
 
772
            path, stat_result))
 
773
 
759
774
    def _check_parents_for_ghosts(self, revision_ids, allow_leftmost_as_ghost):
760
775
        """Common ghost checking functionality from set_parent_*.
761
776
 
1883
1898
            firstline = xml.split('\n', 1)[0]
1884
1899
            if (not 'revision_id="' in firstline or
1885
1900
                'format="7"' not in firstline):
1886
 
                inv = self.branch.repository.deserialise_inventory(
1887
 
                    new_revision, xml)
 
1901
                inv = self.branch.repository._serializer.read_inventory_from_string(
 
1902
                    xml, new_revision)
1888
1903
                xml = self._create_basis_xml_from_inventory(new_revision, inv)
1889
1904
            self._write_basis_inventory(xml)
1890
1905
        except (errors.NoSuchRevision, errors.RevisionNotPresent):
2536
2551
        return un_resolved, resolved
2537
2552
 
2538
2553
    @needs_read_lock
2539
 
    def _check(self):
 
2554
    def _check(self, references):
 
2555
        """Check the tree for consistency.
 
2556
 
 
2557
        :param references: A dict with keys matching the items returned by
 
2558
            self._get_check_refs(), and values from looking those keys up in
 
2559
            the repository.
 
2560
        """
2540
2561
        tree_basis = self.basis_tree()
2541
2562
        tree_basis.lock_read()
2542
2563
        try:
2543
 
            repo_basis = self.branch.repository.revision_tree(
2544
 
                self.last_revision())
 
2564
            repo_basis = references[('trees', self.last_revision())]
2545
2565
            if len(list(repo_basis.iter_changes(tree_basis))) > 0:
2546
2566
                raise errors.BzrCheckError(
2547
2567
                    "Mismatched basis inventory content.")
2593
2613
        if self._inventory is None:
2594
2614
            self.read_working_inventory()
2595
2615
 
 
2616
    def _get_check_refs(self):
 
2617
        """Return the references needed to perform a check of this tree."""
 
2618
        return [('trees', self.last_revision())]
 
2619
 
2596
2620
    def lock_tree_write(self):
2597
2621
        """See WorkingTree.lock_tree_write().
2598
2622
 
2655
2679
                mode=self.bzrdir._get_file_mode())
2656
2680
            return True
2657
2681
 
 
2682
    def _get_check_refs(self):
 
2683
        """Return the references needed to perform a check of this tree."""
 
2684
        return [('trees', self.last_revision())]
 
2685
 
2658
2686
    @needs_tree_write_lock
2659
2687
    def set_conflicts(self, conflicts):
2660
2688
        self._put_rio('conflicts', conflicts.to_stanzas(),
3007
3035
        return self.get_format_string()
3008
3036
 
3009
3037
 
3010
 
__default_format = WorkingTreeFormat4()
 
3038
__default_format = WorkingTreeFormat6()
3011
3039
WorkingTreeFormat.register_format(__default_format)
3012
 
WorkingTreeFormat.register_format(WorkingTreeFormat6())
3013
3040
WorkingTreeFormat.register_format(WorkingTreeFormat5())
 
3041
WorkingTreeFormat.register_format(WorkingTreeFormat4())
3014
3042
WorkingTreeFormat.register_format(WorkingTreeFormat3())
3015
3043
WorkingTreeFormat.set_default_format(__default_format)
3016
3044
# formats which have no format string are not discoverable