patch: replace functions in fsbackend to use vfs
authorChinmay Joshi <c@chinmayjoshi.com>
Thu, 05 Jun 2014 15:24:29 +0530
changeset 21717 2a095d3442e0
parent 21716 90f9be5adade
child 21718 bc773e9505e3
patch: replace functions in fsbackend to use vfs Several functions in fsbackend are replaced to use vfs functions. vfs operations are applied on filename and path is joined by _join().
mercurial/patch.py
--- a/mercurial/patch.py	Thu Jun 05 15:16:44 2014 +0530
+++ b/mercurial/patch.py	Thu Jun 05 15:24:29 2014 +0530
@@ -417,12 +417,12 @@
         return os.path.join(self.opener.base, f)
 
     def getfile(self, fname):
-        path = self._join(fname)
-        if os.path.islink(path):
-            return (os.readlink(path), (True, False))
+        if self.opener.islink(fname):
+            return (self.opener.readlink(fname), (True, False))
+
         isexec = False
         try:
-            isexec = os.lstat(path).st_mode & 0100 != 0
+            isexec = self.opener.lstat(fname).st_mode & 0100 != 0
         except OSError, e:
             if e.errno != errno.ENOENT:
                 raise
@@ -431,17 +431,17 @@
     def setfile(self, fname, data, mode, copysource):
         islink, isexec = mode
         if data is None:
-            util.setflags(self._join(fname), islink, isexec)
+            self.opener.setflags(fname, islink, isexec)
             return
         if islink:
             self.opener.symlink(data, fname)
         else:
             self.opener.write(fname, data)
             if isexec:
-                util.setflags(self._join(fname), False, True)
+                self.opener.setflags(fname, False, True)
 
     def unlink(self, fname):
-        util.unlinkpath(self._join(fname), ignoremissing=True)
+        self.opener.unlinkpath(fname, ignoremissing=True)
 
     def writerej(self, fname, failed, total, lines):
         fname = fname + ".rej"
@@ -453,7 +453,7 @@
         fp.close()
 
     def exists(self, fname):
-        return os.path.lexists(self._join(fname))
+        return self.opener.lexists(fname)
 
 class workingbackend(fsbackend):
     def __init__(self, ui, repo, similarity):