379
379
"""Return RevisionTree for the current last revision.
381
381
If the left most parent is a ghost then the returned tree will be an
382
empty tree - one obtained by calling repository.revision_tree(None).
382
empty tree - one obtained by calling
383
repository.revision_tree(NULL_REVISION).
385
386
revision_id = self.get_parent_ids()[0]
387
388
# no parents, return an empty revision tree.
388
389
# in the future this should return the tree for
389
390
# 'empty:' - the implicit root empty tree.
390
return self.branch.repository.revision_tree(None)
391
return self.branch.repository.revision_tree(
392
_mod_revision.NULL_REVISION)
392
394
return self.revision_tree(revision_id)
393
395
except errors.NoSuchRevision:
404
406
if self.branch.repository.has_revision(revision_id):
406
408
# the basis tree is a ghost so return an empty tree.
407
return self.branch.repository.revision_tree(None)
409
return self.branch.repository.revision_tree(
410
_mod_revision.NULL_REVISION)
409
412
def _cleanup(self):
410
413
self._flush_ignore_list_cache()
520
523
and this one merged in.
522
525
# assumes the target bzr dir format is compatible.
523
result = self._format.initialize(to_bzrdir)
526
result = to_bzrdir.create_workingtree()
524
527
self.copy_content_into(result, revision_id)
1316
1319
only_change_inv = True
1317
1320
elif self.has_filename(from_rel) and not self.has_filename(to_rel):
1318
1321
only_change_inv = False
1319
elif (sys.platform == 'win32'
1320
and from_rel.lower() == to_rel.lower()
1321
and self.has_filename(from_rel)):
1322
elif (not self.case_sensitive
1323
and from_rel.lower() == to_rel.lower()
1324
and self.has_filename(from_rel)):
1322
1325
only_change_inv = False
1324
1327
# something is wrong, so lets determine what exactly
1859
1862
# Recurse directory and add all files
1860
1863
# so we can check if they have changed.
1861
1864
for parent_info, file_infos in\
1862
osutils.walkdirs(self.abspath(directory),
1864
for relpath, basename, kind, lstat, abspath in file_infos:
1865
self.walkdirs(directory):
1866
for relpath, basename, kind, lstat, fileid, kind in file_infos:
1865
1867
# Is it versioned or ignored?
1866
1868
if self.path2id(relpath) or self.is_ignored(relpath):
1867
1869
# Add nested content for deletion.
2419
2420
# FIXME: stash the node in pending
2420
2421
entry = inv[top_id]
2421
for name, child in entry.sorted_children():
2422
dirblock.append((relroot + name, name, child.kind, None,
2423
child.file_id, child.kind
2422
if entry.kind == 'directory':
2423
for name, child in entry.sorted_children():
2424
dirblock.append((relroot + name, name, child.kind, None,
2425
child.file_id, child.kind
2425
2427
yield (currentdir[0], entry.file_id), dirblock
2426
2428
# push the user specified dirs from dirblock
2427
2429
for dir in reversed(dirblock):
2715
2717
"""See WorkingTreeFormat.get_format_description()."""
2716
2718
return "Working tree format 2"
2718
def _stub_initialize_remote(self, branch):
2719
"""As a special workaround create critical control files for a remote working tree.
2720
def _stub_initialize_on_transport(self, transport, file_mode):
2721
"""Workaround: create control files for a remote working tree.
2721
2723
This ensures that it can later be updated and dealt with locally,
2722
since BzrDirFormat6 and BzrDirFormat5 cannot represent dirs with
2724
since BzrDirFormat6 and BzrDirFormat5 cannot represent dirs with
2723
2725
no working tree. (See bug #43064).
2725
2727
sio = StringIO()
2726
2728
inv = Inventory()
2727
2729
xml5.serializer_v5.write_inventory(inv, sio, working=True)
2729
branch._transport.put_file('inventory', sio,
2730
mode=branch.control_files._file_mode)
2731
branch._transport.put_bytes('pending-merges', '',
2732
mode=branch.control_files._file_mode)
2731
transport.put_file('inventory', sio, file_mode)
2732
transport.put_bytes('pending-merges', '', file_mode)
2735
2734
def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
2736
2735
accelerator_tree=None, hardlink=False):