qnew: distinguish between existing file and directory (issue2464) stable
authorMartin Geisler <mg@aragost.com>
Fri, 29 Oct 2010 14:06:06 +0200
branchstable
changeset 12879 da4a9ed369c8
parent 12878 1634287b6ab1
child 12885 b5eae8e24e80
qnew: distinguish between existing file and directory (issue2464)
hgext/mq.py
tests/test-mq-qnew.t
--- a/hgext/mq.py	Fri Oct 29 15:25:21 2010 +0200
+++ b/hgext/mq.py	Fri Oct 29 14:06:06 2010 +0200
@@ -821,7 +821,11 @@
         diffopts = self.diffopts({'git': opts.get('git')})
         self.check_reserved_name(patchfn)
         if os.path.exists(self.join(patchfn)):
-            raise util.Abort(_('patch "%s" already exists') % patchfn)
+            if os.path.isdir(self.join(patchfn)):
+                raise util.Abort(_('"%s" already exists as a directory')
+                                 % patchfn)
+            else:
+                raise util.Abort(_('patch "%s" already exists') % patchfn)
         if opts.get('include') or opts.get('exclude') or pats:
             match = cmdutil.match(repo, pats, opts)
             # detect missing files in pats
--- a/tests/test-mq-qnew.t	Fri Oct 29 15:25:21 2010 +0200
+++ b/tests/test-mq-qnew.t	Fri Oct 29 14:06:06 2010 +0200
@@ -25,6 +25,7 @@
   >     echo '% qnew with name containing slash'
   >     hg qnew foo/
   >     hg qnew foo/bar.patch
+  >     hg qnew foo
   >     hg qseries
   >     hg qpop
   >     hg qdelete foo/bar.patch
@@ -107,6 +108,7 @@
   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
+  abort: "foo" already exists as a directory
   foo/bar.patch
   popping foo/bar.patch
   patch queue now empty
@@ -171,6 +173,7 @@
   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
+  abort: "foo" already exists as a directory
   foo/bar.patch
   popping foo/bar.patch
   patch queue now empty