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.
671
606
# function - they should be part of lock_write and unlock.
672
607
inv = self.inventory
673
608
for f, file_id, kind in zip(files, ids, kinds):
674
assert kind is not None
675
609
if file_id is None:
676
610
inv.add_path(f, kind=kind)
773
707
return (kind, None, None, None)
775
@deprecated_method(zero_eleven)
777
def pending_merges(self):
778
"""Return a list of pending merges.
780
These are revisions that have been merged into the working
781
directory but not yet committed.
783
As of 0.11 this is deprecated. Please see WorkingTree.get_parent_ids()
784
instead - which is available on all tree objects.
786
return self.get_parent_ids()[1:]
788
709
def _check_parents_for_ghosts(self, revision_ids, allow_leftmost_as_ghost):
789
710
"""Common ghost checking functionality from set_parent_*.
1276
1197
DeprecationWarning)
1278
1199
# check destination directory
1279
assert not isinstance(from_paths, basestring)
1200
if isinstance(from_paths, basestring):
1280
1202
inv = self.inventory
1281
1203
to_abs = self.abspath(to_dir)
1282
1204
if not isdir(to_abs):
1546
1468
# - RBC 20060907
1547
1469
self._write_inventory(self._inventory)
1549
@deprecated_method(zero_eight)
1550
def iter_conflicts(self):
1551
"""List all files in the tree that have text or content conflicts.
1552
DEPRECATED. Use conflicts instead."""
1553
return self._iter_conflicts()
1555
1471
def _iter_conflicts(self):
1556
1472
conflicted = set()
1557
1473
for info in self.list_files():
1828
1744
def _write_basis_inventory(self, xml):
1829
1745
"""Write the basis inventory XML to the basis-inventory file"""
1830
assert isinstance(xml, str), 'serialised xml must be bytestring.'
1831
1746
path = self._basis_inventory_name()
1832
1747
sio = StringIO(xml)
1833
1748
self._control_files.put(path, sio)
2097
2012
"""Set the root id for this tree."""
2098
2013
# for compatability
2099
2014
if file_id is None:
2100
symbol_versioning.warn(symbol_versioning.zero_twelve
2101
% 'WorkingTree.set_root_id with fileid=None',
2106
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)
2107
2018
self._set_root_id(file_id)
2109
2020
def _set_root_id(self, file_id):
2651
2562
return path[:-len(suffix)]
2654
@deprecated_function(zero_eight)
2655
def is_control_file(filename):
2656
"""See WorkingTree.is_control_filename(filename)."""
2657
## FIXME: better check
2658
filename = normpath(filename)
2659
while filename != '':
2660
head, tail = os.path.split(filename)
2661
## mutter('check %r for control file' % ((head, tail),))
2664
if filename == head:
2670
2565
class WorkingTreeFormat(object):
2671
2566
"""An encapsulation of the initialization and open routines for a format.