Minor nit: the error message when "stg pop" or "stg push" can't apply a
patch is vague. Add a little extra logic to print a more precise error
message in these cases.
Signed-off-by: Chuck Lever <cel@netapp.com>
if options.to:
if options.to not in applied:
if options.to:
if options.to not in applied:
- raise CmdException, 'Patch "%s" not applied' % options.to
+ if options.to in crt_series.get_unapplied():
+ raise CmdException, 'Patch "%s" is not currently applied.' % options.to
+ else:
+ raise CmdException, 'Patch "%s" does not exist.' % options.to
patches = applied[:applied.index(options.to)]
elif options.number:
patches = applied[:options.number]
patches = applied[:applied.index(options.to)]
elif options.number:
patches = applied[:options.number]
+def is_patch_appliable(p):
+ """See if patch exists, or is already applied.
+ """
+ if p in applied:
+ raise CmdException, 'Patch "%s" is already applied.' % p
+ if p not in unapplied:
+ raise CmdException, 'Patch "%s" does not exist.' % p
+
def func(parser, options, args):
"""Pushes the given patch or all onto the series
"""
def func(parser, options, args):
"""Pushes the given patch or all onto the series
"""
+ global applied, unapplied
+
# If --undo is passed, do the work and exit
if options.undo:
patch = crt_series.get_current()
# If --undo is passed, do the work and exit
if options.undo:
patch = crt_series.get_current()
check_conflicts()
check_head_top_equal()
check_conflicts()
check_head_top_equal()
+ applied = crt_series.get_applied()
unapplied = crt_series.get_unapplied()
if not unapplied:
raise CmdException, 'No more patches to push'
unapplied = crt_series.get_unapplied()
if not unapplied:
raise CmdException, 'No more patches to push'
if options.to:
boundaries = options.to.split(':')
if len(boundaries) == 1:
if options.to:
boundaries = options.to.split(':')
if len(boundaries) == 1:
- if boundaries[0] not in unapplied:
- raise CmdException, 'Patch "%s" not unapplied' % boundaries[0]
+ is_patch_appliable(boundaries[0])
patches = unapplied[:unapplied.index(boundaries[0])+1]
elif len(boundaries) == 2:
patches = unapplied[:unapplied.index(boundaries[0])+1]
elif len(boundaries) == 2:
- if boundaries[0] not in unapplied:
- raise CmdException, 'Patch "%s" not unapplied' % boundaries[0]
- if boundaries[1] not in unapplied:
- raise CmdException, 'Patch "%s" not unapplied' % boundaries[1]
+ is_patch_appliable(boundaries[0])
+ is_patch_appliable(boundaries[1])
lb = unapplied.index(boundaries[0])
hb = unapplied.index(boundaries[1])
if lb > hb:
lb = unapplied.index(boundaries[0])
hb = unapplied.index(boundaries[1])
if lb > hb:
patches = [unapplied[0]]
elif len(args) == 1:
patches = args
patches = [unapplied[0]]
elif len(args) == 1:
patches = args
- if patches[0] not in unapplied:
- raise CmdException, 'Patch "%s" not unapplied' % patches[0]
+ is_patch_appliable(patches[0])
else:
parser.error('incorrect number of arguments')
else:
parser.error('incorrect number of arguments')
print 'Fast-forwarded patch "%s"' % patches[0]
for p in patches[forwarded:]:
print 'Fast-forwarded patch "%s"' % patches[0]
for p in patches[forwarded:]:
- if p not in unapplied:
- raise CmdException, 'Patch "%s" not unapplied' % p
print 'Pushing patch "%s"...' % p,
sys.stdout.flush()
print 'Pushing patch "%s"...' % p,
sys.stdout.flush()