[kteam-tools][PATCH] apply-stable-patches: add --stop-on-fail switch
Kamal Mostafa
kamal at canonical.com
Fri Sep 20 20:31:38 UTC 2013
On Fri, 2013-09-20 at 10:47 +0100, Andy Whitcroft wrote:
> 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 ...
Good advice for whomever wrote this script in the first place... But
well outside the scope of this simple patch.
> PS: this bit is indented slightly off, which normally says you used
> tabs
> when the file is spaces or visa-versa... and in some later pythons
> this
> will call you rude names and refuse to work.
As if python wasn't wonderful enough already!? :-/ I'll change that.
-Kamal
> > 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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20130920/355ee9f9/attachment.sig>
More information about the kernel-team
mailing list