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

Cope with API changes in 1.13.

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
                create_pb.finished()
214
214
 
215
215
    def fetch(self, revision_id=None, pb=None, find_ghosts=False, 
216
 
              mapping=None):
 
216
              mapping=None, fetch_spec=None):
217
217
        if mapping is None:
218
218
            mapping = self.source.get_mapping()
 
219
        if revision_id is not None:
 
220
            interesting_heads = [revision_id]
 
221
        elif fetch_spec is not None:
 
222
            interesting_heads = fetch_spec.heads
 
223
        else:
 
224
            interesting_heads = None
219
225
        def determine_wants(heads):
220
 
            if revision_id is None:
 
226
            if interesting_heads is None:
221
227
                ret = heads.values()
222
228
            else:
223
 
                ret = [mapping.revision_id_bzr_to_foreign(revision_id)[0]]
 
229
                ret = [mapping.revision_id_bzr_to_foreign(revid)[0] for revid in interesting_heads]
224
230
            return [rev for rev in ret if not self.target.has_revision(mapping.revision_id_foreign_to_bzr(rev))]
225
231
        return self.fetch_objects(determine_wants, mapping, pb)
226
232
 
246
252
        self.fetch(revision_id, pb, find_ghosts=False)
247
253
 
248
254
    def fetch(self, revision_id=None, pb=None, find_ghosts=False, 
249
 
              mapping=None):
 
255
              mapping=None, fetch_spec=None):
250
256
        if mapping is None:
251
257
            mapping = self.source.get_mapping()
252
258
        def progress(text):
253
259
            info("git: %s", text)
254
260
        r = self.target._git
255
 
        if revision_id is None:
256
 
            determine_wants = lambda x: [y for y in x.values() if not y in r.object_store]
257
 
        else:
 
261
        if revision_id is not None:
258
262
            args = [mapping.revision_id_bzr_to_foreign(revision_id)[0]]
259
 
            determine_wants = lambda x: [y for y in args if not y in r.object_store]
 
263
        elif fetch_spec is not None:
 
264
            args = [mapping.revision_id_bzr_to_foreign(revid)[0] for revid in fetch_spec.heads]
 
265
        else:
 
266
            args = x.values()
 
267
        determine_wants = lambda x: [y for y in args if not y in r.object_store]
260
268
 
261
269
        graphwalker = SimpleFetchGraphWalker(r.heads().values(), r.get_parents)
262
270
        f, commit = r.object_store.add_pack()