[PATCH stable] mq: fixed ENOENT when qrename to new/directory.patch
Yuya Nishihara
yuya at tcha.org
Sun Mar 28 01:43:58 CDT 2010
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1269757391 -32400
# Branch stable
# Node ID 9d85dcd645627098ff559df1d7f25cde5666bfac
# Parent 1e819576e9264bd749ed6cafcbbc52f51753f189
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"
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -2311,6 +2311,9 @@ def rename(ui, repo, patch, name=None, *
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:
diff --git a/tests/test-mq-qnew b/tests/test-mq-qnew
--- a/tests/test-mq-qnew
+++ b/tests/test-mq-qnew
@@ -25,6 +25,12 @@ runtest() {
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
diff --git a/tests/test-mq-qnew.out b/tests/test-mq-qnew.out
--- a/tests/test-mq-qnew.out
+++ b/tests/test-mq-qnew.out
@@ -8,6 +8,10 @@ abort: ".hgignore" cannot be used as the
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: ".hgignore" cannot be used as the
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
diff --git a/tests/test-mq-qrename b/tests/test-mq-qrename
--- a/tests/test-mq-qrename
+++ b/tests/test-mq-qrename
@@ -22,6 +22,9 @@ ls .hg/patches/bar
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
diff --git a/tests/test-mq-qrename.out b/tests/test-mq-qrename.out
--- a/tests/test-mq-qrename.out
+++ b/tests/test-mq-qrename.out
@@ -5,4 +5,6 @@ bar/renamed
renamed
baz
.hg/patches/baz
+new/dir
+.hg/patches/new/dir
% test patch being renamed before committed
More information about the Mercurial-devel
mailing list