~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Aaron Bentley
  • Date: 2005-12-25 00:38:48 UTC
  • mto: (1185.67.11 bzr.revision-storage)
  • mto: This revision was merged to the branch mainline in revision 1550.
  • Revision ID: aaron.bentley@utoronto.ca-20051225003848-111ac71170cb2605
Renamed Branch.storage to Branch.repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
        if to_branch == from_branch:
92
92
            raise Exception("can't fetch from a branch to itself")
93
93
        self.to_branch = to_branch
94
 
        self.to_storage = to_branch.storage
95
 
        self.to_weaves = self.to_storage.weave_store
96
 
        self.to_control = self.to_storage.control_weaves
 
94
        self.to_repository = to_branch.repository
 
95
        self.to_weaves = self.to_repository.weave_store
 
96
        self.to_control = self.to_repository.control_weaves
97
97
        self.from_branch = from_branch
98
 
        self.from_storage = from_branch.storage
99
 
        self.from_weaves = self.from_storage.weave_store
100
 
        self.from_control = self.from_storage.control_weaves
 
98
        self.from_repository = from_branch.repository
 
99
        self.from_weaves = self.from_repository.weave_store
 
100
        self.from_control = self.from_repository.control_weaves
101
101
        self.failed_revisions = []
102
102
        self.count_copied = 0
103
103
        self.count_total = 0
119
119
        self.last_revision = self._find_last_revision(last_revision)
120
120
        mutter('fetch up to rev {%s}', self.last_revision)
121
121
        if (self.last_revision is not None and 
122
 
            self.to_storage.has_revision(self.last_revision)):
 
122
            self.to_repository.has_revision(self.last_revision)):
123
123
            return
124
124
        try:
125
125
            revs_to_fetch = self._compare_ancestries()
152
152
        That is, every revision that's in the ancestry of the source
153
153
        branch and not in the destination branch."""
154
154
        self.pb.update('get source ancestry')
155
 
        from_storage = self.from_branch.storage
156
 
        self.from_ancestry = from_storage.get_ancestry(self.last_revision)
 
155
        from_repository = self.from_branch.repository
 
156
        self.from_ancestry = from_repository.get_ancestry(self.last_revision)
157
157
 
158
158
        dest_last_rev = self.to_branch.last_revision()
159
159
        self.pb.update('get destination ancestry')
160
160
        if dest_last_rev:
161
 
            to_storage = self.to_branch.storage
162
 
            dest_ancestry = to_storage.get_ancestry(dest_last_rev)
 
161
            to_repository = self.to_branch.repository
 
162
            dest_ancestry = to_repository.get_ancestry(dest_last_rev)
163
163
        else:
164
164
            dest_ancestry = []
165
165
        ss = set(dest_ancestry)
178
178
            i += 1
179
179
            if rev_id is None:
180
180
                continue
181
 
            if self.to_storage.has_revision(rev_id):
 
181
            if self.to_repository.has_revision(rev_id):
182
182
                continue
183
183
            self.pb.update('copy revision', i, self.count_total)
184
184
            self._copy_one_revision(rev_id)
188
188
    def _copy_one_revision(self, rev_id):
189
189
        """Copy revision and everything referenced by it."""
190
190
        mutter('copying revision {%s}', rev_id)
191
 
        rev_xml = self.from_storage.get_revision_xml(rev_id)
192
 
        inv_xml = self.from_storage.get_inventory_xml(rev_id)
 
191
        rev_xml = self.from_repository.get_revision_xml(rev_id)
 
192
        inv_xml = self.from_repository.get_inventory_xml(rev_id)
193
193
        rev = serializer_v5.read_revision_from_string(rev_xml)
194
194
        inv = serializer_v5.read_inventory_from_string(inv_xml)
195
195
        assert rev.revision_id == rev_id
201
201
        parents = rev.parent_ids
202
202
        new_parents = copy(parents)
203
203
        for parent in parents:
204
 
            if not self.to_storage.has_revision(parent):
 
204
            if not self.to_repository.has_revision(parent):
205
205
                new_parents.pop(new_parents.index(parent))
206
206
        self._copy_inventory(rev_id, inv_xml, new_parents)
207
 
        self.to_storage.revision_store.add(StringIO(rev_xml), rev_id)
 
207
        self.to_repository.revision_store.add(StringIO(rev_xml), rev_id)
208
208
        mutter('copied revision %s', rev_id)
209
209
 
210
210
    def _copy_inventory(self, rev_id, inv_xml, parent_ids):
211
211
        self.to_control.add_text('inventory', rev_id,
212
212
                                split_lines(inv_xml), parent_ids,
213
 
                                self.to_storage.get_transaction())
 
213
                                self.to_repository.get_transaction())
214
214
 
215
215
    def _copy_new_texts(self, rev_id, inv):
216
216
        """Copy any new texts occuring in this revision."""
227
227
            text_revision in self.file_ids_names[file_id]:
228
228
                return        
229
229
        to_weave = self.to_weaves.get_weave_or_empty(file_id,
230
 
            self.to_storage.get_transaction())
 
230
            self.to_repository.get_transaction())
231
231
        if not file_id in self.file_ids_names.keys( ):
232
232
            self.file_ids_names[file_id] = to_weave.names( )
233
233
        if text_revision in to_weave:
234
234
            return
235
235
        from_weave = self.from_weaves.get_weave(file_id,
236
 
            self.from_branch.storage.get_transaction())
 
236
            self.from_branch.repository.get_transaction())
237
237
        if text_revision not in from_weave:
238
238
            raise MissingText(self.from_branch, text_revision, file_id)
239
239
        mutter('copy file {%s} modified in {%s}', file_id, rev_id)
248
248
            # destination is empty, just replace it
249
249
            to_weave = from_weave.copy( )
250
250
        self.to_weaves.put_weave(file_id, to_weave,
251
 
            self.to_storage.get_transaction())
 
251
            self.to_repository.get_transaction())
252
252
        self.count_weaves += 1
253
253
        self.copied_file_ids.add(file_id)
254
254
        self.file_ids_names[file_id] = to_weave.names()