123
120
ERROR_PATH_NOT_FOUND = 3 # WindowsError errno code, equivalent to ENOENT
126
@deprecated_function(zero_thirteen)
127
def gen_file_id(name):
128
"""Return new file id for the basename 'name'.
130
Use bzrlib.generate_ids.gen_file_id() instead
132
return generate_ids.gen_file_id(name)
135
@deprecated_function(zero_thirteen)
137
"""Return a new tree-root file id.
139
This has been deprecated in favor of bzrlib.generate_ids.gen_root_id()
141
return generate_ids.gen_root_id()
144
123
class TreeEntry(object):
145
124
"""An entry that implements the minimum interface used by commands.
222
201
if not _internal:
223
202
raise errors.BzrError("Please use bzrdir.open_workingtree or "
224
203
"WorkingTree.open() to obtain a WorkingTree.")
225
assert isinstance(basedir, basestring), \
226
"base directory %r is not a string" % basedir
227
204
basedir = safe_unicode(basedir)
228
205
mutter("opening working tree %r", basedir)
229
206
if deprecated_passed(branch):
237
214
self._control_files = self.branch.control_files
239
216
# assume all other formats have their own control files.
240
assert isinstance(_control_files, LockableFiles), \
241
"_control_files must be a LockableFiles, not %r" \
243
217
self._control_files = _control_files
244
218
# update the whole cache up front and write to disk if anything changed;
245
219
# in the future we might want to do this more selectively
434
407
def _cleanup(self):
435
408
self._flush_ignore_list_cache()
438
@deprecated_method(zero_eight)
439
def create(branch, directory):
440
"""Create a workingtree for branch at directory.
442
If existing_directory already exists it must have a .bzr directory.
443
If it does not exist, it will be created.
445
This returns a new WorkingTree object for the new checkout.
447
TODO FIXME RBC 20060124 when we have checkout formats in place this
448
should accept an optional revisionid to checkout [and reject this if
449
checking out into the same dir as a pre-checkout-aware branch format.]
451
XXX: When BzrDir is present, these should be created through that
454
warnings.warn('delete WorkingTree.create', stacklevel=3)
455
transport = get_transport(directory)
456
if branch.bzrdir.root_transport.base == transport.base:
458
return branch.bzrdir.create_workingtree()
459
# different directory,
460
# create a branch reference
461
# and now a working tree.
462
raise NotImplementedError
465
@deprecated_method(zero_eight)
466
def create_standalone(directory):
467
"""Create a checkout and a branch and a repo at directory.
469
Directory must exist and be empty.
471
please use BzrDir.create_standalone_workingtree
473
return bzrdir.BzrDir.create_standalone_workingtree(directory)
475
410
def relpath(self, path):
476
411
"""Return the local path portion from a given path.
618
553
__contains__ = has_id
620
555
def get_file_size(self, file_id):
621
return os.path.getsize(self.id2abspath(file_id))
556
"""See Tree.get_file_size"""
558
return os.path.getsize(self.id2abspath(file_id))
560
if e.errno != errno.ENOENT:
624
566
def get_file_sha1(self, file_id, path=None, stat_value=None):
664
606
# function - they should be part of lock_write and unlock.
665
607
inv = self.inventory
666
608
for f, file_id, kind in zip(files, ids, kinds):
667
assert kind is not None
668
609
if file_id is None:
669
610
inv.add_path(f, kind=kind)
766
707
return (kind, None, None, None)
768
@deprecated_method(zero_eleven)
770
def pending_merges(self):
771
"""Return a list of pending merges.
773
These are revisions that have been merged into the working
774
directory but not yet committed.
776
As of 0.11 this is deprecated. Please see WorkingTree.get_parent_ids()
777
instead - which is available on all tree objects.
779
return self.get_parent_ids()[1:]
781
709
def _check_parents_for_ghosts(self, revision_ids, allow_leftmost_as_ghost):
782
710
"""Common ghost checking functionality from set_parent_*.
1269
1197
DeprecationWarning)
1271
1199
# check destination directory
1272
assert not isinstance(from_paths, basestring)
1200
if isinstance(from_paths, basestring):
1273
1202
inv = self.inventory
1274
1203
to_abs = self.abspath(to_dir)
1275
1204
if not isdir(to_abs):
1539
1468
# - RBC 20060907
1540
1469
self._write_inventory(self._inventory)
1542
@deprecated_method(zero_eight)
1543
def iter_conflicts(self):
1544
"""List all files in the tree that have text or content conflicts.
1545
DEPRECATED. Use conflicts instead."""
1546
return self._iter_conflicts()
1548
1471
def _iter_conflicts(self):
1549
1472
conflicted = set()
1550
1473
for info in self.list_files():
1821
1744
def _write_basis_inventory(self, xml):
1822
1745
"""Write the basis inventory XML to the basis-inventory file"""
1823
assert isinstance(xml, str), 'serialised xml must be bytestring.'
1824
1746
path = self._basis_inventory_name()
1825
1747
sio = StringIO(xml)
1826
1748
self._control_files.put(path, sio)
2090
2012
"""Set the root id for this tree."""
2091
2013
# for compatability
2092
2014
if file_id is None:
2093
symbol_versioning.warn(symbol_versioning.zero_twelve
2094
% 'WorkingTree.set_root_id with fileid=None',
2099
file_id = osutils.safe_file_id(file_id)
2016
'WorkingTree.set_root_id with fileid=None')
2017
file_id = osutils.safe_file_id(file_id)
2100
2018
self._set_root_id(file_id)
2102
2020
def _set_root_id(self, file_id):
2644
2562
return path[:-len(suffix)]
2647
@deprecated_function(zero_eight)
2648
def is_control_file(filename):
2649
"""See WorkingTree.is_control_filename(filename)."""
2650
## FIXME: better check
2651
filename = normpath(filename)
2652
while filename != '':
2653
head, tail = os.path.split(filename)
2654
## mutter('check %r for control file' % ((head, tail),))
2657
if filename == head:
2663
2565
class WorkingTreeFormat(object):
2664
2566
"""An encapsulation of the initialization and open routines for a format.