~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Robert Collins
  • Date: 2005-09-29 00:24:44 UTC
  • Revision ID: robertc@robertcollins.net-20050929002444-76fe66e99fb9bcd5
reinstate testfetch test case

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib.progress import ProgressBar
24
24
from bzrlib.xml5 import serializer_v5
25
25
from bzrlib.osutils import sha_string, split_lines
26
 
from bzrlib.errors import NoSuchRevision
 
26
from bzrlib.errors import InstallFailed, NoSuchRevision, WeaveError
27
27
 
28
28
"""Copying of history from one branch to another.
29
29
 
87
87
    def __init__(self, to_branch, from_branch, last_revision=None, pb=None):
88
88
        self.to_branch = to_branch
89
89
        self.to_weaves = to_branch.weave_store
90
 
        self.to_control = to_branch.control_weaves
 
90
        self.to_control = to_branch.control_weaves
91
91
        self.from_branch = from_branch
92
92
        self.from_weaves = from_branch.weave_store
93
 
        self.from_control = from_branch.control_weaves
 
93
        self.from_control = from_branch.control_weaves
94
94
        self.failed_revisions = []
95
95
        self.count_copied = 0
96
96
        self.count_total = 0
99
99
            self.pb = bzrlib.ui.ui_factory.progress_bar()
100
100
        else:
101
101
            self.pb = pb
102
 
        self.last_revision = self._find_last_revision(last_revision)
 
102
        try:
 
103
            self.last_revision = self._find_last_revision(last_revision)
 
104
        except NoSuchRevision:
 
105
            raise InstallFailed([last_revision])
103
106
        mutter('fetch up to rev {%s}', self.last_revision)
104
 
        revs_to_fetch = self._compare_ancestries()
 
107
        try:
 
108
            revs_to_fetch = self._compare_ancestries()
 
109
        except WeaveError:
 
110
            raise InstallFailed([self.last_revision])
105
111
        self._copy_revisions(revs_to_fetch)
106
112
        self.new_ancestry = revs_to_fetch
107
113
 
108
 
        
109
114
 
110
115
    def _find_last_revision(self, last_revision):
111
116
        """Find the limiting source revision.
118
123
        from_history = self.from_branch.revision_history()
119
124
        self.pb.update('get destination history')
120
125
        if last_revision:
121
 
            if last_revision not in from_history:
122
 
                raise NoSuchRevision(self.from_branch, last_revision)
123
 
            else:
124
 
                return last_revision
 
126
            self.from_branch.get_revision(last_revision)
 
127
            return last_revision
125
128
        elif from_history:
126
129
            return from_history[-1]
127
130
        else:
151
154
        mutter('need to get %d revisions in total', len(to_fetch))
152
155
        self.count_total = len(to_fetch)
153
156
        return to_fetch
154
 
                
155
 
 
156
157
 
157
158
    def _copy_revisions(self, revs_to_fetch):
158
159
        i = 0