{"thread":{"id":"20450","subject":"[PATCH] Add 'stg prev' and 'stg next'","startedAt":"2009-08-07T10:45:09Z","lastAt":"2009-08-13T22:30:46Z","messageCount":2,"participants":["Hannes Eder","Catalin Marinas"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"119899","messageId":"20090807104503.15805.95504.stgit@jazzy.zrh.corp.google.com","threadId":"20450","inReplyTo":null,"subject":"[PATCH] Add 'stg prev' and 'stg next'","fromName":"Hannes Eder","fromEmail":"heder@google.com","sentAt":"2009-08-07T10:45:09Z","receivedAt":"2009-08-07T10:45:09Z","isPatch":true,"sender":{"key":"heder@google.com","avatar":null},"body":"These commands are related to 'stg top'.  They print the patch below\nresp. above the topmost patch, given that they exist.\n\nSigned-off-by: Hannes Eder <heder@google.com>\n---\nOk, I confess it's not kill feature, but Mercurial has these commands\nand I use them from time to time.  Maybe somebody else finds it useful\nas well, so I decided to share it. ;)\n\nCheers,\nHannes\n\n stgit/commands/next.py |   48 ++++++++++++++++++++++++++++++++++++++++++++++++\n stgit/commands/prev.py |   48 ++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 96 insertions(+), 0 deletions(-)\n create mode 100644 stgit/commands/next.py\n create mode 100644 stgit/commands/prev.py\n\ndiff --git a/stgit/commands/next.py b/stgit/commands/next.py\nnew file mode 100644\nindex 0000000..c8e2599\n--- /dev/null\n+++ b/stgit/commands/next.py\n@@ -0,0 +1,48 @@\n+__copyright__ = \"\"\"\n+Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>\n+\n+This program is free software; you can redistribute it and/or modify\n+it under the terms of the GNU General Public License version 2 as\n+published by the Free Software Foundation.\n+\n+This program is distributed in the hope that it will be useful,\n+but WITHOUT ANY WARRANTY; without even the implied warranty of\n+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+GNU General Public License for more details.\n+\n+You should have received a copy of the GNU General Public License\n+along with this program; if not, write to the Free Software\n+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n+\"\"\"\n+\n+from stgit.argparse import opt\n+from stgit.commands import common\n+from stgit.out import out\n+from stgit import argparse\n+\n+help = 'Print the name of the next patch'\n+kind = 'stack'\n+usage = ['']\n+description = \"\"\"\n+Print the name of the next patch.\"\"\"\n+\n+args = []\n+options = [\n+    opt('-b', '--branch', args = [argparse.stg_branches],\n+        short = 'Use BRANCH instead of the default branch')]\n+\n+directory = common.DirectoryHasRepositoryLib()\n+\n+def func(parser, options, args):\n+    \"\"\"Show the name of the next patch\n+    \"\"\"\n+    if len(args) != 0:\n+        parser.error('incorrect number of arguments')\n+\n+    stack = directory.repository.get_stack(options.branch)\n+    unapplied = stack.patchorder.unapplied\n+\n+    if unapplied:\n+        out.stdout(unapplied[0])\n+    else:\n+        raise common.CmdException, 'No unapplied patches'\ndiff --git a/stgit/commands/prev.py b/stgit/commands/prev.py\nnew file mode 100644\nindex 0000000..79f97a8\n--- /dev/null\n+++ b/stgit/commands/prev.py\n@@ -0,0 +1,48 @@\n+__copyright__ = \"\"\"\n+Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>\n+\n+This program is free software; you can redistribute it and/or modify\n+it under the terms of the GNU General Public License version 2 as\n+published by the Free Software Foundation.\n+\n+This program is distributed in the hope that it will be useful,\n+but WITHOUT ANY WARRANTY; without even the implied warranty of\n+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+GNU General Public License for more details.\n+\n+You should have received a copy of the GNU General Public License\n+along with this program; if not, write to the Free Software\n+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n+\"\"\"\n+\n+from stgit.argparse import opt\n+from stgit.commands import common\n+from stgit.out import out\n+from stgit import argparse\n+\n+help = 'Print the name of the previous patch'\n+kind = 'stack'\n+usage = ['']\n+description = \"\"\"\n+Print the name of the previous patch.\"\"\"\n+\n+args = []\n+options = [\n+    opt('-b', '--branch', args = [argparse.stg_branches],\n+        short = 'Use BRANCH instead of the default branch')]\n+\n+directory = common.DirectoryHasRepositoryLib()\n+\n+def func(parser, options, args):\n+    \"\"\"Show the name of the previous patch\n+    \"\"\"\n+    if len(args) != 0:\n+        parser.error('incorrect number of arguments')\n+\n+    stack = directory.repository.get_stack(options.branch)\n+    applied = stack.patchorder.applied\n+\n+    if applied and len(applied) >= 2:\n+        out.stdout(applied[-2])\n+    else:\n+        raise common.CmdException, 'Not enough applied patches'\n"},{"id":"120596","messageId":"b0943d9e0908131530x61434a27n89b5f31ed046765a@mail.gmail.com","threadId":"20450","inReplyTo":"20090807104503.15805.95504.stgit@jazzy.zrh.corp.google.com","subject":"Re: [PATCH] Add 'stg prev' and 'stg next'","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-08-13T22:30:46Z","receivedAt":"2009-08-13T22:30:46Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"2009/8/7 Hannes Eder <heder@google.com>:\n> These commands are related to 'stg top'.  They print the patch below\n> resp. above the topmost patch, given that they exist.\n\nI applied it. Thanks.\n\n-- \nCatalin\n"}]}