Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 27571:6a6e78f84cc6 stable
merge: while checking for unknown files don't follow symlinks (issue5027)
Previously, we were using Python's native 'os.path.isfile' method which follows
symlinks. In this case, since we're operating on repo contents, we don't want
to follow symlinks.
There's a behaviour change here, as shown by the second part of the added test.
Consider a symlink 'f' pointing to a file containing 'abc'. If we try and
replace it with a file with contents 'abc', previously we would have let it
though. Now we don't. Although this breaks naive inspection with tools like
'cat' and 'diff', on balance I believe this is the right change.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 28 Dec 2015 22:51:37 -0800 |
parents | 88c4e97b9669 |
children | b8405d739149 |
comparison
equal
deleted
inserted
replaced
27555:ca8ada499529 | 27571:6a6e78f84cc6 |
---|---|
309 def isfile(self, path=None): | 309 def isfile(self, path=None): |
310 return os.path.isfile(self.join(path)) | 310 return os.path.isfile(self.join(path)) |
311 | 311 |
312 def islink(self, path=None): | 312 def islink(self, path=None): |
313 return os.path.islink(self.join(path)) | 313 return os.path.islink(self.join(path)) |
314 | |
315 def isfileorlink(self, path=None): | |
316 '''return whether path is a regular file or a symlink | |
317 | |
318 Unlike isfile, this doesn't follow symlinks.''' | |
319 try: | |
320 st = self.lstat(path) | |
321 except OSError: | |
322 return False | |
323 mode = st.st_mode | |
324 return stat.S_ISREG(mode) or stat.S_ISLNK(mode) | |
314 | 325 |
315 def reljoin(self, *paths): | 326 def reljoin(self, *paths): |
316 """join various elements of a path together (as os.path.join would do) | 327 """join various elements of a path together (as os.path.join would do) |
317 | 328 |
318 The vfs base is not injected so that path stay relative. This exists | 329 The vfs base is not injected so that path stay relative. This exists |