27
from bzrlib.branch import Branch
27
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock, quotefn
29
29
from bzrlib.osutils import appendpath, file_kind, isdir, splitpath, relpath
30
30
from bzrlib.errors import BzrCheckError
94
94
It is possible for a `WorkingTree` to have a filename which is
95
95
not listed in the Inventory and vice versa.
97
98
def __init__(self, basedir, branch=None):
98
99
"""Construct a WorkingTree for basedir.
398
399
def kind(self, file_id):
399
400
return file_kind(self.id2abspath(file_id))
403
"""See Branch.lock_read, and WorkingTree.unlock."""
404
return self.branch.lock_read()
406
def lock_write(self):
407
"""See Branch.lock_write, and WorkingTree.unlock."""
408
return self.branch.lock_write()
411
def remove(self, files, verbose=False):
412
"""Remove nominated files from the working inventory..
414
This does not remove their text. This does not run on XXX on what? RBC
416
TODO: Refuse to remove modified files unless --force is given?
418
TODO: Do something useful with directories.
420
TODO: Should this remove the text or not? Tough call; not
421
removing may be useful and the user can just use use rm, and
422
is the opposite of add. Removing it is consistent with most
423
other tools. Maybe an option.
425
## TODO: Normalize names
426
## TODO: Remove nested loops; better scalability
427
if isinstance(files, basestring):
432
# do this before any modifications
436
raise BzrError("cannot remove unversioned file %s" % quotefn(f))
437
mutter("remove inventory entry %s {%s}" % (quotefn(f), fid))
439
# having remove it, it must be either ignored or unknown
440
if self.is_ignored(f):
444
show_status(new_status, inv[fid].kind, quotefn(f))
447
self.branch._write_inventory(inv)
450
"""See Branch.unlock.
452
WorkingTree locking just uses the Branch locking facilities.
453
This is current because all working trees have an embedded branch
454
within them. IF in the future, we were to make branch data shareable
455
between multiple working trees, i.e. via shared storage, then we
456
would probably want to lock both the local tree, and the branch.
458
return self.branch.unlock()
401
461
CONFLICT_SUFFIXES = ('.THIS', '.BASE', '.OTHER')
402
462
def get_conflicted_stem(path):
403
463
for suffix in CONFLICT_SUFFIXES: