diff mercurial/transaction.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 4dd8a6a1240d
children 7559dc8c4238
line wrap: on
line diff
--- a/mercurial/transaction.py	Thu Dec 18 12:07:03 2014 -0600
+++ b/mercurial/transaction.py	Mon Dec 15 13:27:46 2014 -0800
@@ -200,8 +200,8 @@
             return
         dirname, filename = os.path.split(file)
         backupfilename = "%s.backup.%s" % (self.journal, filename)
-        backupfile = os.path.join(dirname, backupfilename)
         vfs = self._vfsmap[location]
+        backupfile = vfs.reljoin(dirname, backupfilename)
         if vfs.exists(file):
             filepath = vfs.join(file)
             backuppath = vfs.join(backupfile)