mq: fixed ENOENT when qrename to new/directory.patch stable
authorYuya Nishihara <yuya@tcha.org>
Sun, 28 Mar 2010 15:23:11 +0900
branchstable
changeset 11513 0c944b7af564
parent 11512 488a80c840ac
child 11514 4a73a0980194
child 11515 cc982ff2dcf8
mq: fixed ENOENT when qrename to new/directory.patch MQ patch name can contain slashes, e.g. 'foo/bar.patch'. Currently "qnew foo/bar.patch" works, but "qrename foo/bar.patch new/dir.patch" fails with "No such file or directory". Also added test case for "qnew foo/bar.patch"
hgext/mq.py
tests/test-mq-qnew
tests/test-mq-qnew.out
tests/test-mq-qrename
tests/test-mq-qrename.out
--- a/hgext/mq.py	Fri Jul 02 14:14:30 2010 -1000
+++ b/hgext/mq.py	Sun Mar 28 15:23:11 2010 +0900
@@ -2311,6 +2311,9 @@
         q.applied[info[0]] = statusentry(info[1], name)
     q.applied_dirty = 1
 
+    destdir = os.path.dirname(absdest)
+    if not os.path.isdir(destdir):
+        os.makedirs(destdir)
     util.rename(q.join(patch), absdest)
     r = q.qrepo()
     if r:
--- a/tests/test-mq-qnew	Fri Jul 02 14:14:30 2010 -1000
+++ b/tests/test-mq-qnew	Sun Mar 28 15:23:11 2010 +0900
@@ -25,6 +25,12 @@
 
     hg qinit -c
 
+    echo '% qnew with name containing slash'
+    hg qnew foo/bar.patch
+    hg qseries
+    hg qpop
+    hg qdelete foo/bar.patch
+
     echo '% qnew with uncommitted changes'
     echo a > somefile
     hg add somefile
--- a/tests/test-mq-qnew.out	Fri Jul 02 14:14:30 2010 -1000
+++ b/tests/test-mq-qnew.out	Sun Mar 28 15:23:11 2010 +0900
@@ -8,6 +8,10 @@
 abort: ".mqfoo" cannot be used as the name of a patch
 abort: "foo#bar" cannot be used as the name of a patch
 abort: "foo:bar" cannot be used as the name of a patch
+% qnew with name containing slash
+foo/bar.patch
+popping foo/bar.patch
+patch queue now empty
 % qnew with uncommitted changes
 uncommitted.patch
 % qnew implies add
@@ -58,6 +62,10 @@
 abort: ".mqfoo" cannot be used as the name of a patch
 abort: "foo#bar" cannot be used as the name of a patch
 abort: "foo:bar" cannot be used as the name of a patch
+% qnew with name containing slash
+foo/bar.patch
+popping foo/bar.patch
+patch queue now empty
 % qnew with uncommitted changes
 uncommitted.patch
 % qnew implies add
--- a/tests/test-mq-qrename	Fri Jul 02 14:14:30 2010 -1000
+++ b/tests/test-mq-qrename	Sun Mar 28 15:23:11 2010 +0900
@@ -22,6 +22,9 @@
 hg qrename bar/renamed baz
 hg qseries
 ls .hg/patches/baz
+hg qrename baz new/dir
+hg qseries
+ls .hg/patches/new/dir
 cd ..
 
 echo % test patch being renamed before committed
--- a/tests/test-mq-qrename.out	Fri Jul 02 14:14:30 2010 -1000
+++ b/tests/test-mq-qrename.out	Sun Mar 28 15:23:11 2010 +0900
@@ -5,4 +5,6 @@
 renamed
 baz
 .hg/patches/baz
+new/dir
+.hg/patches/new/dir
 % test patch being renamed before committed