[PATCH] clone on Windows: abort on reserved filenames (1st update)
Adrian Buehlmann
adrian at cadifra.com
Wed Jun 11 03:50:55 CDT 2008
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1213168826 -7200
# Node ID 56412cee647462b43d28ebe44f23d467e09b93de
# Parent a51093361e1c76cf27124a76417fc118d8fa60c1
clone on Windows: abort on reserved filenames
hg clone hangs forever on Windows when pulling from
a remote repository (on unix) containing a file with
a filename equal to a Windows reserved filename.
With this change, hg clone now aborts with an error
message.
See also issue793.
diff -r a51093361e1c -r 56412cee6474 mercurial/localrepo.py
--- a/mercurial/localrepo.py Sat Jun 07 17:52:00 2008 +0200
+++ b/mercurial/localrepo.py Wed Jun 11 09:20:26 2008 +0200
@@ -2005,6 +2005,8 @@
f = changegroup.getchunk(source)
if not f:
break
+ if not util.validpathname(f):
+ raise util.Abort(_("filename %s is not supported") % f)
self.ui.debug(_("adding %s revisions\n") % f)
fl = self.file(f)
o = fl.count()
diff -r a51093361e1c -r 56412cee6474 mercurial/util.py
--- a/mercurial/util.py Sat Jun 07 17:52:00 2008 +0200
+++ b/mercurial/util.py Wed Jun 11 09:20:26 2008 +0200
@@ -936,6 +936,9 @@
def lookup_reg(key, name=None, scope=None):
return None
+def validpathname(path):
+ return True
+
# Platform specific variants
if os.name == 'nt':
import msvcrt
@@ -1854,3 +1857,12 @@
scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
netloc = netloc[netloc.find('@')+1:]
return urlparse.urlunparse((scheme, netloc, path, params, query, fragment))
+
+_reserved_filenames = '''CON PRN AUX NUL
+ COM1 COM2 COM3 COM4 COM5 COM6 COM7 COM8 COM9
+ LPT1 LPT2 LPT3 LPT4 LPT5 LPT6 LPT7 LPT8 LPT9'''.split()
+def validpathname(path):
+ for n in path.split('/'):
+ if n.upper() in _reserved_filenames:
+ return False
+ return True
More information about the Mercurial-devel
mailing list