mq: wrap patch file name checks in a function
authorIdan Kamara <idankk86@gmail.com>
Tue, 24 May 2011 19:16:51 +0300
changeset 14422 2e77525e52d9
parent 14421 639f26cab2f5
child 14423 7230aef66b7c
mq: wrap patch file name checks in a function
hgext/mq.py
--- a/hgext/mq.py	Tue May 24 13:30:10 2011 -0500
+++ b/hgext/mq.py	Tue May 24 19:16:51 2011 +0300
@@ -873,6 +873,14 @@
                 raise util.Abort(_('"%s" cannot be used in the name of a patch')
                                  % c)
 
+    def checkpatchname(self, name, force=False):
+        self.check_reserved_name(name)
+        if not force and os.path.exists(self.join(name)):
+            if os.path.isdir(self.join(name)):
+                raise util.Abort(_('"%s" already exists as a directory')
+                                 % name)
+            else:
+                raise util.Abort(_('patch "%s" already exists') % name)
 
     def new(self, repo, patchfn, *pats, **opts):
         """options: