Patchwork [2,of,6,v2] windows: teach dirstate and posixfile to understand long paths

login
register
mail settings
Submitter Kostia Balytskyi
Date Sept. 19, 2017, 4:57 p.m.
Message ID <db7c6d368422041bb0d5.1505840266@devvm1416.lla2.facebook.com>
Download mbox | patch
Permalink /patch/24025/
State Deferred, archived
Headers show

Comments

Kostia Balytskyi - Sept. 19, 2017, 4:57 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1505835722 25200
#      Tue Sep 19 08:42:02 2017 -0700
# Node ID db7c6d368422041bb0d5ff5dafcd4cdaf3943fac
# Parent  280ac0656c0637d1006b956cfe4b21808ff0207c
windows: teach dirstate and posixfile to understand long paths

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -269,9 +269,7 @@  class dirstate(object):
         return not util.fscasesensitive(self._join('.hg'))
 
     def _join(self, f):
-        # much faster than os.path.join()
-        # it's safe because f is always a relative path
-        return self._rootdir + f
+        return util.absjoin(self._rootdir, f)
 
     def flagfunc(self, buildfallback):
         if self._checklink and self._checkexec:
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -124,6 +124,9 @@  class mixedfilemodewrapper(object):
 def posixfile(name, mode='r', buffering=-1):
     '''Open a file with even more POSIX-like semantics'''
     try:
+        if os.path.isabs(name) and not hasntprefix(name):
+            # we're out of luck if path is relative
+            name = converttontpath(name)
         fp = osutil.posixfile(name, mode, buffering) # may raise WindowsError
 
         # The position when opening in append mode is implementation defined, so