comparison mercurial/context.py @ 19902:12a8bdd97b4f

context: use "vfs.lstat()" to examine target path instead of "os.path.*" This patch gets stat object of target path by "vfs.lstat()", and examines stat object to know the type of it. This follows the way in "workingctx.add()". This should be cheaper than original implementation invoking "lexists()", "isfile()" and "islink()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 15 Oct 2013 00:51:05 +0900
parents 4d3ce1646dfc
children d51c4d85ec23
comparison
equal deleted inserted replaced
19901:4d3ce1646dfc 19902:12a8bdd97b4f
1171 self._repo.dirstate.normal(f) 1171 self._repo.dirstate.normal(f)
1172 finally: 1172 finally:
1173 wlock.release() 1173 wlock.release()
1174 1174
1175 def copy(self, source, dest): 1175 def copy(self, source, dest):
1176 p = self._repo.wjoin(dest) 1176 try:
1177 if not os.path.lexists(p): 1177 st = self._repo.wvfs.lstat(dest)
1178 except OSError, err:
1179 if err.errno != errno.ENOENT:
1180 raise
1178 self._repo.ui.warn(_("%s does not exist!\n") % dest) 1181 self._repo.ui.warn(_("%s does not exist!\n") % dest)
1179 elif not (os.path.isfile(p) or os.path.islink(p)): 1182 return
1183 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1180 self._repo.ui.warn(_("copy failed: %s is not a file or a " 1184 self._repo.ui.warn(_("copy failed: %s is not a file or a "
1181 "symbolic link\n") % dest) 1185 "symbolic link\n") % dest)
1182 else: 1186 else:
1183 wlock = self._repo.wlock() 1187 wlock = self._repo.wlock()
1184 try: 1188 try: