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

Support pushing git->git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
418
418
        return result
419
419
 
420
420
 
421
 
class InterGitRemoteLocalBranch(branch.InterBranch):
 
421
class InterGitBranch(branch.GenericInterBranch):
422
422
    """InterBranch implementation that pulls between Git branches."""
423
423
 
 
424
 
 
425
class InterGitLocalRemoteBranch(InterGitBranch):
 
426
    """InterBranch that copies from a local to a remote git branch."""
 
427
 
 
428
    @classmethod
 
429
    def is_compatible(self, source, target):
 
430
        from bzrlib.plugins.git.remote import RemoteGitBranch
 
431
        return (isinstance(source, LocalGitBranch) and 
 
432
                isinstance(target, RemoteGitBranch))
 
433
 
 
434
    def _basic_push(self, overwrite=False, stop_revision=None):
 
435
        result = GitBranchPushResult()
 
436
        result.source_branch = self.source
 
437
        result.target_branch = self.target
 
438
        if stop_revision is None:
 
439
            stop_revision = self.source.last_revision()
 
440
        # FIXME: Check for diverged branches
 
441
        def get_changed_refs(old_refs):
 
442
            result.old_revid = self.target.mapping.revision_id_foreign_to_bzr(old_refs["refs/heads/master"])
 
443
            refs = { "refs/heads/master": self.source.repository.lookup_git_revid(stop_revision)[0] }
 
444
            result.new_revid = stop_revision
 
445
            for name, sha in self.source.repository._git.refs.as_dict("refs/tags").iteritems():
 
446
                refs["refs/tags/%s" % name] = sha
 
447
            return refs
 
448
        self.target.repository.send_pack(get_changed_refs, 
 
449
                self.source.repository._git.object_store.generate_pack_contents)
 
450
        return result
 
451
 
 
452
 
 
453
class InterGitRemoteLocalBranch(InterGitBranch):
 
454
    """InterBranch that copies from a remote to a local git branch."""
 
455
 
424
456
    @classmethod
425
457
    def is_compatible(self, source, target):
426
458
        from bzrlib.plugins.git.remote import RemoteGitBranch
504
536
branch.InterBranch.register_optimiser(InterGitRemoteLocalBranch)
505
537
branch.InterBranch.register_optimiser(InterFromGitBranch)
506
538
branch.InterBranch.register_optimiser(InterToGitBranch)
 
539
branch.InterBranch.register_optimiser(InterGitLocalRemoteBranch)