421
class InterGitRemoteLocalBranch(branch.InterBranch):
421
class InterGitBranch(branch.GenericInterBranch):
422
422
"""InterBranch implementation that pulls between Git branches."""
425
class InterGitLocalRemoteBranch(InterGitBranch):
426
"""InterBranch that copies from a local to a remote git branch."""
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))
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
448
self.target.repository.send_pack(get_changed_refs,
449
self.source.repository._git.object_store.generate_pack_contents)
453
class InterGitRemoteLocalBranch(InterGitBranch):
454
"""InterBranch that copies from a remote to a local git branch."""
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)