git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>
@ 2008-02-17 21:03 Onno Kortmann
  2008-02-18 14:00 ` Karl Hasselström
  0 siblings, 1 reply; 10+ messages in thread
From: Onno Kortmann @ 2008-02-17 21:03 UTC (permalink / raw)
  To: git

instead of stg rename <old> <new>.
This is for example helpful for those people who always have a typo or two in 
their
patch names.
---

 stgit/commands/rename.py |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/stgit/commands/rename.py b/stgit/commands/rename.py
index e2b0fa4..acdf962 100644
--- a/stgit/commands/rename.py
+++ b/stgit/commands/rename.py
@@ -25,9 +25,10 @@ from stgit import stack, git
 
 
 help = 'rename a patch in the series'
-usage = """%prog [options] <oldpatch> <newpatch>
+usage = """%prog [options] [oldpatch] <newpatch>
 
-Rename <oldpatch> into <newpatch> in a series."""
+Rename <oldpatch> into <newpatch> in a series. If <oldpatch> is not given, 
the
+top-most patch will be renamed. """
 
 directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
@@ -37,9 +38,18 @@ options = [make_option('-b', '--branch',
 def func(parser, options, args):
     """Rename a patch in the series
     """
-    if len(args) != 2:
-        parser.error('incorrect number of arguments')
+    crt=crt_series.get_current()
+
+    if len(args) == 2:
+        out.start('Renaming patch "%s" to "%s"' % (args[0], args[1]))
+
+    elif len(args) == 1:
+        if not crt:
+            raise CmdException, "No applied top patch to rename exists."
+        args=[crt]+args
+        out.start('Renaming top-most patch "%s" to "%s"' % (args[0], 
args[1]))
+    
+    else: parser.error('incorrect number of arguments')
 
-    out.start('Renaming patch "%s" to "%s"' % (args[0], args[1]))
     crt_series.rename_patch(args[0], args[1])
     out.done()

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

end of thread, other threads:[~2008-02-23  7:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-17 21:03 [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name> Onno Kortmann
2008-02-18 14:00 ` Karl Hasselström
2008-02-21 21:30   ` Onno Kortmann
2008-02-22  7:38     ` Karl Hasselström
2008-02-22 22:52       ` Onno Kortmann
2008-02-23  7:45         ` Karl Hasselström
2008-02-21 21:42   ` [PATCH 1/2] Simple rename of top-most patch Onno Kortmann
2008-02-22  7:44     ` Karl Hasselström
2008-02-21 21:43   ` [PATCH 2/2] Test the 'stg rename' command Onno Kortmann
2008-02-22  7:48     ` Karl Hasselström

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).