changeset 16326:b95b006e18cc

merge with stable
author Matt Mackall <mpm@selenic.com>
date Sat, 31 Mar 2012 11:19:09 -0500
parents 46b991a1f428 (current diff) 740f20e252bd (diff)
children d388c3fc8319
files tests/test-casefolding.t
diffstat 4 files changed, 41 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Fri Mar 30 22:08:46 2012 +0100
+++ b/mercurial/dirstate.py	Sat Mar 31 11:19:09 2012 -0500
@@ -406,9 +406,10 @@
                 # recursively normalize leading directory components
                 # against dirstate
                 if '/' in normed:
-                    d, f = normed.rsplit('/')
-                    d = self._root + "/" + self._normalize(d, isknown)
-                    folded = d + "/" + util.fspath(f, d)
+                    d, f = normed.rsplit('/', 1)
+                    d = self._normalize(d, isknown)
+                    r = self._root + "/" + d
+                    folded = d + "/" + util.fspath(f, r)
                 else:
                     folded = util.fspath(normed, self._root)
                 self._foldmap[normed] = folded
--- a/tests/hghave	Fri Mar 30 22:08:46 2012 +0100
+++ b/tests/hghave	Sat Mar 31 11:19:09 2012 -0500
@@ -4,7 +4,7 @@
 prefixed with "no-", the absence of feature is tested.
 """
 import optparse
-import os
+import os, stat
 import re
 import sys
 import tempfile
@@ -64,14 +64,21 @@
         return False
 
 def has_executablebit():
-    fd, path = tempfile.mkstemp(prefix=tempprefix)
-    os.close(fd)
     try:
-        s = os.lstat(path).st_mode
-        os.chmod(path, s | 0100)
-        return (os.lstat(path).st_mode & 0100 != 0)
-    finally:
-        os.remove(path)
+        EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
+        fh, fn = tempfile.mkstemp(dir=".", prefix='hg-checkexec-')
+        try:
+            os.close(fh)
+            m = os.stat(fn).st_mode & 0777
+            new_file_has_exec = m & EXECFLAGS
+            os.chmod(fn, m ^ EXECFLAGS)
+            exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m)
+        finally:
+            os.unlink(fn)
+    except (IOError, OSError):
+        # we don't care, the user probably won't be able to commit anyway
+        return False
+    return not (new_file_has_exec or exec_flags_cannot_flip)
 
 def has_icasefs():
     # Stolen from mercurial.util
@@ -161,6 +168,15 @@
     return matchoutput('p4 -V', r'Rev\. P4/') and matchoutput('p4d -V', r'Rev\. P4D/')
 
 def has_symlink():
+    if not hasattr(os, "symlink"):
+        return False
+    name = tempfile.mktemp(dir=".", prefix='hg-checklink-')
+    try:
+        os.symlink(".", name)
+        os.unlink(name)
+        return True
+    except (OSError, AttributeError):
+        return False
     return hasattr(os, "symlink") # FIXME: should also check file system and os
 
 def has_tla():
--- a/tests/test-casefolding.t	Fri Mar 30 22:08:46 2012 +0100
+++ b/tests/test-casefolding.t	Sat Mar 31 11:19:09 2012 -0500
@@ -73,6 +73,17 @@
 
   $ cd ..
 
+issue 3342: file in nested directory causes unexpected abort
+
+  $ hg init issue3342
+  $ cd issue3342
+
+  $ mkdir -p a/B/c/D
+  $ echo e > a/B/c/D/e
+  $ hg add a/B/c/D/e
+
+  $ cd ..
+
 issue 3340: mq does not handle case changes correctly
 
 in addition to reported case, 'hg qrefresh' is also tested against
--- a/tests/test-walkrepo.py	Fri Mar 30 22:08:46 2012 +0100
+++ b/tests/test-walkrepo.py	Sat Mar 31 11:19:09 2012 -0500
@@ -1,11 +1,12 @@
 import os
 from mercurial import hg, ui
 from mercurial.scmutil import walkrepos
+from mercurial.util import checklink
 from os import mkdir, chdir
 from os.path import join as pjoin
 
 u = ui.ui()
-sym = getattr(os, 'symlink', False) and getattr(os.path, 'samestat', False)
+sym = checklink('.')
 
 hg.repository(u, 'top1', create=1)
 mkdir('subdir')