/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Robert Collins
  • Date: 2006-08-17 04:28:45 UTC
  • mto: (1908.6.5 use set_parent_trees.)
  • mto: This revision was merged to the branch mainline in revision 1972.
  • Revision ID: robertc@robertcollins.net-20060817042845-74baf6dc1e04b201
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.

Show diffs side-by-side

added added

removed removed

Lines of Context:
653
653
        self._write_inventory(inv)
654
654
 
655
655
    @needs_write_lock
656
 
    def add_parent_tree_id(self, revision_id):
 
656
    def add_parent_tree_id(self, revision_id, allow_leftmost_as_ghost=False):
657
657
        """Add revision_id as a parent.
658
658
 
659
659
        This is equivalent to retrieving the current list of parent ids
662
662
        :param revision_id: The revision id to add to the parent list. It may
663
663
        be a ghost revision.
664
664
        """
665
 
        self.set_parent_ids(self.get_parent_ids() + [revision_id])
 
665
        self.set_parent_ids(self.get_parent_ids() + [revision_id],
 
666
            allow_leftmost_as_ghost=allow_leftmost_as_ghost)
666
667
 
667
668
    @needs_write_lock
668
 
    def add_parent_tree(self, parent_tuple):
 
669
    def add_parent_tree(self, parent_tuple, allow_leftmost_as_ghost=False):
669
670
        """Add revision_id, tree tuple as a parent.
670
671
 
671
672
        This is equivalent to retrieving the current list of parent trees
676
677
 
677
678
        :param parent_tuple: The (revision id, tree) to add to the parent list.             If the revision_id is a ghost, pass None for the tree.
678
679
        """
679
 
        self.set_parent_ids(self.get_parent_ids() + [parent_tuple[0]])
 
680
        self.set_parent_ids(self.get_parent_ids() + [parent_tuple[0]],
 
681
            allow_leftmost_as_ghost=allow_leftmost_as_ghost)
680
682
 
681
683
    @needs_write_lock
682
684
    def add_pending_merge(self, *revision_ids):
712
714
        return p
713
715
 
714
716
    @needs_write_lock
715
 
    def set_parent_ids(self, revision_ids):
 
717
    def set_parent_ids(self, revision_ids, allow_leftmost_as_ghost=False):
716
718
        """Set the parent ids to revision_ids.
717
719
        
718
720
        See also set_parent_trees. This api will try to retrieve the tree data
732
734
            except errors.RevisionNotPresent:
733
735
                trees.append((rev_id, None))
734
736
                pass
735
 
        self.set_parent_trees(trees)
 
737
        self.set_parent_trees(trees,
 
738
            allow_leftmost_as_ghost=allow_leftmost_as_ghost)
736
739
 
737
740
    @needs_write_lock
738
 
    def set_parent_trees(self, parents_list):
 
741
    def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
739
742
        """Set the parents of the working tree.
740
743
 
741
744
        :param parents_list: A list of (revision_id, tree) tuples. 
744
747
        """
745
748
        parent = parents_list[:1]
746
749
        if len(parent):
 
750
            if (not allow_leftmost_as_ghost and not
 
751
                self.branch.repository.has_revision(parent[0][0])):
 
752
                raise errors.GhostRevision(parent[0][0])
747
753
            self.set_last_revision(parent[0][0])
748
754
        else:
749
755
            self.set_last_revision(None)
1245
1251
        for regex, mapping in rules:
1246
1252
            match = regex.match(filename)
1247
1253
            if match is not None:
1248
 
                # one or more of the groups in mapping will have a non-None group 
1249
 
                # match.
 
1254
                # one or more of the groups in mapping will have a non-None
 
1255
                # group match.
1250
1256
                groups = match.groups()
1251
1257
                rules = [mapping[group] for group in 
1252
1258
                    mapping if groups[group] is not None]