comparison mercurial/scmutil.py @ 23581:aed981c7bebf

vfs: add a 'reljoin' function for joining relative paths The vfs.join method only works for absolute paths. We need something that works for relative paths too when transforming filenames. Since os.path.join may misbehave in tricky encoding situations, encapsulate the new join method in our vfs abstraction. The default implementation remains os.path.join, but this opens the door to other VFSes doing something more intelligent based on their needs. In the same go, we replace the usage of 'os.path.join' in transaction code.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 15 Dec 2014 13:27:46 -0800
parents cb42050f2dad
children 7559dc8c4238
comparison
equal deleted inserted replaced
23580:e20f36ad092e 23581:aed981c7bebf
258 def isfile(self, path=None): 258 def isfile(self, path=None):
259 return os.path.isfile(self.join(path)) 259 return os.path.isfile(self.join(path))
260 260
261 def islink(self, path=None): 261 def islink(self, path=None):
262 return os.path.islink(self.join(path)) 262 return os.path.islink(self.join(path))
263
264 def reljoin(self, *paths):
265 """join various elements of a path together (as os.path.join would do)
266
267 The vfs base is not injected so that path stay relative. This exists
268 to allow handling of strange encoding if needed."""
269 return os.path.join(*paths)
263 270
264 def lexists(self, path=None): 271 def lexists(self, path=None):
265 return os.path.lexists(self.join(path)) 272 return os.path.lexists(self.join(path))
266 273
267 def lstat(self, path=None): 274 def lstat(self, path=None):