changeset 27573:ea389970c084 stable 3.6.3

merge with i18n
author Matt Mackall <mpm@selenic.com>
date Sat, 02 Jan 2016 01:49:18 +0100
parents ffffe735175f (current diff) 6a6e78f84cc6 (diff)
children 7d8edb6992dc
files
diffstat 3 files changed, 34 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Fri Jan 01 12:21:11 2016 +0900
+++ b/mercurial/merge.py	Sat Jan 02 01:49:18 2016 +0100
@@ -404,7 +404,7 @@
 def _checkunknownfile(repo, wctx, mctx, f, f2=None):
     if f2 is None:
         f2 = f
-    return (os.path.isfile(repo.wjoin(f))
+    return (repo.wvfs.isfileorlink(f)
         and repo.wvfs.audit.check(f)
         and repo.dirstate.normalize(f) not in repo.dirstate
         and mctx[f2].cmp(wctx[f]))
--- a/mercurial/scmutil.py	Fri Jan 01 12:21:11 2016 +0900
+++ b/mercurial/scmutil.py	Sat Jan 02 01:49:18 2016 +0100
@@ -312,6 +312,17 @@
     def islink(self, path=None):
         return os.path.islink(self.join(path))
 
+    def isfileorlink(self, path=None):
+        '''return whether path is a regular file or a symlink
+
+        Unlike isfile, this doesn't follow symlinks.'''
+        try:
+            st = self.lstat(path)
+        except OSError:
+            return False
+        mode = st.st_mode
+        return stat.S_ISREG(mode) or stat.S_ISLNK(mode)
+
     def reljoin(self, *paths):
         """join various elements of a path together (as os.path.join would do)
 
--- a/tests/test-merge1.t	Fri Jan 01 12:21:11 2016 +0900
+++ b/tests/test-merge1.t	Sat Jan 02 01:49:18 2016 +0100
@@ -102,6 +102,28 @@
   b: untracked file differs
   abort: untracked files in working directory differ from files in requested revision
   [255]
+
+#if symlink
+symlinks to directories should be treated as regular files (issue5027)
+  $ rm b
+  $ ln -s 'This is file b2' b
+  $ hg merge 1
+  b: untracked file differs
+  abort: untracked files in working directory differ from files in requested revision
+  [255]
+symlinks shouldn't be followed
+  $ rm b
+  $ echo This is file b1 > .hg/b
+  $ ln -s .hg/b b
+  $ hg merge 1
+  b: untracked file differs
+  abort: untracked files in working directory differ from files in requested revision
+  [255]
+
+  $ rm b
+  $ echo This is file b2 > b
+#endif
+
 merge of b expected
   $ hg merge -f 1
   merging b