{"thread":{"id":"6786","subject":"[PATCH 0/2] A couple of small StGit improvements","startedAt":"2007-02-12T21:08:18Z","lastAt":"2007-02-12T21:08:29Z","messageCount":3,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"34319","messageId":"20070212210628.28413.87407.stgit@gandelf.nowhere.earth","threadId":"6786","inReplyTo":null,"subject":"[PATCH 0/2] A couple of small StGit improvements","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-02-12T21:08:18Z","receivedAt":"2007-02-12T21:08:18Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"Finally I should never have dropped --merged when copying pull.py to\nrebase.py, I missed it today.  And shortcut commands are nice on\ncommand line, but not within help strings.\n\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"34320","messageId":"20070212210824.28413.71656.stgit@gandelf.nowhere.earth","threadId":"6786","inReplyTo":"20070212210628.28413.87407.stgit@gandelf.nowhere.earth","subject":"[PATCH 1/2] Add --merged option to rebase.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-02-12T21:08:24Z","receivedAt":"2007-02-12T21:08:24Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/commands/rebase.py |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/stgit/commands/rebase.py b/stgit/commands/rebase.py\nindex 8b7bca0..2951421 100644\n--- a/stgit/commands/rebase.py\n+++ b/stgit/commands/rebase.py\n@@ -31,6 +31,9 @@ Pop all patches from current stack, move the stack base to the given\n \n options = [make_option('-n', '--nopush',\n                        help = 'do not push the patches back after rebasing',\n+                       action = 'store_true'),\n+           make_option('-m', '--merged',\n+                       help = 'check for patches merged upstream',\n                        action = 'store_true')]\n \n def func(parser, options, args):\n@@ -59,6 +62,6 @@ def func(parser, options, args):\n \n     # push the patches back\n     if not options.nopush:\n-        push_patches(applied)\n+        push_patches(applied, options.merged)\n \n     print_crt_patch()\n"},{"id":"34321","messageId":"20070212210829.28413.16922.stgit@gandelf.nowhere.earth","threadId":"6786","inReplyTo":"20070212210628.28413.87407.stgit@gandelf.nowhere.earth","subject":"[PATCH 2/2] Use canonical command name in help message.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-02-12T21:08:29Z","receivedAt":"2007-02-12T21:08:29Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nLet's expand shortcut command names in help messages, in all 3 forms\n(\"help foo\", \"--help foo\" and \"foo --help\").\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/main.py |   44 ++++++++++++++++++++++++--------------------\n 1 files changed, 24 insertions(+), 20 deletions(-)\n\ndiff --git a/stgit/main.py b/stgit/main.py\nindex 2da6bbc..f1b47f2 100644\n--- a/stgit/main.py\n+++ b/stgit/main.py\n@@ -29,27 +29,31 @@ import stgit.commands\n class Commands(dict):\n     \"\"\"Commands class. It performs on-demand module loading\n     \"\"\"\n+    def canonical_cmd(self, key):\n+        \"\"\"Return the canonical name for a possibly-shortenned\n+        command name.\n+        \"\"\"\n+        candidates = [cmd for cmd in self.keys() if cmd.startswith(key)]\n+\n+        if not candidates:\n+            print >> sys.stderr, 'Unknown command: %s' % key\n+            print >> sys.stderr, '  Try \"%s help\" for a list of ' \\\n+                  'supported commands' % prog\n+            sys.exit(1)\n+        elif len(candidates) > 1:\n+            print >> sys.stderr, 'Ambiguous command: %s' % key\n+            print >> sys.stderr, '  Candidates are: %s' \\\n+                  % ', '.join(candidates)\n+            sys.exit(1)\n+\n+        return candidates[0]\n+        \n     def __getitem__(self, key):\n         \"\"\"Return the command python module name based.\n         \"\"\"\n         global prog\n \n-        cmd_mod = self.get(key)\n-        if not cmd_mod:\n-            candidates = [cmd for cmd in self.keys() if cmd.startswith(key)]\n-\n-            if not candidates:\n-                print >> sys.stderr, 'Unknown command: %s' % key\n-                print >> sys.stderr, '  Try \"%s help\" for a list of ' \\\n-                      'supported commands' % prog\n-                sys.exit(1)\n-            elif len(candidates) > 1:\n-                print >> sys.stderr, 'Ambiguous command: %s' % key\n-                print >> sys.stderr, '  Candidates are: %s' \\\n-                      % ', '.join(candidates)\n-                sys.exit(1)\n-\n-            cmd_mod = self.get(candidates[0])\n+        cmd_mod = self.get(key) or self.get(self.canonical_cmd(key))\n             \n         __import__('stgit.commands.' + cmd_mod)\n         return getattr(stgit.commands, cmd_mod)\n@@ -202,15 +206,15 @@ def main():\n     cmd = sys.argv[1]\n \n     if cmd in ['-h', '--help']:\n-        if len(sys.argv) >= 3 and sys.argv[2] in commands:\n-            cmd = sys.argv[2]\n+        if len(sys.argv) >= 3:\n+            cmd = commands.canonical_cmd(sys.argv[2])\n             sys.argv[2] = '--help'\n         else:\n             print_help()\n             sys.exit(0)\n     if cmd == 'help':\n         if len(sys.argv) == 3 and not sys.argv[2] in ['-h', '--help']:\n-            cmd = sys.argv[2]\n+            cmd = commands.canonical_cmd(sys.argv[2])\n             if not cmd in commands:\n                 print >> sys.stderr, '%s help: \"%s\" command unknown' \\\n                       % (prog, cmd)\n@@ -236,7 +240,7 @@ def main():\n         sys.exit(0)\n \n     # re-build the command line arguments\n-    sys.argv[0] += ' %s' % cmd\n+    sys.argv[0] += ' %s' % commands.canonical_cmd(cmd)\n     del(sys.argv[1])\n \n     command = commands[cmd]\n"}]}