From 2f7c8b0ba410854dc7dd0c2282323cc04dfcce8e Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Tue, 13 Sep 2005 17:11:18 +0100 Subject: [PATCH] Add a --branch option to different commands This command will show the information on a different branch than the current one. Signed-off-by: Catalin Marinas --- stgit/commands/applied.py | 3 ++- stgit/commands/export.py | 6 ++++-- stgit/commands/files.py | 4 +++- stgit/commands/id.py | 3 ++- stgit/commands/mail.py | 4 +++- stgit/commands/rename.py | 3 ++- stgit/commands/series.py | 3 ++- stgit/commands/top.py | 3 ++- stgit/commands/unapplied.py | 3 ++- stgit/main.py | 6 ++++-- 10 files changed, 26 insertions(+), 12 deletions(-) diff --git a/stgit/commands/applied.py b/stgit/commands/applied.py index 8a2a232..d568cd6 100644 --- a/stgit/commands/applied.py +++ b/stgit/commands/applied.py @@ -31,7 +31,8 @@ List the patches from the series which were already pushed onto the stack. They are listed in the order in which they were pushed, the last one being the current (topmost) patch.""" -options = [] +options = [make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] def func(parser, options, args): diff --git a/stgit/commands/export.py b/stgit/commands/export.py index ebcc77a..5f43da5 100644 --- a/stgit/commands/export.py +++ b/stgit/commands/export.py @@ -56,7 +56,9 @@ options = [make_option('-n', '--numbered', help = 'Use FILE as a template'), make_option('-r', '--range', metavar = '[PATCH1][:[PATCH2]]', - help = 'export patches between PATCH1 and PATCH2')] + help = 'export patches between PATCH1 and PATCH2'), + make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] def func(parser, options, args): @@ -67,7 +69,7 @@ def func(parser, options, args): else: parser.error('incorrect number of arguments') - if git.local_changes(): + if not options.branch and git.local_changes(): print 'Warning: local changes in the tree. ' \ 'You might want to commit them first' diff --git a/stgit/commands/files.py b/stgit/commands/files.py index 9ce926f..d81bc25 100644 --- a/stgit/commands/files.py +++ b/stgit/commands/files.py @@ -35,7 +35,9 @@ command. Use the 'diff' or 'status' commands for these files.""" options = [make_option('-s', '--stat', help = 'show the diff stat', - action = 'store_true')] + action = 'store_true'), + make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] def func(parser, options, args): diff --git a/stgit/commands/id.py b/stgit/commands/id.py index 447eb62..4c07c4f 100644 --- a/stgit/commands/id.py +++ b/stgit/commands/id.py @@ -30,7 +30,8 @@ Print the hash value of a GIT id (defaulting to HEAD). In addition to the standard GIT id's like heads and tags, this command also accepts 'base' and '[]/(bottom | top)'.""" -options = [] +options = [make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] def func(parser, options, args): diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py index 6be00fc..012e640 100644 --- a/stgit/commands/mail.py +++ b/stgit/commands/mail.py @@ -97,7 +97,9 @@ options = [make_option('-a', '--all', make_option('-u', '--smtp-user', metavar = 'USER', help = 'username for SMTP authentication'), make_option('-p', '--smtp-password', metavar = 'PASSWORD', - help = 'username for SMTP authentication')] + help = 'username for SMTP authentication'), + make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] def __get_maintainer(): diff --git a/stgit/commands/rename.py b/stgit/commands/rename.py index 78a473f..ca799c3 100644 --- a/stgit/commands/rename.py +++ b/stgit/commands/rename.py @@ -28,7 +28,8 @@ usage = """%prog [options] Rename into in a series.""" -options = [] +options = [make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] def func(parser, options, args): diff --git a/stgit/commands/series.py b/stgit/commands/series.py index fb8abb7..263f393 100644 --- a/stgit/commands/series.py +++ b/stgit/commands/series.py @@ -31,7 +31,8 @@ Show all the patches in the series. The applied patches are prefixed with a '+' and the unapplied ones with a '-'. The current patch is prefixed with a '>'. Empty patches are prefixed with a '0'.""" -options = [] +options = [make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] def func(parser, options, args): diff --git a/stgit/commands/top.py b/stgit/commands/top.py index 1d6ab5e..f36a0b0 100644 --- a/stgit/commands/top.py +++ b/stgit/commands/top.py @@ -29,7 +29,8 @@ usage = """%prog [options] Print the name of the current (topmost) patch.""" -options = [] +options = [make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] def func(parser, options, args): diff --git a/stgit/commands/unapplied.py b/stgit/commands/unapplied.py index fe6a485..4a14456 100644 --- a/stgit/commands/unapplied.py +++ b/stgit/commands/unapplied.py @@ -30,7 +30,8 @@ usage = """%prog [options] 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 = [] +options = [make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] def func(parser, options, args): diff --git a/stgit/main.py b/stgit/main.py index 99df5a4..ed57668 100644 --- a/stgit/main.py +++ b/stgit/main.py @@ -128,8 +128,8 @@ def main(): sys.exit(0) if not cmd in commands: print >> sys.stderr, 'Unknown command: %s' % cmd - print >> sys.stderr, ' Try "%s help" for a list of supported commands' \ - % prog + print >> sys.stderr, ' Try "%s help" for a list of supported ' \ + 'commands' % prog sys.exit(1) # re-build the command line arguments @@ -144,6 +144,8 @@ def main(): # 'clone' doesn't expect an already initialised GIT tree if cmd == 'clone': stgit.commands.common.crt_series = stack.Series('master') + elif hasattr(options, 'branch') and options.branch: + stgit.commands.common.crt_series = stack.Series(options.branch) else: stgit.commands.common.crt_series = stack.Series() # the line below is a simple way to avoid an exception when -- 2.11.0