/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-08 16:02:52 UTC
  • mfrom: (5837 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5838.
  • Revision ID: jelmer@samba.org-20110508160252-akovn3laoln5sfx9
merge bzr.dev.

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,
37
38
    debug,
38
39
    dirstate,
39
40
    errors,
51
52
from bzrlib.decorators import needs_read_lock, needs_write_lock
52
53
from bzrlib.inventory import Inventory, ROOT_ID, entry_factory
53
54
from bzrlib.lock import LogicalLockResult
 
55
from bzrlib.lockable_files import LockableFiles
 
56
from bzrlib.lockdir import LockDir
54
57
from bzrlib.mutabletree import needs_tree_write_lock
55
58
from bzrlib.osutils import (
56
59
    file_kind,
65
68
    InventoryTree,
66
69
    )
67
70
from bzrlib.workingtree import (
 
71
    InventoryWorkingTree,
68
72
    WorkingTree,
69
 
    WorkingTree3,
70
 
    WorkingTreeFormat3,
 
73
    WorkingTreeFormat,
71
74
    )
72
75
 
73
76
 
74
 
class DirStateWorkingTree(WorkingTree3):
 
77
class DirStateWorkingTree(InventoryWorkingTree):
 
78
 
 
79
    _DEFAULT_WORTH_SAVING_LIMIT = 10
75
80
 
76
81
    def __init__(self, basedir,
77
82
                 branch,
128
133
            state.add(f, file_id, kind, None, '')
129
134
        self._make_dirty(reset_inventory=True)
130
135
 
 
136
    def _get_check_refs(self):
 
137
        """Return the references needed to perform a check of this tree."""
 
138
        return [('trees', self.last_revision())]
 
139
 
131
140
    def _make_dirty(self, reset_inventory):
132
141
        """Make the tree state dirty.
133
142
 
185
194
 
186
195
    def _comparison_data(self, entry, path):
187
196
        kind, executable, stat_value = \
188
 
            WorkingTree3._comparison_data(self, entry, path)
 
197
            WorkingTree._comparison_data(self, entry, path)
189
198
        # it looks like a plain directory, but it's really a reference -- see
190
199
        # also kind()
191
200
        if (self._repo_supports_tree_reference and kind == 'directory'
197
206
    def commit(self, message=None, revprops=None, *args, **kwargs):
198
207
        # mark the tree as dirty post commit - commit
199
208
        # can change the current versioned list by doing deletes.
200
 
        result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
 
209
        result = WorkingTree.commit(self, message, revprops, *args, **kwargs)
201
210
        self._make_dirty(reset_inventory=True)
202
211
        return result
203
212
 
222
231
        local_path = self.bzrdir.get_workingtree_transport(None
223
232
            ).local_abspath('dirstate')
224
233
        self._dirstate = dirstate.DirState.on_file(local_path,
225
 
            self._sha1_provider())
 
234
            self._sha1_provider(), self._worth_saving_limit())
226
235
        return self._dirstate
227
236
 
228
237
    def _sha1_provider(self):
237
246
        else:
238
247
            return None
239
248
 
 
249
    def _worth_saving_limit(self):
 
250
        """How many hash changes are ok before we must save the dirstate.
 
251
 
 
252
        :return: an integer. -1 means never save.
 
253
        """
 
254
        config = self.branch.get_config()
 
255
        val = config.get_user_option('bzr.workingtree.worth_saving_limit')
 
256
        if val is None:
 
257
            val = self._DEFAULT_WORTH_SAVING_LIMIT
 
258
        else:
 
259
            try:
 
260
                val = int(val)
 
261
            except ValueError, e:
 
262
                trace.warning('Invalid config value for'
 
263
                              ' "bzr.workingtree.worth_saving_limit"'
 
264
                              ' value %r is not an integer.'
 
265
                              % (val,))
 
266
                val = self._DEFAULT_WORTH_SAVING_LIMIT
 
267
        return val
 
268
 
240
269
    def filter_unversioned_files(self, paths):
241
270
        """Filter out paths that are versioned.
242
271
 
853
882
                rollback_rename()
854
883
                raise
855
884
            result.append((from_rel, to_rel))
856
 
            state._dirblock_state = dirstate.DirState.IN_MEMORY_MODIFIED
 
885
            state._mark_modified()
857
886
            self._make_dirty(reset_inventory=False)
858
887
 
859
888
        return result
1373
1402
class WorkingTree4(DirStateWorkingTree):
1374
1403
    """This is the Format 4 working tree.
1375
1404
 
1376
 
    This differs from WorkingTree3 by:
 
1405
    This differs from WorkingTree by:
1377
1406
     - Having a consolidated internal dirstate, stored in a
1378
1407
       randomly-accessible sorted file on disk.
1379
1408
     - Not having a regular inventory attribute.  One can be synthesized
1407
1436
        return views.PathBasedViews(self)
1408
1437
 
1409
1438
 
1410
 
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
 
1439
class DirStateWorkingTreeFormat(WorkingTreeFormat):
1411
1440
 
1412
1441
    missing_parent_conflicts = True
1413
1442
 
 
1443
    _lock_class = LockDir
 
1444
    _lock_file_name = 'lock'
 
1445
 
 
1446
    def _open_control_files(self, a_bzrdir):
 
1447
        transport = a_bzrdir.get_workingtree_transport(None)
 
1448
        return LockableFiles(transport, self._lock_file_name,
 
1449
                             self._lock_class)
 
1450
 
1414
1451
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1415
1452
                   accelerator_tree=None, hardlink=False):
1416
1453
        """See WorkingTreeFormat.initialize().
1515
1552
        :param wt: the WorkingTree object
1516
1553
        """
1517
1554
 
 
1555
    def open(self, a_bzrdir, _found=False):
 
1556
        """Return the WorkingTree object for a_bzrdir
 
1557
 
 
1558
        _found is a private parameter, do not use it. It is used to indicate
 
1559
               if format probing has already been done.
 
1560
        """
 
1561
        if not _found:
 
1562
            # we are being called directly and must probe.
 
1563
            raise NotImplementedError
 
1564
        if not isinstance(a_bzrdir.transport, LocalTransport):
 
1565
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
 
1566
        wt = self._open(a_bzrdir, self._open_control_files(a_bzrdir))
 
1567
        return wt
 
1568
 
1518
1569
    def _open(self, a_bzrdir, control_files):
1519
1570
        """Open the tree itself.
1520
1571