~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-18 02:21:57 UTC
  • mfrom: (1787 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1794.
  • Revision ID: john@arbash-meinel.com-20060618022157-6e33aa9b67c25e4f
[merge] bzr.dev 1787

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
53
52
 
54
53
from bzrlib.atomicfile import AtomicFile
 
54
from bzrlib.branch import (Branch,
 
55
                           quotefn)
55
56
from bzrlib.conflicts import Conflict, ConflictList, CONFLICT_SUFFIXES
56
57
import bzrlib.bzrdir as bzrdir
57
58
from bzrlib.decorators import needs_read_lock, needs_write_lock
59
60
from bzrlib.errors import (BzrCheckError,
60
61
                           BzrError,
61
62
                           ConflictFormatError,
 
63
                           DivergedBranches,
62
64
                           WeaveRevisionNotPresent,
63
65
                           NotBranchError,
64
66
                           NoSuchFile,
90
92
from bzrlib.progress import DummyProgress, ProgressPhase
91
93
from bzrlib.revision import NULL_REVISION
92
94
from bzrlib.rio import RioReader, rio_file, Stanza
93
 
from bzrlib.symbol_versioning import (deprecated_passed,
94
 
        deprecated_method,
95
 
        deprecated_function,
96
 
        DEPRECATED_PARAMETER,
97
 
        zero_eight,
98
 
        )
99
 
 
 
95
from bzrlib.symbol_versioning import *
100
96
from bzrlib.textui import show_status
101
97
import bzrlib.tree
102
98
from bzrlib.transform import build_tree
235
231
        self.bzrdir = _bzrdir
236
232
        if not _internal:
237
233
            # not created via open etc.
238
 
            warnings.warn("WorkingTree() is deprecated as of bzr version 0.8. "
 
234
            warn("WorkingTree() is deprecated as of bzr version 0.8. "
239
235
                 "Please use bzrdir.open_workingtree or WorkingTree.open().",
240
236
                 DeprecationWarning,
241
237
                 stacklevel=2)
255
251
        mutter("opening working tree %r", basedir)
256
252
        if deprecated_passed(branch):
257
253
            if not _internal:
258
 
                warnings.warn("WorkingTree(..., branch=XXX) is deprecated as of bzr 0.8."
 
254
                warn("WorkingTree(..., branch=XXX) is deprecated as of bzr 0.8."
259
255
                     " Please use bzrdir.open_workingtree() or"
260
256
                     " WorkingTree.open().",
261
257
                     DeprecationWarning,
264
260
            self._branch = branch
265
261
        else:
266
262
            self._branch = self.bzrdir.open_branch()
 
263
        assert isinstance(self.branch, Branch), \
 
264
            "branch %r is not a Branch" % self.branch
267
265
        self.basedir = realpath(basedir)
268
266
        # if branch is at our basedir and is a format 6 or less
269
267
        if isinstance(self._format, WorkingTreeFormat2):
419
417
        XXX: When BzrDir is present, these should be created through that 
420
418
        interface instead.
421
419
        """
422
 
        warnings.warn('delete WorkingTree.create', stacklevel=3)
 
420
        warn('delete WorkingTree.create', stacklevel=3)
423
421
        transport = get_transport(directory)
424
422
        if branch.bzrdir.root_transport.base == transport.base:
425
423
            # same dir 
611
609
        inv = self.read_working_inventory()
612
610
        for f,file_id in zip(files, ids):
613
611
            if self.is_control_filename(f):
614
 
                raise errors.ForbiddenControlFileError(filename=f)
 
612
                raise BzrError("cannot add control file %s" % quotefn(f))
615
613
 
616
614
            fp = splitpath(f)
617
615
 
619
617
                raise BzrError("cannot add top-level %r" % f)
620
618
 
621
619
            fullpath = normpath(self.abspath(f))
 
620
 
622
621
            try:
623
622
                kind = file_kind(fullpath)
624
623
            except OSError, e:
625
624
                if e.errno == errno.ENOENT:
626
625
                    raise NoSuchFile(fullpath)
 
626
                # maybe something better?
 
627
                raise BzrError('cannot add: not a regular file, symlink or directory: %s' % quotefn(f))
 
628
 
627
629
            if not InventoryEntry.versionable_kind(kind):
628
 
                raise errors.BadFileKindError(filename=f, kind=kind)
 
630
                raise BzrError('cannot add: not a versionable file ('
 
631
                               'i.e. regular file, symlink or directory): %s' % quotefn(f))
 
632
 
629
633
            if file_id is None:
630
634
                inv.add_path(f, kind=kind)
631
635
            else:
928
932
 
929
933
        These are files in the working directory that are not versioned or
930
934
        control files or ignored.
 
935
        
 
936
        >>> from bzrlib.bzrdir import ScratchDir
 
937
        >>> d = ScratchDir(files=['foo', 'foo~'])
 
938
        >>> b = d.open_branch()
 
939
        >>> tree = d.open_workingtree()
 
940
        >>> map(str, tree.unknowns())
 
941
        ['foo']
 
942
        >>> tree.add('foo')
 
943
        >>> list(b.unknowns())
 
944
        []
 
945
        >>> tree.remove('foo')
 
946
        >>> list(b.unknowns())
 
947
        [u'foo']
931
948
        """
932
949
        for subp in self.extras():
933
950
            if not self.is_ignored(subp):
1268
1285
                # TODO: Perhaps make this just a warning, and continue?
1269
1286
                # This tends to happen when 
1270
1287
                raise NotVersionedError(path=f)
 
1288
            mutter("remove inventory entry %s {%s}", quotefn(f), fid)
1271
1289
            if verbose:
1272
1290
                # having remove it, it must be either ignored or unknown
1273
1291
                if self.is_ignored(f):
1274
1292
                    new_status = 'I'
1275
1293
                else:
1276
1294
                    new_status = '?'
1277
 
                show_status(new_status, inv[fid].kind, f, to_file=to_file)
 
1295
                show_status(new_status, inv[fid].kind, quotefn(f), to_file=to_file)
1278
1296
            del inv[fid]
1279
1297
 
1280
1298
        self._write_inventory(inv)
1568
1586
        except NoSuchFile:
1569
1587
            raise errors.NoWorkingTree(base=transport.base)
1570
1588
        except KeyError:
1571
 
            raise errors.UnknownFormatError(format=format_string)
 
1589
            raise errors.UnknownFormatError(format_string)
1572
1590
 
1573
1591
    @classmethod
1574
1592
    def get_default_format(klass):