git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] A couple of small StGit improvements
@ 2007-02-12 21:08 Yann Dirson
  2007-02-12 21:08 ` [PATCH 1/2] Add --merged option to rebase Yann Dirson
  2007-02-12 21:08 ` [PATCH 2/2] Use canonical command name in help message Yann Dirson
  0 siblings, 2 replies; 3+ messages in thread
From: Yann Dirson @ 2007-02-12 21:08 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

Finally I should never have dropped --merged when copying pull.py to
rebase.py, I missed it today.  And shortcut commands are nice on
command line, but not within help strings.

-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] Add --merged option to rebase.
  2007-02-12 21:08 [PATCH 0/2] A couple of small StGit improvements Yann Dirson
@ 2007-02-12 21:08 ` Yann Dirson
  2007-02-12 21:08 ` [PATCH 2/2] Use canonical command name in help message Yann Dirson
  1 sibling, 0 replies; 3+ messages in thread
From: Yann Dirson @ 2007-02-12 21:08 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git




Signed-off-by: Yann Dirson <ydirson@altern.org>
---

 stgit/commands/rebase.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/stgit/commands/rebase.py b/stgit/commands/rebase.py
index 8b7bca0..2951421 100644
--- a/stgit/commands/rebase.py
+++ b/stgit/commands/rebase.py
@@ -31,6 +31,9 @@ Pop all patches from current stack, move the stack base to the given
 
 options = [make_option('-n', '--nopush',
                        help = 'do not push the patches back after rebasing',
+                       action = 'store_true'),
+           make_option('-m', '--merged',
+                       help = 'check for patches merged upstream',
                        action = 'store_true')]
 
 def func(parser, options, args):
@@ -59,6 +62,6 @@ def func(parser, options, args):
 
     # push the patches back
     if not options.nopush:
-        push_patches(applied)
+        push_patches(applied, options.merged)
 
     print_crt_patch()

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Use canonical command name in help message.
  2007-02-12 21:08 [PATCH 0/2] A couple of small StGit improvements Yann Dirson
  2007-02-12 21:08 ` [PATCH 1/2] Add --merged option to rebase Yann Dirson
@ 2007-02-12 21:08 ` Yann Dirson
  1 sibling, 0 replies; 3+ messages in thread
From: Yann Dirson @ 2007-02-12 21:08 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git


Let's expand shortcut command names in help messages, in all 3 forms
("help foo", "--help foo" and "foo --help").

Signed-off-by: Yann Dirson <ydirson@altern.org>
---

 stgit/main.py |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/stgit/main.py b/stgit/main.py
index 2da6bbc..f1b47f2 100644
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -29,27 +29,31 @@ import stgit.commands
 class Commands(dict):
     """Commands class. It performs on-demand module loading
     """
+    def canonical_cmd(self, key):
+        """Return the canonical name for a possibly-shortenned
+        command name.
+        """
+        candidates = [cmd for cmd in self.keys() if cmd.startswith(key)]
+
+        if not candidates:
+            print >> sys.stderr, 'Unknown command: %s' % key
+            print >> sys.stderr, '  Try "%s help" for a list of ' \
+                  'supported commands' % prog
+            sys.exit(1)
+        elif len(candidates) > 1:
+            print >> sys.stderr, 'Ambiguous command: %s' % key
+            print >> sys.stderr, '  Candidates are: %s' \
+                  % ', '.join(candidates)
+            sys.exit(1)
+
+        return candidates[0]
+        
     def __getitem__(self, key):
         """Return the command python module name based.
         """
         global prog
 
-        cmd_mod = self.get(key)
-        if not cmd_mod:
-            candidates = [cmd for cmd in self.keys() if cmd.startswith(key)]
-
-            if not candidates:
-                print >> sys.stderr, 'Unknown command: %s' % key
-                print >> sys.stderr, '  Try "%s help" for a list of ' \
-                      'supported commands' % prog
-                sys.exit(1)
-            elif len(candidates) > 1:
-                print >> sys.stderr, 'Ambiguous command: %s' % key
-                print >> sys.stderr, '  Candidates are: %s' \
-                      % ', '.join(candidates)
-                sys.exit(1)
-
-            cmd_mod = self.get(candidates[0])
+        cmd_mod = self.get(key) or self.get(self.canonical_cmd(key))
             
         __import__('stgit.commands.' + cmd_mod)
         return getattr(stgit.commands, cmd_mod)
@@ -202,15 +206,15 @@ def main():
     cmd = sys.argv[1]
 
     if cmd in ['-h', '--help']:
-        if len(sys.argv) >= 3 and sys.argv[2] in commands:
-            cmd = sys.argv[2]
+        if len(sys.argv) >= 3:
+            cmd = commands.canonical_cmd(sys.argv[2])
             sys.argv[2] = '--help'
         else:
             print_help()
             sys.exit(0)
     if cmd == 'help':
         if len(sys.argv) == 3 and not sys.argv[2] in ['-h', '--help']:
-            cmd = sys.argv[2]
+            cmd = commands.canonical_cmd(sys.argv[2])
             if not cmd in commands:
                 print >> sys.stderr, '%s help: "%s" command unknown' \
                       % (prog, cmd)
@@ -236,7 +240,7 @@ def main():
         sys.exit(0)
 
     # re-build the command line arguments
-    sys.argv[0] += ' %s' % cmd
+    sys.argv[0] += ' %s' % commands.canonical_cmd(cmd)
     del(sys.argv[1])
 
     command = commands[cmd]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-12 21:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-12 21:08 [PATCH 0/2] A couple of small StGit improvements Yann Dirson
2007-02-12 21:08 ` [PATCH 1/2] Add --merged option to rebase Yann Dirson
2007-02-12 21:08 ` [PATCH 2/2] Use canonical command name in help message Yann Dirson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).