82
82
from bzrlib.transport import get_transport
83
83
from bzrlib.plugins.git.branch import (
87
from bzrlib.plugins.git.refs import ref_to_branch_name
86
from bzrlib.plugins.git.refs import (
88
90
from bzrlib.plugins.git.repository import GitRepository
90
92
dest_format = controldir.ControlDirFormat.get_default_format()
97
99
source_repo = Repository.open(src_location)
98
100
if not isinstance(source_repo, GitRepository):
99
raise BzrCommandError("%r is not a git repository" % src_location)
101
raise BzrCommandError(gettext("%r is not a git repository") % src_location)
101
103
target_bzrdir = BzrDir.open_from_transport(dest_transport)
102
104
except NotBranchError:
108
110
target_repo = target_bzrdir.create_repository(shared=True)
110
112
if not target_repo.supports_rich_root():
111
raise BzrCommandError("Target repository doesn't support rich roots")
113
raise BzrCommandError(gettext("Target repository doesn't support rich roots"))
113
115
interrepo = InterRepository.get(source_repo, target_repo)
114
116
mapping = source_repo.get_mapping()
115
117
refs = interrepo.fetch()
116
unpeeled_tags = defaultdict(set)
118
for k, (peeled, unpeeled) in extract_tags(refs).iteritems():
119
tags[k] = mapping.revision_id_foreign_to_bzr(peeled)
120
if unpeeled is not None:
121
unpeeled_tags[peeled].add(unpeeled)
122
# FIXME: Store unpeeled tag map
118
refs_dict = refs.as_dict()
123
119
pb = ui.ui_factory.nested_progress_bar()
125
for i, (name, ref) in enumerate(refs.iteritems()):
121
for i, (name, sha) in enumerate(refs_dict.iteritems()):
127
123
branch_name = ref_to_branch_name(name)
128
124
except ValueError:
129
125
# Not a branch, ignore
131
pb.update("creating branches", i, len(refs))
127
pb.update(gettext("creating branches"), i, len(refs_dict))
132
128
if getattr(target_bzrdir._format, "colocated_branches", False):
133
129
if name == "HEAD":
134
130
branch_name = None
135
131
head_branch = self._get_colocated_branch(target_bzrdir, branch_name)
137
133
head_branch = self._get_nested_branch(dest_transport, dest_format, branch_name)
138
revid = mapping.revision_id_foreign_to_bzr(ref)
134
revid = mapping.revision_id_foreign_to_bzr(sha)
139
135
source_branch = GitBranch(source_repo.bzrdir, source_repo,
141
source_branch.head = ref
137
source_branch.head = sha
142
138
if head_branch.last_revision() != revid:
143
139
head_branch.generate_revision_history(revid)
144
140
source_branch.tags.merge_to(head_branch.tags)
148
144
head_branch.set_parent(url)
151
trace.note("Use 'bzr checkout' to create a working tree in "
152
"the newly created branches.")
148
"Use 'bzr checkout' to create a working tree in "
149
"the newly created branches."))
155
152
class cmd_git_object(Command):
177
174
from bzrlib.bzrdir import (
177
from bzrlib.plugins.git.object_store import (
180
from bzrlib.plugins.git import gettext
180
181
bzrdir, _ = BzrDir.open_containing(directory)
181
182
repo = bzrdir.find_repository()
182
from bzrlib.plugins.git.object_store import (
185
183
object_store = get_object_store(repo)
186
184
object_store.lock_read()
229
227
object_store = get_object_store(repo)
230
228
object_store.lock_read()
232
refs = get_refs(bzrdir)
233
for k, v in refs.iteritems():
230
refs = get_refs_container(bzrdir)
231
for k, v in refs.as_dict().iteritems():
234
232
self.outf.write("%s -> %s\n" % (k, v))
236
234
object_store.unlock()
246
244
takes_options = [
247
245
Option('signoff', short_name='s', help='Add a Signed-off-by line.'),
247
help='Apply patches even if tree has uncommitted changes.')
249
249
takes_args = ["patches*"]
251
251
def _apply_patch(self, wt, f, signoff):