[kteam-tools][PATCH] apply-stable-patches: add --stop-on-fail switch

Andy Whitcroft apw at canonical.com
Fri Sep 20 09:47:17 UTC 2013


On Thu, Sep 19, 2013 at 09:30:39AM -0700, Kamal Mostafa wrote:
> If --stop-on-fail is set, stop processing if a patch fails to apply.
> 
> Signed-off-by: Kamal Mostafa <kamal at canonical.com>
> ---
>  stable/apply-stable-patches | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/stable/apply-stable-patches b/stable/apply-stable-patches
> index d25a3b3..5cd315b 100755
> --- a/stable/apply-stable-patches
> +++ b/stable/apply-stable-patches
> @@ -79,6 +79,8 @@ class Cmdline:
>          --check-already  Check for already committed ('commit {sha} upstream.')
>                           patches
>  
> +        --stop-on-fail   Stop processing if a patch fails to apply
> +
>          --name=<full name>
>                           Name to use for the SOB line.
>                           Default is git config user.name
> @@ -116,7 +118,8 @@ class Cmdline:
>          try:
>              optsShort = ''
>              optsLong  = ['help', 'range=', 'sob', 'verbose', 'config=',
> -                         'check-already', 'debug=', 'name=', 'email=']
> +                         'check-already', 'stop-on-fail', 'debug=',
> +			 'name=', 'email=']

This so really should use the python getopts library rather than
reinventing this ...

>              opts, args = getopt(argv[1:], optsShort, optsLong)
>  
>              for opt, val in opts:
> @@ -132,6 +135,9 @@ class Cmdline:
>                  elif (opt == '--check-already'):
>                      self.cfg['check_already'] = True
>  
> +                elif (opt == '--stop-on-fail'):
> +                    self.cfg['stop_on_fail'] = True
> +
>                  elif opt in ('--name'):
>                      self.cfg['name'] = val
>  
> @@ -515,6 +521,9 @@ class ApplyStablePatches(StdApp):
>                      move(patch_file, failed_dir)
>                      print("failed")
>                      status, result = run_command('git am --abort')
> +		    if 'stop_on_fail' in self.cfg:
> +			print("Stopping because a patch failed to apply.")
> +			break
>                      continue
>                  if patch_file == filename:
>                      move(filename, applied_dir)

-apw




More information about the kernel-team mailing list