~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2006-04-12 04:57:34 UTC
  • mto: This revision was merged to the branch mainline in revision 1654.
  • Revision ID: robertc@robertcollins.net-20060412045734-3e03b7af0860a5a9
 * 'pull' and 'push' now normalise the revision history, so that any two
   branches with the same tip revision will have the same output from 'log'.
   (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
333
333
        """
334
334
        raise NotImplementedError('update_revisions is abstract')
335
335
 
336
 
    def pullable_revisions(self, other, stop_revision):
337
 
        raise NotImplementedError('pullable_revisions is abstract')
338
 
        
339
336
    def revision_id_to_revno(self, revision_id):
340
337
        """Given a revision id, return its revno"""
341
338
        if revision_id is None:
1016
1013
        # transaction.register_clean(history, precious=True)
1017
1014
        return list(history)
1018
1015
 
 
1016
    @needs_write_lock
1019
1017
    def update_revisions(self, other, stop_revision=None):
1020
1018
        """See Branch.update_revisions."""
1021
 
        if stop_revision is None:
1022
 
            stop_revision = other.last_revision()
1023
 
        ### Should this be checking is_ancestor instead of revision_history?
1024
 
        if (stop_revision is not None and 
1025
 
            stop_revision in self.revision_history()):
1026
 
            return
1027
 
        self.fetch(other, stop_revision)
1028
 
        pullable_revs = self.pullable_revisions(other, stop_revision)
1029
 
        if len(pullable_revs) > 0:
1030
 
            self.append_revision(*pullable_revs)
 
1019
        other.lock_read()
 
1020
        try:
 
1021
            if stop_revision is None:
 
1022
                stop_revision = other.last_revision()
 
1023
                if stop_revision is None:
 
1024
                    # if there are no commits, we're done.
 
1025
                    return
 
1026
            # whats the current last revision, before we fetch [and change it
 
1027
            # possibly]
 
1028
            last_rev = self.last_revision()
 
1029
            # we fetch here regardless of whether we need to so that we pickup
 
1030
            # filled in ghosts.
 
1031
            self.fetch(other, stop_revision)
 
1032
            my_ancestry = self.repository.get_ancestry(last_rev)
 
1033
            if stop_revision in my_ancestry:
 
1034
                # last_revision is a descendant of stop_revision
 
1035
                return
 
1036
            # stop_revision must be a descendant of last_revision
 
1037
            stop_graph = self.repository.get_revision_graph(stop_revision)
 
1038
            if last_rev is not None and last_rev not in stop_graph:
 
1039
                # our previous tip is not merged into stop_revision
 
1040
                raise errors.DivergedBranches(self, other)
 
1041
            # make a new revision history from the graph
 
1042
            current_rev_id = stop_revision
 
1043
            new_history = []
 
1044
            while current_rev_id not in (None, NULL_REVISION):
 
1045
                new_history.append(current_rev_id)
 
1046
                current_rev_id_parents = stop_graph[current_rev_id]
 
1047
                try:
 
1048
                    current_rev_id = current_rev_id_parents[0]
 
1049
                except IndexError:
 
1050
                    current_rev_id = None
 
1051
            new_history.reverse()
 
1052
            self.set_revision_history(new_history)
 
1053
        finally:
 
1054
            other.unlock()
1031
1055
 
 
1056
    @deprecated_method(zero_eight)
1032
1057
    def pullable_revisions(self, other, stop_revision):
 
1058
        """Please use bzrlib.missing instead."""
1033
1059
        other_revno = other.revision_id_to_revno(stop_revision)
1034
1060
        try:
1035
1061
            return self.missing_revisions(other, other_revno)