From 948dae344afd7633b7a074beb36113c1b46527eb Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 8 Nov 2006 22:30:03 +0000 Subject: [PATCH] Add a new option to "stg applied" and "stg unapplied" that provides a count of patches rather than a list. Signed-off-by: Chuck Lever --- stgit/commands/applied.py | 14 +++++++++++--- stgit/commands/series.py | 7 +++++++ stgit/commands/unapplied.py | 14 +++++++++++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/stgit/commands/applied.py b/stgit/commands/applied.py index d568cd6..f131d62 100644 --- a/stgit/commands/applied.py +++ b/stgit/commands/applied.py @@ -32,7 +32,10 @@ stack. They are listed in the order in which they were pushed, the last one being the current (topmost) patch.""" options = [make_option('-b', '--branch', - help = 'use BRANCH instead of the default one')] + help = 'use BRANCH instead of the default one'), + make_option('-c', '--count', + help = 'print the number of applied patches', + action = 'store_true')] def func(parser, options, args): @@ -41,5 +44,10 @@ def func(parser, options, args): if len(args) != 0: parser.error('incorrect number of arguments') - for p in crt_series.get_applied(): - print p + applied = crt_series.get_applied() + + if options.count: + print len(applied) + else: + for p in applied: + print p diff --git a/stgit/commands/series.py b/stgit/commands/series.py index e66f1bd..105eeb9 100644 --- a/stgit/commands/series.py +++ b/stgit/commands/series.py @@ -33,6 +33,9 @@ prefixed with a '>'. Empty patches are prefixed with a '0'.""" options = [make_option('-b', '--branch', help = 'use BRANCH instead of the default one'), + make_option('-c', '--count', + help = 'print the number of patches in the series', + action = 'store_true'), make_option('-d', '--description', help = 'show a short description for each patch', action = 'store_true'), @@ -73,6 +76,10 @@ def func(parser, options, args): applied = crt_series.get_applied() unapplied = crt_series.get_unapplied() + if options.count: + print len(applied) + len(unapplied) + return + if options.short: if len(applied) > 5: applied = applied[-6:] diff --git a/stgit/commands/unapplied.py b/stgit/commands/unapplied.py index 4a14456..cbac052 100644 --- a/stgit/commands/unapplied.py +++ b/stgit/commands/unapplied.py @@ -31,7 +31,10 @@ List the patches from the series which are not pushed onto the stack. They are listed in the reverse order in which they were popped.""" options = [make_option('-b', '--branch', - help = 'use BRANCH instead of the default one')] + help = 'use BRANCH instead of the default one'), + make_option('-c', '--count', + help = 'print the number of unapplied patches', + action = 'store_true')] def func(parser, options, args): @@ -40,5 +43,10 @@ def func(parser, options, args): if len(args) != 0: parser.error('incorrect number of arguments') - for p in crt_series.get_unapplied(): - print p + unapplied = crt_series.get_unapplied() + + if options.count: + print len(unapplied) + else: + for p in unapplied: + print p -- 2.11.0