32
32
def run(self, to_location):
33
33
to_branch = Branch.open(to_location)
35
wt = WorkingTree.open_containing(url)[0]
35
self._switch(tree_location, to_branch)
36
# need to re-open tree to get the new branch
37
tree = WorkingTree.open_containing(tree_location)[0]
40
def _switch(self, tree_location, to_branch):
41
tree = WorkingTree.open_containing(tree_location)[0]
40
unlockables.append(wt)
42
unlockables.append(branch)
43
self._check_switch_branch_format(url)
44
self.set_branch_location(wt.bzrdir, to_branch.base)
44
self._check_switch_branch_format(tree_location)
45
self.set_branch_location(tree.bzrdir, to_branch.base)
45
46
note('Switched to branch: %s' % (to_branch.base,))
50
def _update(self, tree):
53
if tree.last_revision() == tree.branch.last_revision():
54
assert tree.branch.get_master_branch() is None, (
55
"switch tried to update a fat checkout")
56
note("Tree is up to date.")
47
59
note('Updated to revision %d' %
48
(wt.branch.revision_id_to_revno(wt.last_revision()),))
60
(tree.branch.revision_id_to_revno(tree.last_revision()),))
50
for unlockable in unlockables:
53
64
def _check_switch_branch_format(self, url):
54
65
transport = get_transport(url)