1420
1424
Do a 'normal' merge of the old branch basis if it is relevant.
1422
1426
old_tip = self.branch.update()
1425
if self.last_revision() != self.branch.last_revision():
1426
# merge tree state up to new branch tip.
1427
basis = self.basis_tree()
1428
to_tree = self.branch.basis_tree()
1429
result += merge_inner(self.branch,
1427
# here if old_tip is not None, it is the old tip of the branch before
1428
# it was updated from the master branch. This should become a pending
1429
# merge in the working tree to preserve the user existing work. we
1430
# cant set that until we update the working trees last revision to be
1431
# one from the new branch, because it will just get absorbed by the
1432
# parent de-duplication logic.
1434
# We MUST save it even if an error occurs, because otherwise the users
1435
# local work is unreferenced and will appear to have been lost.
1438
if self.last_revision() != self.branch.last_revision():
1439
# merge tree state up to new branch tip.
1440
basis = self.basis_tree()
1441
to_tree = self.branch.basis_tree()
1442
result += merge_inner(self.branch,
1446
# when we have set_parent_ids/set_parent_trees we can
1447
# set the pending merge from old tip here if needed. We cant
1448
# set a pending merge for old tip until we've changed the
1449
# primary parent because it will typically have the same value.
1433
1451
self.set_last_revision(self.branch.last_revision())
1434
if old_tip and old_tip != self.last_revision():
1435
# our last revision was not the prior branch last revision
1436
# and we have converted that last revision to a pending merge.
1437
# base is somewhere between the branch tip now
1438
# and the now pending merge
1439
from bzrlib.revision import common_ancestor
1441
base_rev_id = common_ancestor(self.branch.last_revision(),
1443
self.branch.repository)
1444
except errors.NoCommonAncestor:
1446
base_tree = self.branch.repository.revision_tree(base_rev_id)
1447
other_tree = self.branch.repository.revision_tree(old_tip)
1448
result += merge_inner(self.branch,
1453
if old_tip is not None:
1454
self.add_pending_merge(old_tip)
1456
# the working tree had the same last-revision as the master
1457
# branch did. We may still have pivot local work from the local
1458
# branch into old_tip:
1454
1459
if old_tip is not None:
1455
1460
self.add_pending_merge(old_tip)
1461
if old_tip and old_tip != self.last_revision():
1462
# our last revision was not the prior branch last revision
1463
# and we have converted that last revision to a pending merge.
1464
# base is somewhere between the branch tip now
1465
# and the now pending merge
1466
from bzrlib.revision import common_ancestor
1468
base_rev_id = common_ancestor(self.branch.last_revision(),
1470
self.branch.repository)
1471
except errors.NoCommonAncestor:
1473
base_tree = self.branch.repository.revision_tree(base_rev_id)
1474
other_tree = self.branch.repository.revision_tree(old_tip)
1475
result += merge_inner(self.branch,
1457
1481
@needs_write_lock
1458
1482
def _write_inventory(self, inv):