# HG changeset patch # User Pierre-Yves David # Date 1418679154 28800 # Node ID 7559dc8c4238310d5a52d519d36b03a0273f9f0c # Parent aed981c7bebf3b63fbe9f777523a590d39f64bba vfs: add a 'split' method This method has the same behavior as the 'os.path.split' function, but having it in vfs will allow handling of tricky encoding situations in the future. In the same patch, we replace the use of 'os.path.split' in the transaction code. diff -r aed981c7bebf -r 7559dc8c4238 mercurial/scmutil.py --- a/mercurial/scmutil.py Mon Dec 15 13:27:46 2014 -0800 +++ b/mercurial/scmutil.py Mon Dec 15 13:32:34 2014 -0800 @@ -268,6 +268,12 @@ to allow handling of strange encoding if needed.""" return os.path.join(*paths) + def split(self, path): + """split top-most element of a path (as os.path.split would do) + + This exists to allow handling of strange encoding if needed.""" + return os.path.split(path) + def lexists(self, path=None): return os.path.lexists(self.join(path)) diff -r aed981c7bebf -r 7559dc8c4238 mercurial/transaction.py --- a/mercurial/transaction.py Mon Dec 15 13:27:46 2014 -0800 +++ b/mercurial/transaction.py Mon Dec 15 13:32:34 2014 -0800 @@ -12,7 +12,6 @@ # GNU General Public License version 2 or any later version. from i18n import _ -import os import errno import error, util @@ -198,9 +197,9 @@ if file in self.map or file in self._backupmap: return - dirname, filename = os.path.split(file) + vfs = self._vfsmap[location] + dirname, filename = vfs.split(file) backupfilename = "%s.backup.%s" % (self.journal, filename) - vfs = self._vfsmap[location] backupfile = vfs.reljoin(dirname, backupfilename) if vfs.exists(file): filepath = vfs.join(file)