/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.py

  • Committer: Robert Collins
  • Date: 2007-04-04 05:19:38 UTC
  • mfrom: (2395 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2401.
  • Revision ID: robertc@robertcollins.net-20070404051938-2lnvpsm2tbo5a6g2
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
    revisiontree,
69
69
    repository,
70
70
    textui,
 
71
    trace,
71
72
    transform,
 
73
    ui,
72
74
    urlutils,
73
75
    xml5,
74
76
    xml6,
208
210
                 _internal=False,
209
211
                 _format=None,
210
212
                 _bzrdir=None):
211
 
        """Construct a WorkingTree for basedir.
 
213
        """Construct a WorkingTree instance. This is not a public API.
212
214
 
213
 
        If the branch is not supplied, it is opened automatically.
214
 
        If the branch is supplied, it must be the branch for this basedir.
215
 
        (branch.base is not cross checked, because for remote branches that
216
 
        would be meaningless).
 
215
        :param branch: A branch to override probing for the branch.
217
216
        """
218
217
        self._format = _format
219
218
        self.bzrdir = _bzrdir
220
219
        if not _internal:
221
 
            # not created via open etc.
222
 
            warnings.warn("WorkingTree() is deprecated as of bzr version 0.8. "
223
 
                 "Please use bzrdir.open_workingtree or WorkingTree.open().",
224
 
                 DeprecationWarning,
225
 
                 stacklevel=2)
226
 
            wt = WorkingTree.open(basedir)
227
 
            self._branch = wt.branch
228
 
            self.basedir = wt.basedir
229
 
            self._control_files = wt._control_files
230
 
            self._hashcache = wt._hashcache
231
 
            self._set_inventory(wt._inventory, dirty=False)
232
 
            self._format = wt._format
233
 
            self.bzrdir = wt.bzrdir
 
220
            raise errors.BzrError("Please use bzrdir.open_workingtree or "
 
221
                "WorkingTree.open() to obtain a WorkingTree.")
234
222
        assert isinstance(basedir, basestring), \
235
223
            "base directory %r is not a string" % basedir
236
224
        basedir = safe_unicode(basedir)
237
225
        mutter("opening working tree %r", basedir)
238
226
        if deprecated_passed(branch):
239
 
            if not _internal:
240
 
                warnings.warn("WorkingTree(..., branch=XXX) is deprecated"
241
 
                     " as of bzr 0.8. Please use bzrdir.open_workingtree() or"
242
 
                     " WorkingTree.open().",
243
 
                     DeprecationWarning,
244
 
                     stacklevel=2
245
 
                     )
246
227
            self._branch = branch
247
228
        else:
248
229
            self._branch = self.bzrdir.open_branch()
545
526
        return self.abspath(self.id2path(file_id))
546
527
 
547
528
    @needs_read_lock
548
 
    def clone(self, to_bzrdir, revision_id=None, basis=None):
 
529
    def clone(self, to_bzrdir, revision_id=None):
549
530
        """Duplicate this working tree into to_bzr, including all state.
550
531
        
551
532
        Specifically modified files are kept as modified, but
557
538
            If not None, the cloned tree will have its last revision set to 
558
539
            revision, and and difference between the source trees last revision
559
540
            and this one merged in.
560
 
 
561
 
        basis
562
 
            If not None, a closer copy of a tree which may have some files in
563
 
            common, and which file content should be preferentially copied from.
564
541
        """
565
542
        # assumes the target bzr dir format is compatible.
566
543
        result = self._format.initialize(to_bzrdir)
1418
1395
        # prevent race conditions with the lock
1419
1396
        return iter(
1420
1397
            [subp for subp in self.extras() if not self.is_ignored(subp)])
1421
 
    
 
1398
 
1422
1399
    @needs_tree_write_lock
1423
1400
    def unversion(self, file_ids):
1424
1401
        """Remove the file ids in file_ids from the current versioned set.
2288
2265
        self.set_conflicts(un_resolved)
2289
2266
        return un_resolved, resolved
2290
2267
 
 
2268
    def _validate(self):
 
2269
        """Validate internal structures.
 
2270
 
 
2271
        This is meant mostly for the test suite. To give it a chance to detect
 
2272
        corruption after actions have occurred. The default implementation is a
 
2273
        just a no-op.
 
2274
 
 
2275
        :return: None. An exception should be raised if there is an error.
 
2276
        """
 
2277
        return
 
2278
 
2291
2279
 
2292
2280
class WorkingTree2(WorkingTree):
2293
2281
    """This is the Format 2 working tree.
2453
2441
 
2454
2442
    requires_rich_root = False
2455
2443
 
 
2444
    upgrade_recommended = False
 
2445
 
2456
2446
    @classmethod
2457
2447
    def find_format(klass, a_bzrdir):
2458
2448
        """Return the format for the working tree object in a_bzrdir."""
2507
2497
        del klass._formats[format.get_format_string()]
2508
2498
 
2509
2499
 
2510
 
 
2511
2500
class WorkingTreeFormat2(WorkingTreeFormat):
2512
2501
    """The second working tree format. 
2513
2502
 
2514
2503
    This format modified the hash cache from the format 1 hash cache.
2515
2504
    """
2516
2505
 
 
2506
    upgrade_recommended = True
 
2507
 
2517
2508
    def get_format_description(self):
2518
2509
        """See WorkingTreeFormat.get_format_description()."""
2519
2510
        return "Working tree format 2"
2582
2573
            raise NotImplementedError
2583
2574
        if not isinstance(a_bzrdir.transport, LocalTransport):
2584
2575
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2585
 
        return WorkingTree2(a_bzrdir.root_transport.local_abspath('.'),
 
2576
        wt = WorkingTree2(a_bzrdir.root_transport.local_abspath('.'),
2586
2577
                           _internal=True,
2587
2578
                           _format=self,
2588
2579
                           _bzrdir=a_bzrdir)
2589
 
 
 
2580
        return wt
2590
2581
 
2591
2582
class WorkingTreeFormat3(WorkingTreeFormat):
2592
2583
    """The second working tree format updated to record a format marker.
2599
2590
        - is new in bzr 0.8
2600
2591
        - uses a LockDir to guard access for writes.
2601
2592
    """
 
2593
    
 
2594
    upgrade_recommended = True
2602
2595
 
2603
2596
    def get_format_string(self):
2604
2597
        """See WorkingTreeFormat.get_format_string()."""
2689
2682
            raise NotImplementedError
2690
2683
        if not isinstance(a_bzrdir.transport, LocalTransport):
2691
2684
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2692
 
        return self._open(a_bzrdir, self._open_control_files(a_bzrdir))
 
2685
        wt = self._open(a_bzrdir, self._open_control_files(a_bzrdir))
 
2686
        return wt
2693
2687
 
2694
2688
    def _open(self, a_bzrdir, control_files):
2695
2689
        """Open the tree itself.