~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Martin Pool
  • Date: 2006-06-20 03:57:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1798.
  • Revision ID: mbp@sourcefrog.net-20060620035711-400bb6b6bc6ff95b
Add pyflakes makefile target; fix many warnings

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
92
91
from bzrlib.progress import DummyProgress, ProgressPhase
93
92
from bzrlib.revision import NULL_REVISION
94
93
from bzrlib.rio import RioReader, rio_file, Stanza
95
 
from bzrlib.symbol_versioning import *
 
94
from bzrlib.symbol_versioning import (deprecated_passed,
 
95
        deprecated_method,
 
96
        deprecated_function,
 
97
        DEPRECATED_PARAMETER,
 
98
        zero_eight,
 
99
        )
 
100
 
96
101
from bzrlib.textui import show_status
97
102
import bzrlib.tree
98
103
from bzrlib.transform import build_tree
231
236
        self.bzrdir = _bzrdir
232
237
        if not _internal:
233
238
            # not created via open etc.
234
 
            warn("WorkingTree() is deprecated as of bzr version 0.8. "
 
239
            warnings.warn("WorkingTree() is deprecated as of bzr version 0.8. "
235
240
                 "Please use bzrdir.open_workingtree or WorkingTree.open().",
236
241
                 DeprecationWarning,
237
242
                 stacklevel=2)
251
256
        mutter("opening working tree %r", basedir)
252
257
        if deprecated_passed(branch):
253
258
            if not _internal:
254
 
                warn("WorkingTree(..., branch=XXX) is deprecated as of bzr 0.8."
 
259
                warnings.warn("WorkingTree(..., branch=XXX) is deprecated as of bzr 0.8."
255
260
                     " Please use bzrdir.open_workingtree() or"
256
261
                     " WorkingTree.open().",
257
262
                     DeprecationWarning,
260
265
            self._branch = branch
261
266
        else:
262
267
            self._branch = self.bzrdir.open_branch()
263
 
        assert isinstance(self.branch, Branch), \
264
 
            "branch %r is not a Branch" % self.branch
265
268
        self.basedir = realpath(basedir)
266
269
        # if branch is at our basedir and is a format 6 or less
267
270
        if isinstance(self._format, WorkingTreeFormat2):
417
420
        XXX: When BzrDir is present, these should be created through that 
418
421
        interface instead.
419
422
        """
420
 
        warn('delete WorkingTree.create', stacklevel=3)
 
423
        warnings.warn('delete WorkingTree.create', stacklevel=3)
421
424
        transport = get_transport(directory)
422
425
        if branch.bzrdir.root_transport.base == transport.base:
423
426
            # same dir 
593
596
        inv = self.read_working_inventory()
594
597
        for f,file_id in zip(files, ids):
595
598
            if self.is_control_filename(f):
596
 
                raise BzrError("cannot add control file %s" % quotefn(f))
 
599
                raise errors.ForbiddenFileError(filename=f)
597
600
 
598
601
            fp = splitpath(f)
599
602
 
601
604
                raise BzrError("cannot add top-level %r" % f)
602
605
 
603
606
            fullpath = normpath(self.abspath(f))
604
 
 
605
607
            try:
606
608
                kind = file_kind(fullpath)
607
609
            except OSError, e:
608
610
                if e.errno == errno.ENOENT:
609
611
                    raise NoSuchFile(fullpath)
610
 
                # maybe something better?
611
 
                raise BzrError('cannot add: not a regular file, symlink or directory: %s' % quotefn(f))
612
 
 
613
612
            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
 
 
 
613
                raise errors.BadFileKindError(filename=f, kind=kind)
617
614
            if file_id is None:
618
615
                inv.add_path(f, kind=kind)
619
616
            else:
1269
1266
                # TODO: Perhaps make this just a warning, and continue?
1270
1267
                # This tends to happen when 
1271
1268
                raise NotVersionedError(path=f)
1272
 
            mutter("remove inventory entry %s {%s}", quotefn(f), fid)
1273
1269
            if verbose:
1274
1270
                # having remove it, it must be either ignored or unknown
1275
1271
                if self.is_ignored(f):
1276
1272
                    new_status = 'I'
1277
1273
                else:
1278
1274
                    new_status = '?'
1279
 
                show_status(new_status, inv[fid].kind, quotefn(f), to_file=to_file)
 
1275
                show_status(new_status, inv[fid].kind, f, to_file=to_file)
1280
1276
            del inv[fid]
1281
1277
 
1282
1278
        self._write_inventory(inv)