This is a fix for bug #12518. If the patch name already exists, the pick
command generates another by appending a numbered suffix.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
if options.name:
patchname = options.name
if options.name:
patchname = options.name
+ if patchname:
+ patchname = find_patch_name(patchname, crt_series.patch_exists)
if options.parent:
parent = git_id(crt_series, options.parent)
if options.parent:
parent = git_id(crt_series, options.parent)
raise CmdException, 'No patches applied'
if commit_id:
raise CmdException, 'No patches applied'
if commit_id:
- __pick_commit(commit_id, None, options)
+ # Try to guess a patch name if the argument was <branch>:<patch>
+ try:
+ patchname = args[0].split(':')[1]
+ except IndexError:
+ patchname = None
+ __pick_commit(commit_id, patchname, options)
else:
if options.unapplied:
patches.reverse()
else:
if options.unapplied:
patches.reverse()
os.remove(filename)
return s
os.remove(filename)
return s
+def find_patch_name(patchname, unacceptable):
+ """Find a patch name which is acceptable."""
+ if unacceptable(patchname):
+ suffix = 0
+ while unacceptable('%s-%d' % (patchname, suffix)):
+ suffix += 1
+ patchname = '%s-%d' % (patchname, suffix)
+ return patchname
+
def patch_name_from_msg(msg):
"""Return a string to be used as a patch name. This is generated
from the top line of the string passed as argument."""
def patch_name_from_msg(msg):
"""Return a string to be used as a patch name. This is generated
from the top line of the string passed as argument."""
patchname = patch_name_from_msg(msg)
if not patchname:
patchname = default_name
patchname = patch_name_from_msg(msg)
if not patchname:
patchname = default_name
- if unacceptable(patchname):
- suffix = 0
- while unacceptable('%s-%d' % (patchname, suffix)):
- suffix += 1
- patchname = '%s-%d' % (patchname, suffix)
- return patchname
+ return find_patch_name(patchname, unacceptable)
# any and all functions are builtin in Python 2.5 and higher, but not
# in 2.4.
# any and all functions are builtin in Python 2.5 and higher, but not
# in 2.4.