# HG changeset patch # User Martin Geisler # Date 1288353966 -7200 # Node ID da4a9ed369c8150dff598c287e3df361d252814a # Parent 1634287b6ab1d1cd99b0d96fe36ef0d8b1e3bfa9 qnew: distinguish between existing file and directory (issue2464) diff -r 1634287b6ab1 -r da4a9ed369c8 hgext/mq.py --- 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 diff -r 1634287b6ab1 -r da4a9ed369c8 tests/test-mq-qnew.t --- 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