Windows long path experimenting report
Adrian Buehlmann
adrian at cadifra.com
Fri Jun 20 04:51:48 CDT 2008
On 20.06.2008 09:56, Adrian Buehlmann wrote:
> On 19.06.2008 14:56, Adrian Buehlmann wrote:
>> But the variant with "aux" as a *directory* name will need some more hg hacking:
>> http://www.cadifra.com/cgi-bin/repos/auxtest2/file/87ca4ddb082f/aux/
>>
>
> Problem point here is util.makedirs:
>
In case anyone is still interested in this, I was able to clone
http://www.cadifra.com/cgi-bin/repos/auxtest2/
> hgt clone -U --traceback http://www.cadifra.com/cgi-bin/repos/auxtest2/
--- running hg from W:\hg-longpath
destination directory: auxtest2
creating file: \\?\W:\tmp\auxtest2\.hg\00changelog.i
creating file: \\?\W:\tmp\auxtest2\.hg\requires
creating file: \\?\W:\tmp\auxtest2\.hg\store\00changelog.i
requesting all changes
creating file: \\?\W:\tmp\auxtest2\.hg\dirstate
creating file: \\?\W:\tmp\auxtest2\.hg\journal.dirstate
creating file: \\?\W:\tmp\auxtest2\.hg\journal.branch
creating file: \\?\W:\tmp\auxtest2\.hg\branch
adding changesets
creating file: \\?\W:\tmp\auxtest2\.hg\store\00changelog.i
creating file: \\?\W:\tmp\auxtest2\.hg\store\00changelog.i.a
adding manifests
creating file: \\?\W:\tmp\auxtest2\.hg\store\00manifest.i
creating file: \\?\W:\tmp\auxtest2\.hg\store\00manifest.i
adding file changes
creating file: \\?\W:\tmp\auxtest2\.hg\store\data\aux\a.txt.i
called util_win32.makedirs('\\?\W:\tmp\auxtest2\.hg\store\data\aux')
creating parent
called util_win32.makedirs('\\?\W:\tmp\auxtest2\.hg\store\data')
CreateDirectoryW() was successful
called util_win32.makedirs('\\?\W:\tmp\auxtest2\.hg\store\data\aux')
CreateDirectoryW() was successful
creating file: \\?\W:\tmp\auxtest2\.hg\store\data\aux\a.txt.i
creating file: \\?\W:\tmp\auxtest2\.hg\store\00changelog.i
added 1 changesets with 1 changes to 1 files
creating file: \\?\W:\tmp\auxtest2\.hg\branch.cache
creating file: \\?\W:\tmp\auxtest2\.hg\.branch.cache-ziovls
creating file: \\?\W:\tmp\auxtest2\.hg\hgrc
to my Windows XP SP3 thanks to the following additional makedirs hacking
(note that the change in util.py just moves makedirs up to before the
if os.name == 'nt' block, so I can redefine it in util_win32.py):
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -983,6 +983,23 @@
def lookup_reg(key, name=None, scope=None):
return None
+def makedirs(name, mode=None):
+ """recursive directory creation with parent mode inheritance"""
+ print "makedirs %s" % name
+ try:
+ os.mkdir(name)
+ if mode is not None:
+ os.chmod(name, mode)
+ return
+ except OSError, err:
+ if err.errno == errno.EEXIST:
+ return
+ if err.errno != errno.ENOENT:
+ raise
+ parent = os.path.abspath(os.path.dirname(name))
+ makedirs(parent, mode)
+ makedirs(name, mode)
+
# Platform specific variants
if os.name == 'nt':
import msvcrt
@@ -1457,22 +1474,6 @@
except: pass
posixfile.close(self)
-def makedirs(name, mode=None):
- """recursive directory creation with parent mode inheritance"""
- try:
- os.mkdir(name)
- if mode is not None:
- os.chmod(name, mode)
- return
- except OSError, err:
- if err.errno == errno.EEXIST:
- return
- if err.errno != errno.ENOENT:
- raise
- parent = os.path.abspath(os.path.dirname(name))
- makedirs(parent, mode)
- makedirs(name, mode)
-
class opener(object):
"""Open files relative to a base directory
diff --git a/mercurial/util_win32.py b/mercurial/util_win32.py
--- a/mercurial/util_win32.py
+++ b/mercurial/util_win32.py
@@ -375,3 +375,24 @@
def handler(event):
win32process.ExitProcess(1)
win32api.SetConsoleCtrlHandler(handler)
+
+def makedirs(name, mode=None):
+ """recursive directory creation for Windows long paths. Parameter mode is unused"""
+ if not name.startswith('\\\\?\\'):
+ name = '\\\\?\\' + name.replace('/', '\\')
+ print "called util_win32.makedirs('%s')" % name
+ try:
+ win32file.CreateDirectoryW(name, None)
+ print "CreateDirectoryW() was successful"
+ return
+ except pywintypes.error, details:
+ err = WinOSError(details)
+ if err.errno == errno.EEXIST:
+ print "directory exists, returning"
+ return
+ if err.errno != errno.ENOENT:
+ raise
+ parent = os.path.dirname(name)
+ print "creating parent"
+ makedirs(parent, mode)
+ makedirs(name, mode)
More information about the Mercurial-devel
mailing list