/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

Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
import re
50
50
import stat
51
51
from time import time
 
52
import warnings
52
53
 
53
54
from bzrlib.atomicfile import AtomicFile
54
 
from bzrlib.branch import (Branch,
55
 
                           quotefn)
56
55
from bzrlib.conflicts import Conflict, ConflictList, CONFLICT_SUFFIXES
57
56
import bzrlib.bzrdir as bzrdir
58
57
from bzrlib.decorators import needs_read_lock, needs_write_lock
60
59
from bzrlib.errors import (BzrCheckError,
61
60
                           BzrError,
62
61
                           ConflictFormatError,
63
 
                           DivergedBranches,
64
62
                           WeaveRevisionNotPresent,
65
63
                           NotBranchError,
66
64
                           NoSuchFile,
92
90
from bzrlib.progress import DummyProgress, ProgressPhase
93
91
from bzrlib.revision import NULL_REVISION
94
92
from bzrlib.rio import RioReader, rio_file, Stanza
95
 
from bzrlib.symbol_versioning import *
 
93
from bzrlib.symbol_versioning import (deprecated_passed,
 
94
        deprecated_method,
 
95
        deprecated_function,
 
96
        DEPRECATED_PARAMETER,
 
97
        zero_eight,
 
98
        )
 
99
 
96
100
from bzrlib.textui import show_status
97
101
import bzrlib.tree
98
102
from bzrlib.transform import build_tree
231
235
        self.bzrdir = _bzrdir
232
236
        if not _internal:
233
237
            # not created via open etc.
234
 
            warn("WorkingTree() is deprecated as of bzr version 0.8. "
 
238
            warnings.warn("WorkingTree() is deprecated as of bzr version 0.8. "
235
239
                 "Please use bzrdir.open_workingtree or WorkingTree.open().",
236
240
                 DeprecationWarning,
237
241
                 stacklevel=2)
251
255
        mutter("opening working tree %r", basedir)
252
256
        if deprecated_passed(branch):
253
257
            if not _internal:
254
 
                warn("WorkingTree(..., branch=XXX) is deprecated as of bzr 0.8."
 
258
                warnings.warn("WorkingTree(..., branch=XXX) is deprecated as of bzr 0.8."
255
259
                     " Please use bzrdir.open_workingtree() or"
256
260
                     " WorkingTree.open().",
257
261
                     DeprecationWarning,
260
264
            self._branch = branch
261
265
        else:
262
266
            self._branch = self.bzrdir.open_branch()
263
 
        assert isinstance(self.branch, Branch), \
264
 
            "branch %r is not a Branch" % self.branch
265
267
        self.basedir = realpath(basedir)
266
268
        # if branch is at our basedir and is a format 6 or less
267
269
        if isinstance(self._format, WorkingTreeFormat2):
417
419
        XXX: When BzrDir is present, these should be created through that 
418
420
        interface instead.
419
421
        """
420
 
        warn('delete WorkingTree.create', stacklevel=3)
 
422
        warnings.warn('delete WorkingTree.create', stacklevel=3)
421
423
        transport = get_transport(directory)
422
424
        if branch.bzrdir.root_transport.base == transport.base:
423
425
            # same dir 
455
457
    def get_file_byname(self, filename):
456
458
        return file(self.abspath(filename), 'rb')
457
459
 
 
460
    def get_parent_ids(self):
 
461
        """See Tree.get_parent_ids.
 
462
        
 
463
        This implementation reads the pending merges list and last_revision
 
464
        value and uses that to decide what the parents list should be.
 
465
        """
 
466
        last_rev = self.last_revision()
 
467
        if last_rev is None:
 
468
            parents = []
 
469
        else:
 
470
            parents = [last_rev]
 
471
        other_parents = self.pending_merges()
 
472
        return parents + other_parents
 
473
 
458
474
    def get_root_id(self):
459
475
        """Return the id of this trees root"""
460
476
        inv = self.read_working_inventory()
509
525
        # but with branch a kwarg now, passing in args as is results in the
510
526
        #message being used for the branch
511
527
        args = (DEPRECATED_PARAMETER, message, ) + args
512
 
        Commit().commit(working_tree=self, revprops=revprops, *args, **kwargs)
 
528
        committed_id = Commit().commit( working_tree=self, revprops=revprops,
 
529
            *args, **kwargs)
513
530
        self._set_inventory(self.read_working_inventory())
 
531
        return committed_id
514
532
 
515
533
    def id2abspath(self, file_id):
516
534
        return self.abspath(self.id2path(file_id))
593
611
        inv = self.read_working_inventory()
594
612
        for f,file_id in zip(files, ids):
595
613
            if self.is_control_filename(f):
596
 
                raise BzrError("cannot add control file %s" % quotefn(f))
 
614
                raise errors.ForbiddenControlFileError(filename=f)
597
615
 
598
616
            fp = splitpath(f)
599
617
 
601
619
                raise BzrError("cannot add top-level %r" % f)
602
620
 
603
621
            fullpath = normpath(self.abspath(f))
604
 
 
605
622
            try:
606
623
                kind = file_kind(fullpath)
607
624
            except OSError, e:
608
625
                if e.errno == errno.ENOENT:
609
626
                    raise NoSuchFile(fullpath)
610
 
                # maybe something better?
611
 
                raise BzrError('cannot add: not a regular file, symlink or directory: %s' % quotefn(f))
612
 
 
613
627
            if not InventoryEntry.versionable_kind(kind):
614
 
                raise BzrError('cannot add: not a versionable file ('
615
 
                               'i.e. regular file, symlink or directory): %s' % quotefn(f))
616
 
 
 
628
                raise errors.BadFileKindError(filename=f, kind=kind)
617
629
            if file_id is None:
618
630
                inv.add_path(f, kind=kind)
619
631
            else:
1269
1281
                # TODO: Perhaps make this just a warning, and continue?
1270
1282
                # This tends to happen when 
1271
1283
                raise NotVersionedError(path=f)
1272
 
            mutter("remove inventory entry %s {%s}", quotefn(f), fid)
1273
1284
            if verbose:
1274
1285
                # having remove it, it must be either ignored or unknown
1275
1286
                if self.is_ignored(f):
1276
1287
                    new_status = 'I'
1277
1288
                else:
1278
1289
                    new_status = '?'
1279
 
                show_status(new_status, inv[fid].kind, quotefn(f), to_file=to_file)
 
1290
                show_status(new_status, inv[fid].kind, f, to_file=to_file)
1280
1291
            del inv[fid]
1281
1292
 
1282
1293
        self._write_inventory(inv)
1570
1581
        except NoSuchFile:
1571
1582
            raise errors.NoWorkingTree(base=transport.base)
1572
1583
        except KeyError:
1573
 
            raise errors.UnknownFormatError(format_string)
 
1584
            raise errors.UnknownFormatError(format=format_string)
1574
1585
 
1575
1586
    @classmethod
1576
1587
    def get_default_format(klass):