/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

Implement to_files() for git merge directives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from dulwich.objects import (
18
18
    Commit,
19
19
    Tag,
20
 
    Tree,
21
20
    S_ISGITLINK,
22
21
    )
23
22
from dulwich.object_store import (
24
23
    tree_lookup_path,
25
24
    )
26
 
from itertools import (
27
 
    imap,
28
 
    )
29
 
import posixpath
30
25
import re
31
26
import stat
32
27
 
33
28
from bzrlib import (
34
29
    debug,
 
30
    lru_cache,
35
31
    osutils,
36
32
    trace,
37
33
    ui,
 
34
    urlutils,
38
35
    )
39
36
from bzrlib.errors import (
40
37
    BzrError,
57
54
    topo_sort,
58
55
    )
59
56
from bzrlib.versionedfile import (
60
 
    ChunkedContentFactory,
 
57
    FulltextContentFactory,
61
58
    )
62
59
 
63
60
from bzrlib.plugins.git.mapping import (
64
61
    DEFAULT_FILE_MODE,
65
62
    inventory_to_tree_and_blobs,
66
63
    mode_is_executable,
67
 
    mode_kind,
68
64
    squash_revision,
69
65
    warn_unusual_mode,
70
66
    )
71
67
from bzrlib.plugins.git.object_store import (
72
68
    BazaarObjectStore,
73
 
    LRUInventoryCache,
74
69
    )
75
70
from bzrlib.plugins.git.remote import (
76
71
    RemoteGitRepository,
82
77
    )
83
78
 
84
79
 
85
 
def import_git_blob(texts, mapping, path, name, (base_hexsha, hexsha), 
86
 
        base_inv, parent_id, revision_id,
87
 
        parent_invs, lookup_object, (base_mode, mode), store_updater):
 
80
MAX_INV_CACHE_SIZE = 50 * 1024 * 1024
 
81
 
 
82
 
 
83
def import_git_blob(texts, mapping, path, hexsha, base_inv, base_ie, parent_id,
 
84
    revision_id, parent_invs, shagitmap, lookup_object, executable, symlink):
88
85
    """Import a git blob object into a bzr repository.
89
86
 
90
87
    :param texts: VersionedFiles to add to
92
89
    :param blob: A git blob
93
90
    :return: Inventory delta for this file
94
91
    """
95
 
    if base_hexsha == hexsha and base_mode == mode:
96
 
        # If nothing has changed since the base revision, we're done
97
 
        return []
98
92
    file_id = mapping.generate_file_id(path)
99
 
    if stat.S_ISLNK(mode):
 
93
    if symlink:
100
94
        cls = InventoryLink
101
95
    else:
102
96
        cls = InventoryFile
103
 
    ie = cls(file_id, name.decode("utf-8"), parent_id)
104
 
    ie.executable = mode_is_executable(mode)
105
 
    if base_hexsha == hexsha and mode_kind(base_mode) == mode_kind(mode):
106
 
        base_ie = base_inv[base_inv.path2id(path)]
 
97
    # We just have to hope this is indeed utf-8:
 
98
    ie = cls(file_id, urlutils.basename(path).decode("utf-8"), parent_id)
 
99
    ie.executable = executable
 
100
    # See if this has changed at all
 
101
    if base_ie is None:
 
102
        base_sha = None
 
103
    else:
 
104
        try:
 
105
            base_sha = shagitmap.lookup_blob(file_id, base_ie.revision)
 
106
        except KeyError:
 
107
            base_sha = None
 
108
        else:
 
109
            if (base_sha == hexsha and base_ie.executable == ie.executable
 
110
                and base_ie.kind == ie.kind):
 
111
                # If nothing has changed since the base revision, we're done
 
112
                return [], []
 
113
    if base_sha == hexsha and base_ie.kind == ie.kind:
107
114
        ie.text_size = base_ie.text_size
108
115
        ie.text_sha1 = base_ie.text_sha1
109
116
        ie.symlink_target = base_ie.symlink_target
119
126
            ie.text_size = None
120
127
            ie.text_sha1 = None
121
128
        else:
122
 
            ie.text_size = sum(imap(len, blob.chunked))
123
 
            ie.text_sha1 = osutils.sha_strings(blob.chunked)
 
129
            ie.text_size = len(blob.data)
 
130
            ie.text_sha1 = osutils.sha_string(blob.data)
124
131
    # Check what revision we should store
125
132
    parent_keys = []
126
 
    for pinv in parent_invs[1:]:
127
 
        try:
128
 
            pie = pinv[file_id]
129
 
        except NoSuchId:
130
 
            continue
 
133
    for pinv in parent_invs:
 
134
        if pinv.revision_id == base_inv.revision_id:
 
135
            pie = base_ie
 
136
            if pie is None:
 
137
                continue
 
138
        else:
 
139
            try:
 
140
                pie = pinv[file_id]
 
141
            except NoSuchId:
 
142
                continue
131
143
        if pie.text_sha1 == ie.text_sha1 and pie.executable == ie.executable and pie.symlink_target == ie.symlink_target:
132
144
            # found a revision in one of the parents to use
133
145
            ie.revision = pie.revision
136
148
    if ie.revision is None:
137
149
        # Need to store a new revision
138
150
        ie.revision = revision_id
 
151
        assert file_id is not None
139
152
        assert ie.revision is not None
140
153
        if ie.kind == 'symlink':
141
 
            chunks = []
 
154
            data = ''
142
155
        else: 
143
 
            chunks = blob.chunked
144
 
        texts.insert_record_stream([ChunkedContentFactory((file_id, ie.revision), tuple(parent_keys), ie.text_sha1, chunks)])
 
156
            data = blob.data
 
157
        texts.insert_record_stream([FulltextContentFactory((file_id, ie.revision), tuple(parent_keys), ie.text_sha1, data)])
 
158
        shamap = [(hexsha, "blob", (ie.file_id, ie.revision))]
 
159
    else:
 
160
        shamap = []
145
161
    invdelta = []
146
 
    if base_hexsha is not None:
147
 
        old_path = path # Renames are not supported yet
148
 
        if stat.S_ISDIR(base_mode):
149
 
            invdelta.extend(remove_disappeared_children(base_inv, old_path,
150
 
                lookup_object(base_hexsha), [], lookup_object))
 
162
    if base_ie is not None:
 
163
        old_path = base_inv.id2path(file_id)
 
164
        if base_ie.kind == "directory":
 
165
            invdelta.extend(remove_disappeared_children(old_path, base_ie.children, []))
151
166
    else:
152
167
        old_path = None
153
168
    invdelta.append((old_path, path, file_id, ie))
154
 
    if base_hexsha != hexsha:
155
 
        store_updater.add_object(blob, ie)
156
 
    return invdelta
 
169
    return (invdelta, shamap)
157
170
 
158
171
 
159
172
class SubmodulesRequireSubtrees(BzrError):
161
174
    internal = False
162
175
 
163
176
 
164
 
def import_git_submodule(texts, mapping, path, name, (base_hexsha, hexsha),
165
 
    base_inv, parent_id, revision_id, parent_invs, lookup_object,
166
 
    (base_mode, mode), store_updater):
167
 
    if base_hexsha == hexsha and base_mode == mode:
168
 
        return [], {}
 
177
def import_git_submodule(texts, mapping, path, hexsha, base_inv, base_ie,
 
178
    parent_id, revision_id, parent_invs, shagitmap, lookup_object):
169
179
    file_id = mapping.generate_file_id(path)
170
 
    ie = TreeReference(file_id, name.decode("utf-8"), parent_id)
 
180
    ie = TreeReference(file_id, urlutils.basename(path.decode("utf-8")),
 
181
        parent_id)
171
182
    ie.revision = revision_id
172
 
    if base_hexsha is None:
 
183
    if base_ie is None:
173
184
        oldpath = None
174
185
    else:
175
186
        oldpath = path
 
187
        if (base_ie.kind == ie.kind and
 
188
            base_ie.reference_revision == ie.reference_revision):
 
189
            ie.revision = base_ie.revision
176
190
    ie.reference_revision = mapping.revision_id_foreign_to_bzr(hexsha)
177
 
    texts.insert_record_stream([ChunkedContentFactory((file_id, ie.revision), (), None, [])])
 
191
    texts.insert_record_stream([FulltextContentFactory((file_id, ie.revision), (), None, "")])
178
192
    invdelta = [(oldpath, path, file_id, ie)]
179
 
    return invdelta, {}
180
 
 
181
 
 
182
 
def remove_disappeared_children(base_inv, path, base_tree, existing_children,
183
 
        lookup_object):
 
193
    return invdelta, {}, {}
 
194
 
 
195
 
 
196
def remove_disappeared_children(path, base_children, existing_children):
184
197
    ret = []
185
 
    for name, mode, hexsha in base_tree.iteritems():
186
 
        if name in existing_children:
187
 
            continue
188
 
        c_path = posixpath.join(path, name.decode("utf-8"))
189
 
        ret.append((c_path, None, base_inv.path2id(c_path), None))
190
 
        if stat.S_ISDIR(mode):
191
 
            ret.extend(remove_disappeared_children(
192
 
                base_inv, c_path, lookup_object(hexsha), [], lookup_object))
 
198
    deletable = [(osutils.pathjoin(path, k), v) for k,v in base_children.iteritems() if k not in existing_children]
 
199
    while deletable:
 
200
        (path, ie) = deletable.pop()
 
201
        ret.append((path, None, ie.file_id, None))
 
202
        if ie.kind == "directory":
 
203
            for name, child_ie in ie.children.iteritems():
 
204
                deletable.append((osutils.pathjoin(path, name), child_ie))
193
205
    return ret
194
206
 
195
207
 
196
 
def import_git_tree(texts, mapping, path, name, (base_hexsha, hexsha),
197
 
        base_inv, parent_id, revision_id, parent_invs,
198
 
    lookup_object, (base_mode, mode), store_updater, allow_submodules=False):
 
208
def import_git_tree(texts, mapping, path, hexsha, base_inv, base_ie, parent_id,
 
209
    revision_id, parent_invs, shagitmap, lookup_object, allow_submodules=False):
199
210
    """Import a git tree object into a bzr repository.
200
211
 
201
212
    :param texts: VersionedFiles object to add to
204
215
    :param base_inv: Base inventory against which to return inventory delta
205
216
    :return: Inventory delta for this subtree
206
217
    """
207
 
    if base_hexsha == hexsha and base_mode == mode:
208
 
        # If nothing has changed since the base revision, we're done
209
 
        return [], {}
210
218
    invdelta = []
211
219
    file_id = mapping.generate_file_id(path)
212
220
    # We just have to hope this is indeed utf-8:
213
 
    ie = InventoryDirectory(file_id, name.decode("utf-8"), parent_id)
214
 
    tree = lookup_object(hexsha)
215
 
    if base_hexsha is None:
216
 
        base_tree = None
217
 
        old_path = None # Newly appeared here
218
 
    else:
219
 
        base_tree = lookup_object(base_hexsha)
220
 
        old_path = path # Renames aren't supported yet
221
 
    if base_tree is None or type(base_tree) is not Tree:
 
221
    ie = InventoryDirectory(file_id, urlutils.basename(path.decode("utf-8")),
 
222
        parent_id)
 
223
    if base_ie is None:
 
224
        # Newly appeared here
222
225
        ie.revision = revision_id
223
 
        invdelta.append((old_path, path, ie.file_id, ie))
224
 
        texts.insert_record_stream([ChunkedContentFactory((ie.file_id, ie.revision), (), None, [])])
 
226
        texts.insert_record_stream([FulltextContentFactory((file_id, ie.revision), (), None, "")])
 
227
        invdelta.append((None, path, file_id, ie))
 
228
    else:
 
229
        # See if this has changed at all
 
230
        try:
 
231
            base_sha = shagitmap.lookup_tree(file_id, base_inv.revision_id)
 
232
        except KeyError:
 
233
            pass
 
234
        else:
 
235
            if base_sha == hexsha:
 
236
                # If nothing has changed since the base revision, we're done
 
237
                return [], {}, []
 
238
        if base_ie.kind != "directory":
 
239
            ie.revision = revision_id
 
240
            texts.insert_record_stream([FulltextContentFactory((ie.file_id, ie.revision), (), None, "")])
 
241
            invdelta.append((base_inv.id2path(ie.file_id), path, ie.file_id, ie))
 
242
    if base_ie is not None and base_ie.kind == "directory":
 
243
        base_children = base_ie.children
 
244
    else:
 
245
        base_children = {}
225
246
    # Remember for next time
226
247
    existing_children = set()
227
248
    child_modes = {}
228
 
    for child_mode, name, child_hexsha in tree.entries():
229
 
        existing_children.add(name)
230
 
        child_path = posixpath.join(path, name)
231
 
        if type(base_tree) is Tree:
232
 
            try:
233
 
                child_base_mode, child_base_hexsha = base_tree[name]
234
 
            except KeyError:
235
 
                child_base_hexsha = None
236
 
                child_base_mode = 0
237
 
        else:
238
 
            child_base_hexsha = None
239
 
            child_base_mode = 0
240
 
        if stat.S_ISDIR(child_mode):
241
 
            subinvdelta, grandchildmodes = import_git_tree(
242
 
                    texts, mapping, child_path, name,
243
 
                    (child_base_hexsha, child_hexsha),
244
 
                    base_inv, file_id, revision_id, parent_invs, lookup_object,
245
 
                    (child_base_mode, child_mode), store_updater,
 
249
    shamap = []
 
250
    tree = lookup_object(hexsha)
 
251
    for mode, name, child_hexsha in tree.entries():
 
252
        basename = name.decode("utf-8")
 
253
        existing_children.add(basename)
 
254
        child_path = osutils.pathjoin(path, name)
 
255
        if stat.S_ISDIR(mode):
 
256
            subinvdelta, grandchildmodes, subshamap = import_git_tree(
 
257
                    texts, mapping, child_path, child_hexsha, base_inv,
 
258
                    base_children.get(basename), file_id, revision_id,
 
259
                    parent_invs, shagitmap, lookup_object,
246
260
                    allow_submodules=allow_submodules)
247
 
        elif S_ISGITLINK(child_mode): # submodule
 
261
            invdelta.extend(subinvdelta)
 
262
            child_modes.update(grandchildmodes)
 
263
            shamap.extend(subshamap)
 
264
        elif S_ISGITLINK(mode): # submodule
248
265
            if not allow_submodules:
249
266
                raise SubmodulesRequireSubtrees()
250
 
            subinvdelta, grandchildmodes = import_git_submodule(
251
 
                    texts, mapping, child_path, name,
252
 
                    (child_base_hexsha, child_hexsha),
253
 
                    base_inv, file_id, revision_id, parent_invs, lookup_object,
254
 
                    (child_base_mode, child_mode), store_updater)
 
267
            subinvdelta, grandchildmodes, subshamap = import_git_submodule(
 
268
                    texts, mapping, child_path, child_hexsha, base_inv, base_children.get(basename),
 
269
                    file_id, revision_id, parent_invs, shagitmap, lookup_object)
 
270
            invdelta.extend(subinvdelta)
 
271
            child_modes.update(grandchildmodes)
 
272
            shamap.extend(subshamap)
255
273
        else:
256
 
            subinvdelta = import_git_blob(texts, mapping,
257
 
                    child_path, name, (child_base_hexsha, child_hexsha),
258
 
                    base_inv, file_id, revision_id, parent_invs, lookup_object,
259
 
                    (child_base_mode, child_mode), store_updater)
260
 
            grandchildmodes = {}
261
 
        child_modes.update(grandchildmodes)
262
 
        invdelta.extend(subinvdelta)
263
 
        if child_mode not in (stat.S_IFDIR, DEFAULT_FILE_MODE,
 
274
            subinvdelta, subshamap = import_git_blob(texts, mapping,
 
275
                    child_path, child_hexsha, base_inv, base_children.get(basename), file_id,
 
276
                    revision_id, parent_invs, shagitmap, lookup_object,
 
277
                    mode_is_executable(mode), stat.S_ISLNK(mode))
 
278
            invdelta.extend(subinvdelta)
 
279
            shamap.extend(subshamap)
 
280
        if mode not in (stat.S_IFDIR, DEFAULT_FILE_MODE,
264
281
                        stat.S_IFLNK, DEFAULT_FILE_MODE|0111):
265
 
            child_modes[child_path] = child_mode
 
282
            child_modes[child_path] = mode
266
283
    # Remove any children that have disappeared
267
 
    if base_tree is not None and type(base_tree) is Tree:
268
 
        invdelta.extend(remove_disappeared_children(base_inv, old_path, 
269
 
            base_tree, existing_children, lookup_object))
270
 
    store_updater.add_object(tree, ie)
271
 
    return invdelta, child_modes
 
284
    if base_ie is not None and base_ie.kind == "directory":
 
285
        invdelta.extend(remove_disappeared_children(base_inv.id2path(file_id),
 
286
            base_children, existing_children))
 
287
    shamap.append((hexsha, "tree", (file_id, revision_id)))
 
288
    return invdelta, child_modes, shamap
 
289
 
 
290
 
 
291
def approx_inv_size(inv):
 
292
    # Very rough estimate, 1k per inventory entry
 
293
    return len(inv) * 1024
272
294
 
273
295
 
274
296
def import_git_commit(repo, mapping, head, lookup_object,
278
300
    # We have to do this here, since we have to walk the tree and
279
301
    # we need to make sure to import the blobs / trees with the right
280
302
    # path; this may involve adding them more than once.
281
 
    parent_invs = parent_invs_cache.get_inventories(rev.parent_ids)
 
303
    parent_invs = []
 
304
    for parent_id in rev.parent_ids:
 
305
        try:
 
306
            parent_invs.append(parent_invs_cache[parent_id])
 
307
        except KeyError:
 
308
            parent_inv = repo.get_inventory(parent_id)
 
309
            parent_invs.append(parent_inv)
 
310
            parent_invs_cache[parent_id] = parent_inv
282
311
    if parent_invs == []:
283
312
        base_inv = Inventory(root_id=None)
284
 
        base_tree = None
285
 
        base_mode = None
 
313
        base_ie = None
286
314
    else:
287
315
        base_inv = parent_invs[0]
288
 
        base_tree = lookup_object(o.parents[0]).tree
289
 
        base_mode = stat.S_IFDIR
290
 
    store_updater = target_git_object_retriever._get_updater(rev)
291
 
    store_updater.add_object(o, None)
292
 
    inv_delta, unusual_modes = import_git_tree(repo.texts,
293
 
            mapping, "", u"", (base_tree, o.tree), base_inv, 
294
 
            None, rev.revision_id, parent_invs, lookup_object,
295
 
            (base_mode, stat.S_IFDIR), store_updater,
 
316
        base_ie = base_inv.root
 
317
    inv_delta, unusual_modes, shamap = import_git_tree(repo.texts,
 
318
            mapping, "", o.tree, base_inv, base_ie, None, rev.revision_id,
 
319
            parent_invs, target_git_object_retriever._idmap, lookup_object,
296
320
            allow_submodules=getattr(repo._format, "supports_tree_reference", False))
297
 
    store_updater.finish()
 
321
    target_git_object_retriever._idmap.add_entries(shamap)
298
322
    if unusual_modes != {}:
299
323
        for path, mode in unusual_modes.iteritems():
300
324
            warn_unusual_mode(rev.foreign_revid, path, mode)
307
331
    rev.inventory_sha1, inv = repo.add_inventory_by_delta(basis_id,
308
332
              inv_delta, rev.revision_id, rev.parent_ids,
309
333
              base_inv)
310
 
    parent_invs_cache.add(rev.revision_id, inv)
 
334
    parent_invs_cache[rev.revision_id] = inv
311
335
    repo.add_revision(rev.revision_id, rev)
312
336
    if "verify" in debug.debug_flags:
313
337
        new_unusual_modes = mapping.export_unusual_file_modes(rev)
324
348
                raise AssertionError("%r != %r in %s" % (oldsha1, newsha1, path))
325
349
 
326
350
 
327
 
def import_git_objects(repo, mapping, object_iter,
328
 
    target_git_object_retriever, heads, pb=None, limit=None):
 
351
def import_git_objects(repo, mapping, object_iter, target_git_object_retriever,
 
352
        heads, pb=None, limit=None):
329
353
    """Import a set of git objects into a bzr repository.
330
354
 
331
355
    :param repo: Target Bazaar repository
332
356
    :param mapping: Mapping to use
333
357
    :param object_iter: Iterator over Git objects.
334
 
    :return: Tuple with pack hints and last imported revision id
335
358
    """
336
359
    def lookup_object(sha):
337
360
        try:
338
361
            return object_iter[sha]
339
362
        except KeyError:
340
363
            return target_git_object_retriever[sha]
 
364
    # TODO: a more (memory-)efficient implementation of this
341
365
    graph = []
342
366
    checked = set()
343
367
    heads = list(set(heads))
344
 
    parent_invs_cache = LRUInventoryCache(repo)
 
368
    parent_invs_cache = lru_cache.LRUSizeCache(compute_size=approx_inv_size,
 
369
                                               max_size=MAX_INV_CACHE_SIZE)
 
370
    target_git_object_retriever.start_write_group() # FIXME: try/finally
345
371
    # Find and convert commit objects
346
372
    while heads:
347
373
        if pb is not None:
349
375
        head = heads.pop()
350
376
        assert isinstance(head, str)
351
377
        try:
352
 
            o = lookup_object(head)
 
378
            o = object_iter[head]
353
379
        except KeyError:
354
380
            continue
355
381
        if isinstance(o, Commit):
358
384
                continue
359
385
            squash_revision(repo, rev)
360
386
            graph.append((o.id, o.parents))
 
387
            target_git_object_retriever._idmap.add_entry(o.id, "commit",
 
388
                    (rev.revision_id, o.tree))
361
389
            heads.extend([p for p in o.parents if p not in checked])
362
390
        elif isinstance(o, Tag):
363
391
            if o.object[1] not in checked:
368
396
    del checked
369
397
    # Order the revisions
370
398
    # Create the inventory objects
371
 
    batch_size = 1000
 
399
    batch_size = 100
372
400
    revision_ids = topo_sort(graph)
373
401
    pack_hints = []
374
402
    if limit is not None:
375
403
        revision_ids = revision_ids[:limit]
376
404
    last_imported = None
377
405
    for offset in range(0, len(revision_ids), batch_size):
378
 
        target_git_object_retriever.start_write_group() 
 
406
        repo.start_write_group()
379
407
        try:
380
 
            repo.start_write_group()
381
 
            try:
382
 
                for i, head in enumerate(
383
 
                    revision_ids[offset:offset+batch_size]):
384
 
                    if pb is not None:
385
 
                        pb.update("fetching revisions", offset+i,
386
 
                                  len(revision_ids))
387
 
                    import_git_commit(repo, mapping, head, lookup_object,
388
 
                                      target_git_object_retriever,
389
 
                                      parent_invs_cache)
390
 
                    last_imported = head
391
 
            except:
392
 
                repo.abort_write_group()
393
 
                raise
394
 
            else:
395
 
                hint = repo.commit_write_group()
396
 
                if hint is not None:
397
 
                    pack_hints.extend(hint)
 
408
            for i, head in enumerate(revision_ids[offset:offset+batch_size]):
 
409
                if pb is not None:
 
410
                    pb.update("fetching revisions", offset+i, len(revision_ids))
 
411
                import_git_commit(repo, mapping, head, lookup_object,
 
412
                                  target_git_object_retriever,
 
413
                                  parent_invs_cache)
 
414
                last_imported = head
398
415
        except:
399
 
            target_git_object_retriever.abort_write_group()
 
416
            repo.abort_write_group()
400
417
            raise
401
418
        else:
402
 
            target_git_object_retriever.commit_write_group()
 
419
            hint = repo.commit_write_group()
 
420
            if hint is not None:
 
421
                pack_hints.extend(hint)
 
422
    target_git_object_retriever.commit_write_group()
403
423
    return pack_hints, last_imported
404
424
 
405
425
 
415
435
        """See InterRepository.copy_content."""
416
436
        self.fetch(revision_id, pb, find_ghosts=False)
417
437
 
418
 
    def fetch(self, revision_id=None, pb=None, find_ghosts=False,
419
 
        mapping=None, fetch_spec=None):
420
 
        self.fetch_refs(revision_id=revision_id, pb=pb,
421
 
            find_ghosts=find_ghosts, mapping=mapping, fetch_spec=fetch_spec)
 
438
    def fetch(self, revision_id=None, pb=None, find_ghosts=False, mapping=None,
 
439
            fetch_spec=None):
 
440
        self.fetch_refs(revision_id=revision_id, pb=pb, find_ghosts=find_ghosts,
 
441
                mapping=mapping, fetch_spec=fetch_spec)
422
442
 
423
443
 
424
444
class InterGitNonGitRepository(InterGitRepository):
443
463
            else:
444
464
                ret = [mapping.revision_id_bzr_to_foreign(revid)[0] for revid in interesting_heads if revid not in (None, NULL_REVISION)]
445
465
            return [rev for rev in ret if not self.target.has_revision(mapping.revision_id_foreign_to_bzr(rev))]
446
 
        (pack_hint, _) = self.fetch_objects(determine_wants, mapping, pb)
 
466
        pack_hint = self.fetch_objects(determine_wants, mapping, pb)[0]
447
467
        if pack_hint is not None and self.target._format.pack_compresses:
448
468
            self.target.pack(hint=pack_hint)
449
469
        if interesting_heads is not None:
522
542
    repository."""
523
543
 
524
544
    def fetch_objects(self, determine_wants, mapping, pb=None, limit=None):
525
 
        """Fetch objects.
526
 
        """
527
545
        wants = determine_wants(self.source._git.get_refs())
528
546
        create_pb = None
529
547
        if pb is None:
533
551
            self.target.lock_write()
534
552
            try:
535
553
                return import_git_objects(self.target, mapping,
536
 
                    self.source._git.object_store,
537
 
                    target_git_object_retriever, wants, pb, limit)
 
554
                    self.source._git.object_store, target_git_object_retriever,
 
555
                    wants, pb, limit)
538
556
            finally:
539
557
                self.target.unlock()
540
558
        finally: