[PATCH 6 of 9] context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Mon Oct 14 16:16:06 UTC 2013
# HG changeset patch
# User FUJIWARA Katsunori <foozy at 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()".
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)
More information about the Mercurial-devel
mailing list