Patchwork [6,of,9] context: use "vfs.lstat()" instead of "os.lstat()"

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 14, 2013, 4:16 p.m.
Message ID <799f7b70736b5b2479e0.1381767366@juju>
Download mbox | patch
Permalink /patch/2764/
State Superseded
Commit 7c21e3398931acaebb200622f5385d1dea1351b1
Headers show

Comments

Katsunori FUJIWARA - Oct. 14, 2013, 4:16 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1381765864 -32400
#      Tue Oct 15 00:51:04 2013 +0900
# Node ID 799f7b70736b5b2479e028460ab08cf6233eb356
# Parent  07ebc40aa3695dfbf03ae13bb1662f784266bcab
context: use "vfs.lstat()" instead of "os.lstat()"

This patch also changes paths added to "rejected" list from full path
(referred by "p") to relative one (referred by "f"), when type of
target path is neither file nor symlink.

This change should be reasonable, because the path added to "rejected"
list is relative one, when "OSError" is raised at "lstat()".

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1111,11 +1111,11 @@ 
         ui, ds = self._repo.ui, self._repo.dirstate
         try:
             rejected = []
+            lstat = self._repo.wvfs.lstat
             for f in list:
                 scmutil.checkportable(ui, join(f))
-                p = self._repo.wjoin(f)
                 try:
-                    st = os.lstat(p)
+                    st = lstat(f)
                 except OSError:
                     ui.warn(_("%s does not exist!\n") % join(f))
                     rejected.append(f)
@@ -1129,7 +1129,7 @@ 
                 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
                     ui.warn(_("%s not added: only files and symlinks "
                               "supported currently\n") % join(f))
-                    rejected.append(p)
+                    rejected.append(f)
                 elif ds[f] in 'amn':
                     ui.warn(_("%s already tracked!\n") % join(f))
                 elif ds[f] == 'r':
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -254,6 +254,9 @@ 
     def islink(self, path=None):
         return os.path.islink(self.join(path))
 
+    def lstat(self, path=None):
+        return os.lstat(self.join(path))
+
     def makedir(self, path=None, notindexed=True):
         return util.makedir(self.join(path), notindexed)