657
657
self._write_inventory(inv)
659
659
@needs_write_lock
660
def add_parent_tree_id(self, revision_id, allow_leftmost_as_ghost=False):
661
"""Add revision_id as a parent.
663
This is equivalent to retrieving the current list of parent ids
664
and setting the list to its value plus revision_id.
666
:param revision_id: The revision id to add to the parent list. It may
667
be a ghost revision as long as its not the first parent to be added,
668
or the allow_leftmost_as_ghost parameter is set True.
669
:param allow_leftmost_as_ghost: Allow the first parent to be a ghost.
671
parents = self.get_parent_ids() + [revision_id]
672
self.set_parent_ids(parents,
673
allow_leftmost_as_ghost=len(parents) > 1 or allow_leftmost_as_ghost)
676
def add_parent_tree(self, parent_tuple, allow_leftmost_as_ghost=False):
677
"""Add revision_id, tree tuple as a parent.
679
This is equivalent to retrieving the current list of parent trees
680
and setting the list to its value plus parent_tuple. See also
681
add_parent_tree_id - if you only have a parent id available it will be
682
simpler to use that api. If you have the parent already available, using
683
this api is preferred.
685
:param parent_tuple: The (revision id, tree) to add to the parent list.
686
If the revision_id is a ghost, pass None for the tree.
687
:param allow_leftmost_as_ghost: Allow the first parent to be a ghost.
689
self.set_parent_ids(self.get_parent_ids() + [parent_tuple[0]],
690
allow_leftmost_as_ghost=allow_leftmost_as_ghost)
660
693
def add_pending_merge(self, *revision_ids):
661
694
# TODO: Perhaps should check at this point that the
662
695
# history of the revision is actually present?
692
725
@needs_write_lock
726
def set_parent_ids(self, revision_ids, allow_leftmost_as_ghost=False):
727
"""Set the parent ids to revision_ids.
729
See also set_parent_trees. This api will try to retrieve the tree data
730
for each element of revision_ids from the trees repository. If you have
731
tree data already available, it is more efficient to use
732
set_parent_trees rather than set_parent_ids. set_parent_ids is however
733
an easier API to use.
735
:param revision_ids: The revision_ids to set as the parent ids of this
736
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)
749
def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
750
"""Set the parents of the working tree.
752
:param parents_list: A list of (revision_id, tree) tuples.
753
If tree is None, then that element is treated as an unreachable
754
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])
693
768
def set_pending_merges(self, rev_list):
694
769
if self.last_revision() is None:
695
770
new_last_list = rev_list[:1]
1184
1259
for regex, mapping in rules:
1185
1260
match = regex.match(filename)
1186
1261
if match is not None:
1187
# one or more of the groups in mapping will have a non-None group
1262
# one or more of the groups in mapping will have a non-None
1189
1264
groups = match.groups()
1190
1265
rules = [mapping[group] for group in
1191
1266
mapping if groups[group] is not None]