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