~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Martin Pool
  • Date: 2005-10-06 04:09:55 UTC
  • mfrom: (1413)
  • mto: (1185.13.3)
  • mto: This revision was merged to the branch mainline in revision 1417.
  • Revision ID: mbp@sourcefrog.net-20051006040955-36f27e5a8d5c977b
[merge] from robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
 
83
83
    count_copied -- number of revisions copied
84
84
 
85
 
    count_texts -- number of file texts copied
 
85
    count_weaves -- number of file weaves copied
86
86
    """
87
87
    def __init__(self, to_branch, from_branch, last_revision=None, pb=None):
88
88
        if to_branch == from_branch:
96
96
        self.failed_revisions = []
97
97
        self.count_copied = 0
98
98
        self.count_total = 0
99
 
        self.count_texts = 0
 
99
        self.count_weaves = 0
 
100
        self.copied_file_ids = set()
100
101
        if pb is None:
101
102
            self.pb = bzrlib.ui.ui_factory.progress_bar()
102
103
        else:
191
192
        self._copy_inventory(rev_id, inv_xml, parents)
192
193
        self._copy_ancestry(rev_id, parents)
193
194
        self.to_branch.revision_store.add(StringIO(rev_xml), rev_id)
 
195
        mutter('copied revision %s', rev_id)
194
196
 
195
197
 
196
198
    def _copy_inventory(self, rev_id, inv_xml, parent_ids):
210
212
        # in memory until everything's done?  But this way is nicer
211
213
        # if it's interrupted.
212
214
        for path, ie in inv.iter_entries():
213
 
            if not ie.has_text():
214
 
                continue
215
215
            if ie.revision != rev_id:
216
216
                continue
217
217
            mutter('%s {%s} is changed in this revision',
218
218
                   path, ie.file_id)
219
 
            self._copy_one_text(rev_id, ie.file_id)
220
 
 
221
 
 
222
 
    def _copy_one_text(self, rev_id, file_id):
223
 
        """Copy one file text."""
224
 
        mutter('copy text version {%s} of file {%s}',
225
 
               rev_id, file_id)
 
219
            self._copy_one_weave(rev_id, ie.file_id)
 
220
 
 
221
 
 
222
    def _copy_one_weave(self, rev_id, file_id):
 
223
        """Copy one file weave."""
 
224
        mutter('copy file {%s} modified in {%s}', file_id, rev_id)
 
225
        if file_id in self.copied_file_ids:
 
226
            mutter('file {%s} already copied', file_id)
 
227
            return
226
228
        from_weave = self.from_weaves.get_weave(file_id)
227
 
        from_idx = from_weave.lookup(rev_id)
228
 
        from_parents = map(from_weave.idx_to_name, from_weave.parents(from_idx))
229
 
        text_lines = from_weave.get(from_idx)
230
229
        to_weave = self.to_weaves.get_weave_or_empty(file_id)
231
 
        to_parents = map(to_weave.lookup, from_parents)
232
 
        # it's ok to add even if the text is already there
233
 
        to_weave.add(rev_id, to_parents, text_lines)
 
230
        to_weave.join(from_weave)
234
231
        self.to_weaves.put_weave(file_id, to_weave)
235
 
        self.count_texts += 1
 
232
        self.count_weaves += 1
 
233
        self.copied_file_ids.add(file_id)
 
234
        mutter('copied file {%s}', file_id)
236
235
 
237
236
 
238
237
fetch = Fetcher