Make qrename handle directory targets; closes #333.
--- a/hgext/mq.py Tue Sep 12 17:27:41 2006 +0200
+++ b/hgext/mq.py Wed Sep 13 08:57:08 2006 -0700
@@ -1651,13 +1651,6 @@
name = patch
patch = None
- if name in q.series:
- raise util.Abort(_('A patch named %s already exists in the series file') % name)
-
- absdest = q.join(name)
- if os.path.exists(absdest):
- raise util.Abort(_('%s already exists') % absdest)
-
if patch:
patch = q.lookup(patch)
else:
@@ -1665,6 +1658,15 @@
ui.write(_('No patches applied\n'))
return
patch = q.lookup('qtip')
+ absdest = q.join(name)
+ if os.path.isdir(absdest):
+ name = os.path.join(name, os.path.basename(patch))
+ absdest = q.join(name)
+ if os.path.exists(absdest):
+ raise util.Abort(_('%s already exists') % absdest)
+
+ if name in q.series:
+ raise util.Abort(_('A patch named %s already exists in the series file') % name)
if ui.verbose:
ui.write('Renaming %s to %s\n' % (patch, name))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-mq-qrename Wed Sep 13 08:57:08 2006 -0700
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+echo "[extensions]" >> $HGRCPATH
+echo "mq=" >> $HGRCPATH
+
+hg init a
+cd a
+
+echo 'base' > base
+hg ci -Ambase -d '1 0'
+
+hg qnew -mmqbase mqbase
+hg qrename mqbase renamed
+mkdir .hg/patches/foo
+hg qrename renamed foo
+hg qseries
+ls .hg/patches/foo
+mkdir .hg/patches/bar
+hg qrename foo/renamed bar
+hg qseries
+ls .hg/patches/bar
+hg qrename bar/renamed baz
+hg qseries
+ls .hg/patches/baz
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-mq-qrename.out Wed Sep 13 08:57:08 2006 -0700
@@ -0,0 +1,7 @@
+adding base
+foo/renamed
+renamed
+bar/renamed
+renamed
+baz
+.hg/patches/baz