~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

Merge direct pack access branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
from bzrlib import (
35
35
    bzrdir,
36
36
    cache_utf8,
37
 
    conflicts as _mod_conflicts,
38
37
    debug,
39
38
    dirstate,
40
39
    errors,
52
51
from bzrlib.decorators import needs_read_lock, needs_write_lock
53
52
from bzrlib.inventory import Inventory, ROOT_ID, entry_factory
54
53
from bzrlib.lock import LogicalLockResult
55
 
from bzrlib.lockable_files import LockableFiles
56
 
from bzrlib.lockdir import LockDir
57
54
from bzrlib.mutabletree import needs_tree_write_lock
58
55
from bzrlib.osutils import (
59
56
    file_kind,
63
60
    safe_unicode,
64
61
    )
65
62
from bzrlib.transport.local import LocalTransport
66
 
from bzrlib.tree import (
67
 
    InterTree,
68
 
    InventoryTree,
69
 
    )
70
 
from bzrlib.workingtree import (
71
 
    InventoryWorkingTree,
72
 
    WorkingTree,
73
 
    WorkingTreeFormat,
74
 
    )
75
 
 
76
 
 
77
 
class DirStateWorkingTree(InventoryWorkingTree):
78
 
 
 
63
from bzrlib.tree import InterTree
 
64
from bzrlib.tree import Tree
 
65
from bzrlib.workingtree import WorkingTree, WorkingTree3, WorkingTreeFormat3
 
66
 
 
67
 
 
68
class DirStateWorkingTree(WorkingTree3):
79
69
    def __init__(self, basedir,
80
70
                 branch,
81
71
                 _control_files=None,
131
121
            state.add(f, file_id, kind, None, '')
132
122
        self._make_dirty(reset_inventory=True)
133
123
 
134
 
    def _get_check_refs(self):
135
 
        """Return the references needed to perform a check of this tree."""
136
 
        return [('trees', self.last_revision())]
137
 
 
138
124
    def _make_dirty(self, reset_inventory):
139
125
        """Make the tree state dirty.
140
126
 
192
178
 
193
179
    def _comparison_data(self, entry, path):
194
180
        kind, executable, stat_value = \
195
 
            WorkingTree._comparison_data(self, entry, path)
 
181
            WorkingTree3._comparison_data(self, entry, path)
196
182
        # it looks like a plain directory, but it's really a reference -- see
197
183
        # also kind()
198
184
        if (self._repo_supports_tree_reference and kind == 'directory'
204
190
    def commit(self, message=None, revprops=None, *args, **kwargs):
205
191
        # mark the tree as dirty post commit - commit
206
192
        # can change the current versioned list by doing deletes.
207
 
        result = WorkingTree.commit(self, message, revprops, *args, **kwargs)
 
193
        result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
208
194
        self._make_dirty(reset_inventory=True)
209
195
        return result
210
196
 
1264
1250
    def rename_one(self, from_rel, to_rel, after=False):
1265
1251
        """See WorkingTree.rename_one"""
1266
1252
        self.flush()
1267
 
        super(DirStateWorkingTree, self).rename_one(from_rel, to_rel, after)
 
1253
        WorkingTree.rename_one(self, from_rel, to_rel, after)
1268
1254
 
1269
1255
    @needs_tree_write_lock
1270
1256
    def apply_inventory_delta(self, changes):
1380
1366
class WorkingTree4(DirStateWorkingTree):
1381
1367
    """This is the Format 4 working tree.
1382
1368
 
1383
 
    This differs from WorkingTree by:
 
1369
    This differs from WorkingTree3 by:
1384
1370
     - Having a consolidated internal dirstate, stored in a
1385
1371
       randomly-accessible sorted file on disk.
1386
1372
     - Not having a regular inventory attribute.  One can be synthesized
1414
1400
        return views.PathBasedViews(self)
1415
1401
 
1416
1402
 
1417
 
class DirStateWorkingTreeFormat(WorkingTreeFormat):
 
1403
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
1418
1404
 
1419
1405
    missing_parent_conflicts = True
1420
1406
 
1421
 
    _lock_class = LockDir
1422
 
    _lock_file_name = 'lock'
1423
 
 
1424
 
    def _open_control_files(self, a_bzrdir):
1425
 
        transport = a_bzrdir.get_workingtree_transport(None)
1426
 
        return LockableFiles(transport, self._lock_file_name,
1427
 
                             self._lock_class)
1428
 
 
1429
1407
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1430
1408
                   accelerator_tree=None, hardlink=False):
1431
1409
        """See WorkingTreeFormat.initialize().
1530
1508
        :param wt: the WorkingTree object
1531
1509
        """
1532
1510
 
1533
 
    def open(self, a_bzrdir, _found=False):
1534
 
        """Return the WorkingTree object for a_bzrdir
1535
 
 
1536
 
        _found is a private parameter, do not use it. It is used to indicate
1537
 
               if format probing has already been done.
1538
 
        """
1539
 
        if not _found:
1540
 
            # we are being called directly and must probe.
1541
 
            raise NotImplementedError
1542
 
        if not isinstance(a_bzrdir.transport, LocalTransport):
1543
 
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
1544
 
        wt = self._open(a_bzrdir, self._open_control_files(a_bzrdir))
1545
 
        return wt
1546
 
 
1547
1511
    def _open(self, a_bzrdir, control_files):
1548
1512
        """Open the tree itself.
1549
1513
 
1640
1604
        return True
1641
1605
 
1642
1606
 
1643
 
class DirStateRevisionTree(InventoryTree):
 
1607
class DirStateRevisionTree(Tree):
1644
1608
    """A revision tree pulling the inventory from a dirstate.
1645
1609
    
1646
1610
    Note that this is one of the historical (ie revision) trees cached in the
1665
1629
    def annotate_iter(self, file_id,
1666
1630
                      default_revision=_mod_revision.CURRENT_REVISION):
1667
1631
        """See Tree.annotate_iter"""
1668
 
        text_key = (file_id, self.get_file_revision(file_id))
 
1632
        text_key = (file_id, self.inventory[file_id].revision)
1669
1633
        annotations = self._repository.texts.annotate(text_key)
1670
1634
        return [(key[-1], line) for (key, line) in annotations]
1671
1635
 
1835
1799
            return parent_details[1]
1836
1800
        return None
1837
1801
 
1838
 
    @needs_read_lock
1839
 
    def get_file_revision(self, file_id):
1840
 
        return self.inventory[file_id].revision
1841
 
 
1842
1802
    def get_file(self, file_id, path=None):
1843
1803
        return StringIO(self.get_file_text(file_id))
1844
1804
 
2045
2005
    def make_source_parent_tree(source, target):
2046
2006
        """Change the source tree into a parent of the target."""
2047
2007
        revid = source.commit('record tree')
2048
 
        target.branch.fetch(source.branch, revid)
 
2008
        target.branch.repository.fetch(source.branch.repository, revid)
2049
2009
        target.set_parent_ids([revid])
2050
2010
        return target.basis_tree(), target
2051
2011