/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

  • Committer: John Carr
  • Date: 2009-01-13 20:26:54 UTC
  • mto: (0.217.53 git-serve)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: john.carr@unrouted.co.uk-20090113202654-9hsels0a9r35o7u0
Rename upload-pack and receive-pack so they don't clash with the Git versions

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
32
33
from dulwich.objects import Commit
33
34
 
34
35
from cStringIO import StringIO
49
50
 
50
51
    def remove(self, revid):
51
52
        self.done.add(revid)
52
 
        if ref in self.heads:
 
53
        if revid in self.heads:
53
54
            self.heads.remove(revid)
54
55
        if revid in self.parents:
55
56
            for p in self.parents[revid]:
161
162
                return objects[sha]
162
163
            return reconstruct_git_object(repo, mapping, sha)
163
164
        parent_invs = [repo.get_inventory(r) for r in rev.parent_ids]
164
 
        import_git_tree(repo, mapping, "", root_tree, inv, parent_invs, lookup_object)
 
165
        import_git_tree(repo, mapping, "", root_tree, inv, parent_invs, 
 
166
            lookup_object)
165
167
        repo.add_revision(rev.revision_id, rev, inv)
166
168
 
167
169
 
184
186
    raise KeyError("No such object %s" % sha)
185
187
 
186
188
 
187
 
class InterGitRepository(InterRepository):
 
189
class InterGitNonGitRepository(InterRepository):
188
190
 
189
191
    _matching_repo_format = GitFormat()
190
192
 
201
203
        if mapping is None:
202
204
            mapping = self.source.get_mapping()
203
205
        def progress(text):
204
 
            pb.note("git: %s", text)
 
206
            pb.update("git: %s" % text.rstrip("\r\n"), 0, 0)
205
207
        def determine_wants(heads):
206
208
            if revision_id is None:
207
209
                ret = heads.values()
233
235
        """Be compatible with GitRepository."""
234
236
        # FIXME: Also check target uses VersionedFile
235
237
        return (isinstance(source, GitRepository) and 
236
 
                target.supports_rich_root())
 
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))