/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

Fix branch cloning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        )
30
30
from bzrlib.plugins.git.remote import RemoteGitRepository
31
31
 
32
 
from dulwich.client import SimpleFetchGraphWalker
33
32
from dulwich.objects import Commit
34
33
 
35
34
from cStringIO import StringIO
50
49
 
51
50
    def remove(self, revid):
52
51
        self.done.add(revid)
53
 
        if revid in self.heads:
 
52
        if ref in self.heads:
54
53
            self.heads.remove(revid)
55
54
        if revid in self.parents:
56
55
            for p in self.parents[revid]:
162
161
                return objects[sha]
163
162
            return reconstruct_git_object(repo, mapping, sha)
164
163
        parent_invs = [repo.get_inventory(r) for r in rev.parent_ids]
165
 
        import_git_tree(repo, mapping, "", root_tree, inv, parent_invs, 
166
 
            lookup_object)
 
164
        import_git_tree(repo, mapping, "", root_tree, inv, parent_invs, lookup_object)
167
165
        repo.add_revision(rev.revision_id, rev, inv)
168
166
 
169
167
 
186
184
    raise KeyError("No such object %s" % sha)
187
185
 
188
186
 
189
 
class InterGitNonGitRepository(InterRepository):
 
187
class InterGitRepository(InterRepository):
190
188
 
191
189
    _matching_repo_format = GitFormat()
192
190
 
235
233
        """Be compatible with GitRepository."""
236
234
        # FIXME: Also check target uses VersionedFile
237
235
        return (isinstance(source, GitRepository) and 
238
 
                target.supports_rich_root() and
239
 
                not isinstance(target, GitRepository))
240
 
 
241
 
 
242
 
class InterGitRepository(InterRepository):
243
 
 
244
 
    _matching_repo_format = GitFormat()
245
 
 
246
 
    @staticmethod
247
 
    def _get_repo_format_to_test():
248
 
        return None
249
 
 
250
 
    def copy_content(self, revision_id=None, pb=None):
251
 
        """See InterRepository.copy_content."""
252
 
        self.fetch(revision_id, pb, find_ghosts=False)
253
 
 
254
 
    def fetch(self, revision_id=None, pb=None, find_ghosts=False, 
255
 
              mapping=None):
256
 
        if mapping is None:
257
 
            mapping = self.source.get_mapping()
258
 
        def progress(text):
259
 
            info("git: %s", text)
260
 
        r = self.target._git
261
 
        if revision_id is None:
262
 
            determine_wants = lambda x: [y for y in x.values() if not y in r.object_store]
263
 
        else:
264
 
            args = [mapping.revision_id_bzr_to_foreign(revision_id)]
265
 
            determine_wants = lambda x: [y for y in args if not y in r.object_store]
266
 
 
267
 
        graphwalker = SimpleFetchGraphWalker(r.heads().values(), r.get_parents)
268
 
        f, commit = r.object_store.add_pack()
269
 
        try:
270
 
            self.source._git.fetch_pack(path, determine_wants, graphwalker, f.write, progress)
271
 
            f.close()
272
 
            commit()
273
 
        except:
274
 
            f.close()
275
 
            raise
276
 
 
277
 
    @staticmethod
278
 
    def is_compatible(source, target):
279
 
        """Be compatible with GitRepository."""
280
 
        return (isinstance(source, GitRepository) and 
281
 
                isinstance(target, GitRepository))
 
236
                target.supports_rich_root())