Add a --branch option to different commands
authorCatalin Marinas <catalin.marinas@gmail.com>
Tue, 13 Sep 2005 16:11:18 +0000 (17:11 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 13 Sep 2005 16:11:18 +0000 (17:11 +0100)
This command will show the information on a different branch than the
current one.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/applied.py
stgit/commands/export.py
stgit/commands/files.py
stgit/commands/id.py
stgit/commands/mail.py
stgit/commands/rename.py
stgit/commands/series.py
stgit/commands/top.py
stgit/commands/unapplied.py
stgit/main.py

index 8a2a232..d568cd6 100644 (file)
@@ -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):
index ebcc77a..5f43da5 100644 (file)
@@ -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'
 
index 9ce926f..d81bc25 100644 (file)
@@ -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):
index 447eb62..4c07c4f 100644 (file)
@@ -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 '[<patch>]/(bottom | top)'."""
 
-options = []
+options = [make_option('-b', '--branch',
+                       help = 'use BRANCH instead of the default one')]
 
 
 def func(parser, options, args):
index 6be00fc..012e640 100644 (file)
@@ -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():
index 78a473f..ca799c3 100644 (file)
@@ -28,7 +28,8 @@ usage = """%prog [options] <oldpatch> <newpatch>
 
 Rename <oldpatch> into <newpatch> in a series."""
 
-options = []
+options = [make_option('-b', '--branch',
+                       help = 'use BRANCH instead of the default one')]
 
 
 def func(parser, options, args):
index fb8abb7..263f393 100644 (file)
@@ -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):
index 1d6ab5e..f36a0b0 100644 (file)
@@ -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):
index fe6a485..4a14456 100644 (file)
@@ -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):
index 99df5a4..ed57668 100644 (file)
@@ -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