~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Vincent Ladeuil
  • Date: 2012-02-14 17:22:37 UTC
  • mfrom: (6466 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120214172237-7dv7er3n4uy8d5m4
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
from bzrlib.lock import LogicalLockResult
58
58
from bzrlib.lockable_files import LockableFiles
59
59
from bzrlib.lockdir import LockDir
60
 
from bzrlib.mutabletree import needs_tree_write_lock
 
60
from bzrlib.mutabletree import (
 
61
    MutableTree,
 
62
    needs_tree_write_lock,
 
63
    )
61
64
from bzrlib.osutils import (
62
65
    file_kind,
63
66
    isdir,
65
68
    realpath,
66
69
    safe_unicode,
67
70
    )
 
71
from bzrlib.symbol_versioning import (
 
72
    deprecated_in,
 
73
    deprecated_method,
 
74
    )
68
75
from bzrlib.transport.local import LocalTransport
69
76
from bzrlib.tree import (
70
77
    InterTree,
252
259
 
253
260
        :return: an integer. -1 means never save.
254
261
        """
255
 
        # FIXME: We want a WorkingTreeStack here -- vila 20110812
256
 
        conf = config.BranchStack(self.branch)
 
262
        conf = self.get_config_stack()
257
263
        return conf.get('bzr.workingtree.worth_saving_limit')
258
264
 
259
265
    def filter_unversioned_files(self, paths):
412
418
                return link_or_sha1
413
419
        return None
414
420
 
415
 
    def _get_inventory(self):
 
421
    def _get_root_inventory(self):
416
422
        """Get the inventory for the tree. This is only valid within a lock."""
417
423
        if 'evil' in debug.debug_flags:
418
424
            trace.mutter_callsite(2,
423
429
        self._generate_inventory()
424
430
        return self._inventory
425
431
 
 
432
    @deprecated_method(deprecated_in((2, 5, 0)))
 
433
    def _get_inventory(self):
 
434
        return self.root_inventory
 
435
 
426
436
    inventory = property(_get_inventory,
427
437
                         doc="Inventory of this Tree")
428
438
 
 
439
    root_inventory = property(_get_root_inventory,
 
440
        "Root inventory of this tree")
 
441
 
429
442
    @needs_read_lock
430
443
    def get_parent_ids(self):
431
444
        """See Tree.get_parent_ids.
678
691
 
679
692
        if self._inventory is not None:
680
693
            update_inventory = True
681
 
            inv = self.inventory
 
694
            inv = self.root_inventory
682
695
            to_dir_id = to_entry[0][2]
683
696
            to_dir_ie = inv[to_dir_id]
684
697
        else:
1033
1046
 
1034
1047
        This is a meaningless operation for dirstate, but we obey it anyhow.
1035
1048
        """
1036
 
        return self.inventory
 
1049
        return self.root_inventory
1037
1050
 
1038
1051
    @needs_read_lock
1039
1052
    def revision_tree(self, revision_id):
1147
1160
                # _make_delta if we can't get the RevisionTree
1148
1161
                pass
1149
1162
            else:
1150
 
                delta = rev_tree.inventory._make_delta(basis_tree.inventory)
 
1163
                delta = rev_tree.root_inventory._make_delta(
 
1164
                    basis_tree.root_inventory)
1151
1165
                dirstate.update_basis_by_delta(delta, rev_id)
1152
1166
                updated = True
1153
1167
        if not updated:
1324
1338
        # being created.
1325
1339
        self._inventory = None
1326
1340
        # generate a delta,
1327
 
        delta = inv._make_delta(self.inventory)
 
1341
        delta = inv._make_delta(self.root_inventory)
1328
1342
        # and apply it.
1329
1343
        self.apply_inventory_delta(delta)
1330
1344
        if had_inventory:
1350
1364
            base_tree = trees[0][1]
1351
1365
        state = self.current_dirstate()
1352
1366
        # We don't support ghosts yet
1353
 
        state.set_state_from_scratch(base_tree.inventory, trees, [])
 
1367
        state.set_state_from_scratch(base_tree.root_inventory, trees, [])
1354
1368
 
1355
1369
 
1356
1370
class ContentFilterAwareSHA1Provider(dirstate.SHA1Provider):
1544
1558
                transform.build_tree(basis, wt, accelerator_tree,
1545
1559
                                     hardlink=hardlink,
1546
1560
                                     delta_from_tree=delta_from_tree)
 
1561
                for hook in MutableTree.hooks['post_build_tree']:
 
1562
                    hook(wt)
1547
1563
            finally:
1548
1564
                basis.unlock()
1549
1565
        finally:
1593
1609
        """Overrideable method to get a bzrdir for testing."""
1594
1610
        # please test against something that will let us do tree references
1595
1611
        return bzrdir.format_registry.make_bzrdir(
1596
 
            'dirstate-with-subtree')
 
1612
            'development-subtree')
1597
1613
 
1598
1614
    _matchingbzrdir = property(__get_matchingbzrdir)
1599
1615
 
1867
1883
 
1868
1884
    @needs_read_lock
1869
1885
    def get_file_revision(self, file_id):
1870
 
        return self.inventory[file_id].revision
 
1886
        inv, inv_file_id = self._unpack_file_id(file_id)
 
1887
        return inv[inv_file_id].revision
1871
1888
 
1872
1889
    def get_file(self, file_id, path=None):
1873
1890
        return StringIO(self.get_file_text(file_id))
1874
1891
 
1875
1892
    def get_file_size(self, file_id):
1876
1893
        """See Tree.get_file_size"""
1877
 
        return self.inventory[file_id].text_size
 
1894
        inv, inv_file_id = self._unpack_file_id(file_id)
 
1895
        return inv[inv_file_id].text_size
1878
1896
 
1879
1897
    def get_file_text(self, file_id, path=None):
1880
1898
        _, content = list(self.iter_files_bytes([(file_id, None)]))[0]
1881
1899
        return ''.join(content)
1882
1900
 
1883
1901
    def get_reference_revision(self, file_id, path=None):
1884
 
        return self.inventory[file_id].reference_revision
 
1902
        inv, inv_file_id = self._unpack_file_id(file_id)
 
1903
        return inv[inv_file_id].reference_revision
1885
1904
 
1886
1905
    def iter_files_bytes(self, desired_files):
1887
1906
        """See Tree.iter_files_bytes.
1911
1930
        """Return the revision id for this tree."""
1912
1931
        return self._revision_id
1913
1932
 
1914
 
    def _get_inventory(self):
 
1933
    def _get_root_inventory(self):
1915
1934
        if self._inventory is not None:
1916
1935
            return self._inventory
1917
1936
        self._must_be_locked()
1918
1937
        self._generate_inventory()
1919
1938
        return self._inventory
1920
1939
 
 
1940
    root_inventory = property(_get_root_inventory,
 
1941
                         doc="Inventory of this Tree")
 
1942
 
 
1943
    @deprecated_method(deprecated_in((2, 5, 0)))
 
1944
    def _get_inventory(self):
 
1945
        return self.root_inventory
 
1946
 
1921
1947
    inventory = property(_get_inventory,
1922
1948
                         doc="Inventory of this Tree")
1923
1949
 
1941
1967
 
1942
1968
    def path_content_summary(self, path):
1943
1969
        """See Tree.path_content_summary."""
1944
 
        id = self.inventory.path2id(path)
1945
 
        if id is None:
 
1970
        inv, inv_file_id = self._path2inv_file_id(path)
 
1971
        if inv_file_id is None:
1946
1972
            return ('missing', None, None, None)
1947
 
        entry = self._inventory[id]
 
1973
        entry = inv[inv_file_id]
1948
1974
        kind = entry.kind
1949
1975
        if kind == 'file':
1950
1976
            return (kind, entry.text_size, entry.executable, entry.text_sha1)
1954
1980
            return (kind, None, None, None)
1955
1981
 
1956
1982
    def is_executable(self, file_id, path=None):
1957
 
        ie = self.inventory[file_id]
 
1983
        inv, inv_file_id = self._unpack_file_id(file_id)
 
1984
        ie = inv[inv_file_id]
1958
1985
        if ie.kind != "file":
1959
1986
            return False
1960
1987
        return ie.executable
1965
1992
    def list_files(self, include_root=False, from_dir=None, recursive=True):
1966
1993
        # We use a standard implementation, because DirStateRevisionTree is
1967
1994
        # dealing with one of the parents of the current state
1968
 
        inv = self._get_inventory()
1969
1995
        if from_dir is None:
 
1996
            inv = self.root_inventory
1970
1997
            from_dir_id = None
1971
1998
        else:
1972
 
            from_dir_id = inv.path2id(from_dir)
 
1999
            inv, from_dir_id = self._path2inv_file_id(from_dir)
1973
2000
            if from_dir_id is None:
1974
2001
                # Directory not versioned
1975
2002
                return
 
2003
        # FIXME: Support nested trees
1976
2004
        entries = inv.iter_entries(from_dir=from_dir_id, recursive=recursive)
1977
2005
        if inv.root is not None and not include_root and from_dir is None:
1978
2006
            entries.next()
2028
2056
        # So for now, we just build up the parent inventory, and extract
2029
2057
        # it the same way RevisionTree does.
2030
2058
        _directory = 'directory'
2031
 
        inv = self._get_inventory()
 
2059
        inv = self._get_root_inventory()
2032
2060
        top_id = inv.path2id(prefix)
2033
2061
        if top_id is None:
2034
2062
            pending = []