changeset 12878:1634287b6ab1 stable

qnew: give better feedback when doing 'hg qnew foo/' (issue2464)
author Martin Geisler <mg@aragost.com>
date Fri, 29 Oct 2010 15:25:21 +0200
parents 551aa6e27929
children da4a9ed369c8
files hgext/mq.py tests/test-mq-qnew.t
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Fri Oct 29 12:50:08 2010 +0200
+++ b/hgext/mq.py	Fri Oct 29 15:25:21 2010 +0200
@@ -839,8 +839,12 @@
         insert = self.full_series_end()
         wlock = repo.wlock()
         try:
-            # if patch file write fails, abort early
-            p = self.opener(patchfn, "w")
+            try:
+                # if patch file write fails, abort early
+                p = self.opener(patchfn, "w")
+            except IOError, e:
+                raise util.Abort(_('cannot write patch "%s": %s')
+                                 % (patchfn, e.strerror))
             try:
                 if self.plainmode:
                     if user:
--- a/tests/test-mq-qnew.t	Fri Oct 29 12:50:08 2010 +0200
+++ b/tests/test-mq-qnew.t	Fri Oct 29 15:25:21 2010 +0200
@@ -23,6 +23,7 @@
   >     hg qinit -c
   > 
   >     echo '% qnew with name containing slash'
+  >     hg qnew foo/
   >     hg qnew foo/bar.patch
   >     hg qseries
   >     hg qpop
@@ -105,6 +106,7 @@
   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
+  abort: cannot write patch "foo/": Is a directory
   foo/bar.patch
   popping foo/bar.patch
   patch queue now empty
@@ -168,6 +170,7 @@
   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
+  abort: cannot write patch "foo/": Is a directory
   foo/bar.patch
   popping foo/bar.patch
   patch queue now empty