changeset 19900:7c21e3398931

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()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 15 Oct 2013 00:51:04 +0900
parents 8c3dcbbfb5de
children 4d3ce1646dfc
files mercurial/context.py mercurial/scmutil.py
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Tue Oct 15 00:51:04 2013 +0900
+++ b/mercurial/context.py	Tue Oct 15 00:51:04 2013 +0900
@@ -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':
--- a/mercurial/scmutil.py	Tue Oct 15 00:51:04 2013 +0900
+++ b/mercurial/scmutil.py	Tue Oct 15 00:51:04 2013 +0900
@@ -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)