1491
1495
Do a 'normal' merge of the old branch basis if it is relevant.
1493
1497
old_tip = self.branch.update()
1496
if self.last_revision() != self.branch.last_revision():
1497
# merge tree state up to new branch tip.
1498
basis = self.basis_tree()
1499
to_tree = self.branch.basis_tree()
1500
result += merge_inner(self.branch,
1498
# here if old_tip is not None, it is the old tip of the branch before
1499
# it was updated from the master branch. This should become a pending
1500
# merge in the working tree to preserve the user existing work. we
1501
# cant set that until we update the working trees last revision to be
1502
# one from the new branch, because it will just get absorbed by the
1503
# parent de-duplication logic.
1505
# We MUST save it even if an error occurs, because otherwise the users
1506
# local work is unreferenced and will appear to have been lost.
1509
if self.last_revision() != self.branch.last_revision():
1510
# merge tree state up to new branch tip.
1511
basis = self.basis_tree()
1512
to_tree = self.branch.basis_tree()
1513
result += merge_inner(self.branch,
1517
# when we have set_parent_ids/set_parent_trees we can
1518
# set the pending merge from old tip here if needed. We cant
1519
# set a pending merge for old tip until we've changed the
1520
# primary parent because it will typically have the same value.
1504
1522
self.set_last_revision(self.branch.last_revision())
1505
if old_tip and old_tip != self.last_revision():
1506
# our last revision was not the prior branch last revision
1507
# and we have converted that last revision to a pending merge.
1508
# base is somewhere between the branch tip now
1509
# and the now pending merge
1510
from bzrlib.revision import common_ancestor
1512
base_rev_id = common_ancestor(self.branch.last_revision(),
1514
self.branch.repository)
1515
except errors.NoCommonAncestor:
1517
base_tree = self.branch.repository.revision_tree(base_rev_id)
1518
other_tree = self.branch.repository.revision_tree(old_tip)
1519
result += merge_inner(self.branch,
1524
if old_tip is not None:
1525
self.add_pending_merge(old_tip)
1527
# the working tree had the same last-revision as the master
1528
# branch did. We may still have pivot local work from the local
1529
# branch into old_tip:
1525
1530
if old_tip is not None:
1526
1531
self.add_pending_merge(old_tip)
1532
if old_tip and old_tip != self.last_revision():
1533
# our last revision was not the prior branch last revision
1534
# and we have converted that last revision to a pending merge.
1535
# base is somewhere between the branch tip now
1536
# and the now pending merge
1537
from bzrlib.revision import common_ancestor
1539
base_rev_id = common_ancestor(self.branch.last_revision(),
1541
self.branch.repository)
1542
except errors.NoCommonAncestor:
1544
base_tree = self.branch.repository.revision_tree(base_rev_id)
1545
other_tree = self.branch.repository.revision_tree(old_tip)
1546
result += merge_inner(self.branch,
1528
1552
@needs_write_lock
1529
1553
def _write_inventory(self, inv):