changeset 24902:986a5c23b1c1 stable

util.checkcase: don't abort on broken symlinks One case where that would happen is while trying to resolve a subrepo, if the path to the subrepo was actually a broken symlink. This bug was exposed by an hg-git test.
author Siddharth Agarwal <sid0@fb.com>
date Sun, 03 May 2015 12:49:15 -0700
parents c48850339988
children 09124cce913f
files mercurial/util.py tests/test-subrepo-git.t
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Fri May 01 16:49:15 2015 -0500
+++ b/mercurial/util.py	Sun May 03 12:49:15 2015 -0700
@@ -877,7 +877,7 @@
     Requires a path (like /foo/.hg) ending with a foldable final
     directory component.
     """
-    s1 = os.stat(path)
+    s1 = os.lstat(path)
     d, b = os.path.split(path)
     b2 = b.upper()
     if b == b2:
@@ -886,7 +886,7 @@
             return True # no evidence against case sensitivity
     p2 = os.path.join(d, b2)
     try:
-        s2 = os.stat(p2)
+        s2 = os.lstat(p2)
         if s2 == s1:
             return False
         return True
--- a/tests/test-subrepo-git.t	Fri May 01 16:49:15 2015 -0500
+++ b/tests/test-subrepo-git.t	Sun May 03 12:49:15 2015 -0700
@@ -381,6 +381,20 @@
   $ hg commit --subrepos -qm missing
   abort: subrepo s is missing (in subrepo s)
   [255]
+
+#if symlink
+Don't crash if subrepo is a broken symlink
+  $ ln -s broken s
+  $ hg status -S
+  $ hg push -q
+  abort: subrepo s is missing (in subrepo s)
+  [255]
+  $ hg commit --subrepos -qm missing
+  abort: subrepo s is missing (in subrepo s)
+  [255]
+  $ rm s
+#endif
+
   $ hg update -C 2> /dev/null
   cloning subrepo s from $TESTTMP/gitroot
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved