[PATCH 4 of 4] patch: replace file api with vfs api in fsbackend

Chinmay Joshi c at chinmayjoshi.com
Tue May 27 13:58:03 CDT 2014


# HG changeset patch
# User Chinmay Joshi <c at chinmayjoshi.com>
# Date 1401216458 -19800
#      Wed May 28 00:17:38 2014 +0530
# Node ID fdd07320898be7a8471005f8900b0bdc4c0b36b3
# Parent  0375426f4b794f252af6d1d7fbfd600a68071027
patch: replace file api with vfs api in fsbackend

This patch replaces users with os.* and util.* with vfs API from opener.

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -418,11 +418,11 @@
 
     def getfile(self, fname):
         path = self._join(fname)
-        if os.path.islink(path):
-            return (os.readlink(path), (True, False))
+        if self.opener.islink(path):
+            return (self.opener.readlink(path), (True, False))
         isexec = False
         try:
-            isexec = os.lstat(path).st_mode & 0100 != 0
+            isexec = self.opener.lstat(path).st_mode & 0100 != 0
         except OSError, e:
             if e.errno != errno.ENOENT:
                 raise
@@ -438,7 +438,7 @@
         else:
             self.opener.write(fname, data)
             if isexec:
-                util.setflags(self._join(fname), False, True)
+                self.opener.setflags(self._join(fname), False, True)
 
     def unlink(self, fname):
         util.unlinkpath(self._join(fname), ignoremissing=True)
@@ -453,7 +453,7 @@
         fp.close()
 
     def exists(self, fname):
-        return os.path.lexists(self._join(fname))
+        return self.opener.lexists(self._join(fname))
 
 class workingbackend(fsbackend):
     def __init__(self, ui, repo, similarity):


More information about the Mercurial-devel mailing list