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