~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Robert Collins
  • Date: 2005-10-10 23:18:27 UTC
  • mfrom: (1437)
  • mto: This revision was merged to the branch mainline in revision 1438.
  • Revision ID: robertc@robertcollins.net-20051010231827-f9e2dda2e92bf565
mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import os
18
18
from cStringIO import StringIO
19
19
 
20
 
import bzrlib.errors
 
20
import bzrlib
 
21
import bzrlib.errors as errors
 
22
from bzrlib.errors import InstallFailed, NoSuchRevision, WeaveError
21
23
from bzrlib.trace import mutter, note, warning
22
24
from bzrlib.branch import Branch
23
25
from bzrlib.progress import ProgressBar
24
26
from bzrlib.xml5 import serializer_v5
25
27
from bzrlib.osutils import sha_string, split_lines
26
 
from bzrlib.errors import InstallFailed, NoSuchRevision, WeaveError
27
28
 
28
29
"""Copying of history from one branch to another.
29
30
 
102
103
            self.pb = bzrlib.ui.ui_factory.progress_bar()
103
104
        else:
104
105
            self.pb = pb
 
106
        self.from_branch.lock_read()
 
107
        try:
 
108
            self._fetch_revisions(last_revision)
 
109
        finally:
 
110
            self.from_branch.unlock()
 
111
            self.pb.clear()
 
112
 
 
113
    def _fetch_revisions(self, last_revision):
105
114
        try:
106
115
            self.last_revision = self._find_last_revision(last_revision)
107
116
        except NoSuchRevision, e:
115
124
        self._copy_revisions(revs_to_fetch)
116
125
        self.new_ancestry = revs_to_fetch
117
126
 
118
 
 
119
127
    def _find_last_revision(self, last_revision):
120
128
        """Find the limiting source revision.
121
129
 
218
226
        if file_id in self.copied_file_ids:
219
227
            mutter('file {%s} already copied', file_id)
220
228
            return
221
 
        from_weave = self.from_weaves.get_weave(file_id, 
 
229
        from_weave = self.from_weaves.get_weave(file_id,
222
230
            self.from_branch.get_transaction())
223
231
        to_weave = self.to_weaves.get_weave_or_empty(file_id,
224
232
            self.to_branch.get_transaction())
225
 
        to_weave.join(from_weave)
 
233
        try:
 
234
            to_weave.join(from_weave)
 
235
        except errors.WeaveParentMismatch:
 
236
            to_weave.reweave(from_weave)
226
237
        self.to_weaves.put_weave(file_id, to_weave,
227
238
            self.to_branch.get_transaction())
228
239
        self.count_weaves += 1