~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Danny van Heumen
  • Date: 2010-03-09 21:42:11 UTC
  • mto: (4634.139.5 2.0)
  • mto: This revision was merged to the branch mainline in revision 5160.
  • Revision ID: danny@dannyvanheumen.nl-20100309214211-iqh42x6qcikgd9p3
Reverted now-useless TODO list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
613
613
 
614
614
    def get_file_size(self, file_id):
615
615
        """See Tree.get_file_size"""
 
616
        # XXX: this returns the on-disk size; it should probably return the
 
617
        # canonical size
616
618
        try:
617
619
            return os.path.getsize(self.id2abspath(file_id))
618
620
        except OSError, e:
749
751
            raise
750
752
        kind = _mapper(stat_result.st_mode)
751
753
        if kind == 'file':
752
 
            size = stat_result.st_size
753
 
            # try for a stat cache lookup
754
 
            executable = self._is_executable_from_path_and_stat(path, stat_result)
755
 
            return (kind, size, executable, self._sha_from_stat(
756
 
                path, stat_result))
 
754
            return self._file_content_summary(path, stat_result)
757
755
        elif kind == 'directory':
758
756
            # perhaps it looks like a plain directory, but it's really a
759
757
            # reference.
766
764
        else:
767
765
            return (kind, None, None, None)
768
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
 
769
774
    def _check_parents_for_ghosts(self, revision_ids, allow_leftmost_as_ghost):
770
775
        """Common ghost checking functionality from set_parent_*.
771
776
 
1619
1624
                                this_tree=self,
1620
1625
                                pb=pb,
1621
1626
                                change_reporter=change_reporter)
1622
 
                    if (basis_tree.inventory.root is None and
1623
 
                        new_basis_tree.inventory.root is not None):
1624
 
                        self.set_root_id(new_basis_tree.get_root_id())
 
1627
                    basis_root_id = basis_tree.get_root_id()
 
1628
                    new_root_id = new_basis_tree.get_root_id()
 
1629
                    if basis_root_id != new_root_id:
 
1630
                        self.set_root_id(new_root_id)
1625
1631
                finally:
1626
1632
                    pb.finished()
1627
1633
                    basis_tree.unlock()
1893
1899
            firstline = xml.split('\n', 1)[0]
1894
1900
            if (not 'revision_id="' in firstline or
1895
1901
                'format="7"' not in firstline):
1896
 
                inv = self.branch.repository.deserialise_inventory(
1897
 
                    new_revision, xml)
 
1902
                inv = self.branch.repository._serializer.read_inventory_from_string(
 
1903
                    xml, new_revision)
1898
1904
                xml = self._create_basis_xml_from_inventory(new_revision, inv)
1899
1905
            self._write_basis_inventory(xml)
1900
1906
        except (errors.NoSuchRevision, errors.RevisionNotPresent):
2240
2246
            basis.lock_read()
2241
2247
            try:
2242
2248
                to_tree = self.branch.basis_tree()
2243
 
                if basis.inventory.root is None:
2244
 
                    self.set_root_id(to_tree.get_root_id())
 
2249
                to_root_id = to_tree.get_root_id()
 
2250
                if (basis.inventory.root is None
 
2251
                    or basis.inventory.root.file_id != to_root_id):
 
2252
                    self.set_root_id(to_root_id)
2245
2253
                    self.flush()
2246
2254
                result += merge.merge_inner(
2247
2255
                                      self.branch,
3030
3038
        return self.get_format_string()
3031
3039
 
3032
3040
 
3033
 
__default_format = WorkingTreeFormat4()
 
3041
__default_format = WorkingTreeFormat6()
3034
3042
WorkingTreeFormat.register_format(__default_format)
3035
 
WorkingTreeFormat.register_format(WorkingTreeFormat6())
3036
3043
WorkingTreeFormat.register_format(WorkingTreeFormat5())
 
3044
WorkingTreeFormat.register_format(WorkingTreeFormat4())
3037
3045
WorkingTreeFormat.register_format(WorkingTreeFormat3())
3038
3046
WorkingTreeFormat.set_default_format(__default_format)
3039
3047
# formats which have no format string are not discoverable