50
50
from bzrlib.branch import (Branch,
55
53
from bzrlib.errors import (BzrCheckError,
58
56
WeaveRevisionNotPresent,
61
60
from bzrlib.inventory import InventoryEntry
62
61
from bzrlib.osutils import (appendpath,
412
412
self.set_pending_merges(p)
414
415
def pending_merges(self):
415
416
"""Return a list of pending merges.
417
418
These are revisions that have been merged into the working
418
419
directory but not yet committed.
420
cfn = self.branch._rel_controlfilename('pending-merges')
421
if not self.branch._transport.has(cfn):
422
f = self.branch.control_files.get_utf8('pending-merges')
424
for l in self.branch.controlfile('pending-merges', 'r').readlines():
426
for l in f.readlines():
425
427
p.append(l.rstrip('\n'))
428
430
@needs_write_lock
429
431
def set_pending_merges(self, rev_list):
430
self.branch.put_controlfile('pending-merges', '\n'.join(rev_list))
432
self.branch.control_files.put_utf8('pending-merges', '\n'.join(rev_list))
432
434
def get_symlink_target(self, file_id):
433
435
return os.readlink(self.id2abspath(file_id))
676
678
other_revision = old_revision_history[-1]
678
680
other_revision = None
681
repository = self.branch.repository
679
682
merge_inner(self.branch,
680
683
self.branch.basis_tree(),
681
self.branch.revision_tree(other_revision))
684
repository.revision_tree(other_revision))
789
792
return 'basis-inventory.%s' % revision_id
791
794
def set_last_revision(self, new_revision, old_revision=None):
795
if old_revision is not None:
794
797
path = self._basis_inventory_name(old_revision)
795
path = self.branch._rel_controlfilename(path)
796
self.branch._transport.delete(path)
798
path = self.branch.control_files._escape(path)
799
self.branch.control_files._transport.delete(path)
800
xml = self.branch.get_inventory_xml(new_revision)
803
xml = self.branch.repository.get_inventory_xml(new_revision)
801
804
path = self._basis_inventory_name(new_revision)
802
self.branch.put_controlfile(path, xml)
805
self.branch.control_files.put_utf8(path, xml)
803
806
except WeaveRevisionNotPresent:
806
809
def read_basis_inventory(self, revision_id):
807
810
"""Read the cached basis inventory."""
808
811
path = self._basis_inventory_name(revision_id)
809
return self.branch.controlfile(path, 'r').read()
812
return self.branch.control_files.get_utf8(path).read()
812
815
def read_working_inventory(self):
813
816
"""Read the working inventory."""
814
817
# ElementTree does its own conversion from UTF-8, so open in
816
f = self.branch.controlfile('inventory', 'rb')
819
f = self.branch.control_files.get('inventory')
817
820
return bzrlib.xml5.serializer_v5.read_inventory(f)
819
822
@needs_write_lock
915
918
between multiple working trees, i.e. via shared storage, then we
916
919
would probably want to lock both the local tree, and the branch.
918
if self._hashcache.needs_write and self.branch._lock_count==1:
921
# FIXME: We want to write out the hashcache only when the last lock on
922
# this working copy is released. Peeking at the lock count is a bit
923
# of a nasty hack; probably it's better to have a transaction object,
924
# which can do some finalization when it's either successfully or
925
# unsuccessfully completed. (Denys's original patch did that.)
926
if self._hashcache.needs_write and self.branch.control_files._lock_count==1:
919
927
self._hashcache.write()
920
928
return self.branch.unlock()