Mercurial > hg-stable
changeset 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 | ca875b271ac3 |
files | mercurial/context.py |
diffstat | 1 files changed, 7 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:05 2013 +0900 @@ -1173,10 +1173,14 @@ wlock.release() def copy(self, source, dest): - p = self._repo.wjoin(dest) - if not os.path.lexists(p): + try: + st = self._repo.wvfs.lstat(dest) + except OSError, err: + if err.errno != errno.ENOENT: + raise self._repo.ui.warn(_("%s does not exist!\n") % dest) - elif not (os.path.isfile(p) or os.path.islink(p)): + return + if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): self._repo.ui.warn(_("copy failed: %s is not a file or a " "symbolic link\n") % dest) else: