82
83
mapping = source_repo.get_mapping()
83
84
refs = interrepo.fetch()
85
for k, v in extract_tags(refs).iteritems():
86
tags[k] = mapping.revision_id_foreign_to_bzr(v)
86
for k, (peeled, unpeeled) in extract_tags(refs).iteritems():
87
tags[k] = mapping.revision_id_foreign_to_bzr(peeled)
88
if unpeeled is not None:
89
pass # FIXME: Store unpeeled information
87
90
pb = ui.ui_factory.nested_progress_bar()
89
92
for i, (name, ref) in enumerate(refs.iteritems()):
90
if name.startswith("refs/tags/"):
94
ref_to_branch_name(name)
96
# Not a branch, ignore
92
98
pb.update("creating branches", i, len(refs))
93
99
head_loc = os.path.join(dest_location, name)
214
Option('signoff', short_name='s', help='Add a Signed-off-by line.'),
207
216
takes_args = ["patches*"]
209
def _apply_patch(self, wt, f):
218
def _apply_patch(self, wt, f, signoff):
221
:param wt: A Bazaar working tree object.
222
:param f: Patch file to read.
223
:param signoff: Add Signed-Off-By flag.
225
from bzrlib.errors import BzrCommandError
210
226
from dulwich.patch import git_am_patch_split
211
228
(c, diff, version) = git_am_patch_split(f)
212
# FIXME: Process diff
213
wt.commit(committer=c.committer,
229
# FIXME: Cope with git-specific bits in patch
230
p = subprocess.Popen(["patch", "-p1"], stdin=subprocess.PIPE, cwd=wt.basedir)
234
raise BzrCommandError("error running patch")
237
signed_off_by = wt.branch.get_config().username()
238
message += "Signed-off-by: %s\n" % signed_off_by.encode('utf-8')
239
wt.commit(authors=[c.author], message=message)
216
def run(self, patches_list=None):
241
def run(self, patches_list=None, signoff=False, force=False):
242
from bzrlib.errors import UncommittedChanges
217
243
from bzrlib.workingtree import WorkingTree
218
244
if patches_list is None:
219
245
patches_list = []
221
247
tree, _ = WorkingTree.open_containing(".")
248
if tree.basis_tree().changes_from(tree).has_changed() and not force:
249
raise UncommittedChanges(tree)
222
250
tree.lock_write()
224
252
for patch in patches_list:
225
253
f = open(patch, 'r')
227
self._apply_patch(tree, f)
255
self._apply_patch(tree, f, signoff=signoff)