532
533
return BzrDir.open(base, _unsupported=True)
535
def open(base, _unsupported=False):
536
def open(base, _unsupported=False, possible_transports=None):
536
537
"""Open an existing bzrdir, rooted at 'base' (url)
538
539
_unsupported is a private parameter to the BzrDir class.
540
t = get_transport(base)
541
t = get_transport(base, possible_transports=possible_transports)
541
542
return BzrDir.open_from_transport(t, _unsupported=_unsupported)
1083
1084
wt = self.open_workingtree(recommend_upgrade=False)
1084
1085
repository = wt.branch.repository
1085
1086
empty = repository.revision_tree(_mod_revision.NULL_REVISION)
1086
wt.revert([], old_tree=empty)
1087
wt.revert(old_tree=empty)
1087
1088
self.destroy_workingtree_metadata()
1089
1090
def destroy_workingtree_metadata(self):
1804
1805
def _convert_working_inv(self):
1805
1806
inv = xml4.serializer_v4.read_inventory(
1806
1807
self.branch.control_files.get('inventory'))
1807
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
1808
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv, working=True)
1808
1809
# FIXME inventory is a working tree change.
1809
1810
self.branch.control_files.put('inventory', StringIO(new_inv_xml))
1889
1890
present_parents = [p for p in rev.parent_ids
1890
1891
if p not in self.absent_revisions]
1891
1892
self._convert_revision_contents(rev, inv, present_parents)
1892
self._store_new_weave(rev, inv, present_parents)
1893
self._store_new_inv(rev, inv, present_parents)
1893
1894
self.converted_revs.add(rev_id)
1895
def _store_new_weave(self, rev, inv, present_parents):
1896
def _store_new_inv(self, rev, inv, present_parents):
1896
1897
# the XML is now updated with text versions
1898
1899
entries = inv.iter_entries()
1903
1904
(file_id, rev.revision_id)
1904
1905
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
1905
1906
new_inv_sha1 = sha_string(new_inv_xml)
1906
self.inv_weave.add_lines(rev.revision_id,
1907
self.inv_weave.add_lines(rev.revision_id,
1907
1908
present_parents,
1908
1909
new_inv_xml.splitlines(True))
1909
1910
rev.inventory_sha1 = new_inv_sha1
1934
1935
w = Weave(file_id)
1935
1936
self.text_weaves[file_id] = w
1936
1937
text_changed = False
1937
previous_entries = ie.find_previous_heads(parent_invs,
1941
for old_revision in previous_entries:
1942
# if this fails, its a ghost ?
1943
assert old_revision in self.converted_revs, \
1944
"Revision {%s} not in converted_revs" % old_revision
1938
parent_candiate_entries = ie.parent_candidates(parent_invs)
1939
for old_revision in parent_candiate_entries.keys():
1940
# if this fails, its a ghost ?
1941
assert old_revision in self.converted_revs, \
1942
"Revision {%s} not in converted_revs" % old_revision
1943
heads = graph.Graph(self).heads(parent_candiate_entries.keys())
1944
# XXX: Note that this is unordered - and this is tolerable because
1945
# the previous code was also unordered.
1946
previous_entries = dict((head, parent_candiate_entries[head]) for head
1945
1948
self.snapshot_ie(previous_entries, ie, w, rev_id)
1947
1950
assert getattr(ie, 'revision', None) is not None
1952
def get_parents(self, revision_ids):
1953
for revision_id in revision_ids:
1954
yield self.revisions[revision_id].parent_ids
1949
1956
def snapshot_ie(self, previous_revisions, ie, w, rev_id):
1950
1957
# TODO: convert this logic, which is ~= snapshot to
1951
1958
# a call to:. This needs the path figured out. rather than a work_tree