693
693
def add_pending_merge(self, *revision_ids):
694
694
# TODO: Perhaps should check at this point that the
695
695
# history of the revision is actually present?
696
p = self.pending_merges()
697
existing_parents = self.get_parent_ids()
696
parents = self.get_parent_ids()
699
698
for rev_id in revision_ids:
702
if rev_id in existing_parents:
699
if rev_id in parents:
701
parents.append(rev_id)
707
self.set_pending_merges(p)
704
self.set_parent_ids(parents, allow_leftmost_as_ghost=True)
710
707
def pending_merges(self):
735
732
:param revision_ids: The revision_ids to set as the parent ids of this
736
733
working tree. Any of these may be ghosts.
739
for rev_id in revision_ids:
742
(rev_id, self.branch.repository.revision_tree(rev_id)))
743
except errors.RevisionNotPresent:
744
trees.append((rev_id, None))
745
self.set_parent_trees(trees,
746
allow_leftmost_as_ghost=allow_leftmost_as_ghost)
735
if len(revision_ids) > 0:
736
leftmost_id = revision_ids[0]
737
if (not allow_leftmost_as_ghost and not
738
self.branch.repository.has_revision(leftmost_id)):
739
raise errors.GhostRevisionUnusableHere(leftmost_id)
740
self.set_last_revision(leftmost_id)
742
self.set_last_revision(None)
743
merges = revision_ids[1:]
744
self._control_files.put_utf8('pending-merges', '\n'.join(merges))
748
746
@needs_write_lock
749
747
def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
753
751
If tree is None, then that element is treated as an unreachable
754
752
parent tree - i.e. a ghost.
756
if len(parents_list) > 0:
757
leftmost_id = parents_list[0][0]
758
if (not allow_leftmost_as_ghost and not
759
self.branch.repository.has_revision(leftmost_id)):
760
raise errors.GhostRevisionUnusableHere(leftmost_id)
761
self.set_last_revision(leftmost_id)
763
self.set_last_revision(None)
764
merges = parents_list[1:]
765
self.set_pending_merges([revid for revid, tree in merges])
754
# parent trees are not used in current format trees, delegate to
756
self.set_parent_ids([rev for (rev, tree) in parents_list],
757
allow_leftmost_as_ghost=allow_leftmost_as_ghost)
767
759
@needs_write_lock
768
760
def set_pending_merges(self, rev_list):
769
if self.last_revision() is None:
770
new_last_list = rev_list[:1]
771
rev_list = rev_list[1:]
773
self.set_last_revision(new_last_list[0])
774
self._control_files.put_utf8('pending-merges', '\n'.join(rev_list))
761
parents = self.get_parent_ids()
762
leftmost = parents[:1]
763
new_parents = leftmost + rev_list
764
self.set_parent_ids(new_parents)
776
766
@needs_write_lock
777
767
def set_merge_modified(self, modified_hashes):
1434
1424
old_tree = self.basis_tree()
1435
1425
conflicts = revert(self, old_tree, filenames, backups, pb)
1436
1426
if not len(filenames):
1437
self.set_pending_merges([])
1427
self.set_parent_ids(self.get_parent_ids()[:1])
1440
1430
resolve(self, filenames, ignore_misses=True)
1551
1541
# branch did. We may still have pivot local work from the local
1552
1542
# branch into old_tip:
1553
1543
if old_tip is not None:
1554
self.add_pending_merge(old_tip)
1544
self.add_parent_tree_id(old_tip)
1555
1545
if old_tip and old_tip != self.last_revision():
1556
1546
# our last revision was not the prior branch last revision
1557
1547
# and we have converted that last revision to a pending merge.