~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-06-15 03:43:04 UTC
  • Revision ID: mbp@sourcefrog.net-20050615034304-f9419fead7b602dc
- add -r option to the branch command
  patch from aaron

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
        self.branch2 = branch2
111
111
        Exception.__init__(self, "These branches have diverged.")
112
112
 
 
113
 
 
114
class NoSuchRevision(BzrError):
 
115
    def __init__(self, branch, revision):
 
116
        self.branch = branch
 
117
        self.revision = revision
 
118
        msg = "Branch %s has no revision %d" % (branch, revision)
 
119
        BzrError.__init__(self, msg)
 
120
 
 
121
 
113
122
######################################################################
114
123
# branch objects
115
124
 
671
680
            return None
672
681
 
673
682
 
674
 
    def missing_revisions(self, other):
 
683
    def missing_revisions(self, other, stop_revision=None):
675
684
        """
676
685
        If self and other have not diverged, return a list of the revisions
677
686
        present in other, but missing from self.
706
715
        if common_index >= 0 and \
707
716
            self_history[common_index] != other_history[common_index]:
708
717
            raise DivergedBranches(self, other)
709
 
        if self_len < other_len:
710
 
            return other_history[self_len:]
711
 
        return []
712
 
 
713
 
 
714
 
    def update_revisions(self, other):
 
718
 
 
719
        if stop_revision is None:
 
720
            stop_revision = other_len
 
721
        elif stop_revision > other_len:
 
722
            raise NoSuchRevision(self, stop_revision)
 
723
        
 
724
        return other_history[self_len:stop_revision]
 
725
 
 
726
 
 
727
    def update_revisions(self, other, stop_revision=None):
715
728
        """Pull in all new revisions from other branch.
716
729
        
717
730
        >>> from bzrlib.commit import commit
739
752
        pb = ProgressBar()
740
753
 
741
754
        pb.update('comparing histories')
742
 
        revision_ids = self.missing_revisions(other)
 
755
        revision_ids = self.missing_revisions(other, stop_revision)
743
756
        revisions = []
744
757
        needed_texts = sets.Set()
745
758
        i = 0