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 8a2a2320..d568cd60 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 ebcc77a2..5f43da57 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 9ce926f1..d81bc25a 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 447eb62f..4c07c4fa 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 6be00fc0..012e6403 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 78a473f1..ca799c3a 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 fb8abb7c..263f3934 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 1d6ab5e8..f36a0b06 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 fe6a4855..4a144560 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 99df5a44..ed57668b 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.4.GIT