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)
897
900
hashfile = self._transport.get('merge-hashes')
898
901
except errors.NoSuchFile:
902
if hashfile.next() != MERGE_MODIFIED_HEADER_1 + '\n':
906
if hashfile.next() != MERGE_MODIFIED_HEADER_1 + '\n':
907
raise errors.MergeModifiedFormatError()
908
except StopIteration:
903
909
raise errors.MergeModifiedFormatError()
904
except StopIteration:
905
raise errors.MergeModifiedFormatError()
906
for s in RioReader(hashfile):
907
# RioReader reads in Unicode, so convert file_ids back to utf8
908
file_id = osutils.safe_file_id(s.get("file_id"), warn=False)
909
if file_id not in self.inventory:
911
text_hash = s.get("hash")
912
if text_hash == self.get_file_sha1(file_id):
913
merge_hashes[file_id] = text_hash
910
for s in RioReader(hashfile):
911
# RioReader reads in Unicode, so convert file_ids back to utf8
912
file_id = osutils.safe_file_id(s.get("file_id"), warn=False)
913
if file_id not in self.inventory:
915
text_hash = s.get("hash")
916
if text_hash == self.get_file_sha1(file_id):
917
merge_hashes[file_id] = text_hash
916
922
@needs_write_lock
917
923
def mkdir(self, path, file_id=None):
2593
2599
except errors.NoSuchFile:
2594
2600
return _mod_conflicts.ConflictList()
2596
if confile.next() != CONFLICT_HEADER_1 + '\n':
2603
if confile.next() != CONFLICT_HEADER_1 + '\n':
2604
raise errors.ConflictFormatError()
2605
except StopIteration:
2597
2606
raise errors.ConflictFormatError()
2598
except StopIteration:
2599
raise errors.ConflictFormatError()
2600
return _mod_conflicts.ConflictList.from_stanzas(RioReader(confile))
2607
return _mod_conflicts.ConflictList.from_stanzas(RioReader(confile))
2602
2611
def unlock(self):
2603
2612
# do non-implementation specific cleanup
2714
2723
"""See WorkingTreeFormat.get_format_description()."""
2715
2724
return "Working tree format 2"
2717
def _stub_initialize_remote(self, branch):
2718
"""As a special workaround create critical control files for a remote working tree.
2726
def _stub_initialize_on_transport(self, transport, file_mode):
2727
"""Workaround: create control files for a remote working tree.
2720
2729
This ensures that it can later be updated and dealt with locally,
2721
since BzrDirFormat6 and BzrDirFormat5 cannot represent dirs with
2730
since BzrDirFormat6 and BzrDirFormat5 cannot represent dirs with
2722
2731
no working tree. (See bug #43064).
2724
2733
sio = StringIO()
2725
2734
inv = Inventory()
2726
2735
xml5.serializer_v5.write_inventory(inv, sio, working=True)
2728
branch._transport.put_file('inventory', sio,
2729
mode=branch.control_files._file_mode)
2730
branch._transport.put_bytes('pending-merges', '',
2731
mode=branch.control_files._file_mode)
2737
transport.put_file('inventory', sio, file_mode)
2738
transport.put_bytes('pending-merges', '', file_mode)
2734
2740
def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
2735
2741
accelerator_tree=None, hardlink=False):