/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/fetch.py

[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import bzrlib
22
22
import bzrlib.errors as errors
23
 
from bzrlib.errors import InstallFailed, NoSuchRevision, WeaveError
 
23
from bzrlib.errors import (InstallFailed, NoSuchRevision, WeaveError,
 
24
                           MissingText)
24
25
from bzrlib.trace import mutter, note, warning
25
26
from bzrlib.branch import Branch
26
27
from bzrlib.progress import ProgressBar
100
101
        self.count_total = 0
101
102
        self.count_weaves = 0
102
103
        self.copied_file_ids = set()
 
104
        self.file_ids_names = {}
103
105
        if pb is None:
104
106
            self.pb = bzrlib.ui.ui_factory.progress_bar()
105
107
        else:
212
214
        # in memory until everything's done?  But this way is nicer
213
215
        # if it's interrupted.
214
216
        for path, ie in inv.iter_entries():
215
 
            if ie.revision != rev_id:
216
 
                continue
217
 
            mutter('%s {%s} is changed in this revision',
218
 
                   path, ie.file_id)
219
 
            self._copy_one_weave(rev_id, ie.file_id)
 
217
            self._copy_one_weave(rev_id, ie.file_id, ie.revision)
220
218
 
221
 
    def _copy_one_weave(self, rev_id, file_id):
222
 
        """Copy one file weave."""
223
 
        mutter('copy file {%s} modified in {%s}', file_id, rev_id)
224
 
        if file_id in self.copied_file_ids:
225
 
            mutter('file {%s} already copied', file_id)
 
219
    def _copy_one_weave(self, rev_id, file_id, text_revision):
 
220
        """Copy one file weave, esuring the result contains text_revision."""
 
221
        # check if the revision is already there
 
222
        if file_id in self.file_ids_names.keys( ) and \
 
223
            text_revision in self.file_ids_names[file_id]:
 
224
                return        
 
225
        to_weave = self.to_weaves.get_weave_or_empty(file_id,
 
226
            self.to_branch.get_transaction())
 
227
        if not file_id in self.file_ids_names.keys( ):
 
228
            self.file_ids_names[file_id] = to_weave.names( )
 
229
        if text_revision in to_weave:
226
230
            return
227
231
        from_weave = self.from_weaves.get_weave(file_id,
228
232
            self.from_branch.get_transaction())
229
 
        to_weave = self.to_weaves.get_weave_or_empty(file_id,
230
 
            self.to_branch.get_transaction())
231
 
        try:
232
 
            to_weave.join(from_weave)
233
 
        except errors.WeaveParentMismatch:
234
 
            to_weave.reweave(from_weave)
 
233
        if text_revision not in from_weave:
 
234
            raise MissingText(self.from_branch, text_revision, file_id)
 
235
        mutter('copy file {%s} modified in {%s}', file_id, rev_id)
 
236
 
 
237
        if to_weave.numversions() > 0:
 
238
            # destination has contents, must merge
 
239
            try:
 
240
                to_weave.join(from_weave)
 
241
            except errors.WeaveParentMismatch:
 
242
                to_weave.reweave(from_weave)
 
243
        else:
 
244
            # destination is empty, just replace it
 
245
            to_weave = from_weave.copy( )
235
246
        self.to_weaves.put_weave(file_id, to_weave,
236
247
            self.to_branch.get_transaction())
237
248
        self.count_weaves += 1
238
249
        self.copied_file_ids.add(file_id)
 
250
        self.file_ids_names[file_id] = to_weave.names()
239
251
        mutter('copied file {%s}', file_id)
240
252
 
241
253