Merge with stable
authorChristian Ebert <blacktrash@gmx.net>
Mon, 02 Apr 2012 17:28:55 +0100
changeset 1058 3639efa7216a
parent 1054 671c1a0be907 (current diff)
parent 1057 66d2754c6f30 (diff)
child 1060 2d2d93380694
Merge with stable
--- a/tests/hghave	Sat Mar 31 17:14:32 2012 +0100
+++ b/tests/hghave	Mon Apr 02 17:28:55 2012 +0100
@@ -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-keyword.t	Sat Mar 31 17:14:32 2012 +0100
+++ b/tests/test-keyword.t	Mon Apr 02 17:28:55 2012 +0100
@@ -338,18 +338,18 @@
   > EOF
   diff --git a/a b/a
   2 hunks, 2 lines changed
-  examine changes to 'a'? [Ynsfdaq?] 
+  examine changes to 'a'? [Ynesfdaq?] 
   @@ -1,3 +1,4 @@
    expand $Id$
   +foo
    do not process $Id:
    xxx $
-  record change 1/2 to 'a'? [Ynsfdaq?] 
+  record change 1/2 to 'a'? [Ynesfdaq?] 
   @@ -2,2 +3,3 @@
    do not process $Id:
    xxx $
   +bar
-  record change 2/2 to 'a'? [Ynsfdaq?] 
+  record change 2/2 to 'a'? [Ynesfdaq?] 
 
   $ hg identify
   d17e03c92c97+ tip
@@ -395,18 +395,18 @@
   > EOF
   diff --git a/a b/a
   2 hunks, 2 lines changed
-  examine changes to 'a'? [Ynsfdaq?] 
+  examine changes to 'a'? [Ynesfdaq?] 
   @@ -1,3 +1,4 @@
    expand $Id$
   +foo
    do not process $Id:
    xxx $
-  record change 1/2 to 'a'? [Ynsfdaq?] 
+  record change 1/2 to 'a'? [Ynesfdaq?] 
   @@ -2,2 +3,3 @@
    do not process $Id:
    xxx $
   +bar
-  record change 2/2 to 'a'? [Ynsfdaq?] 
+  record change 2/2 to 'a'? [Ynesfdaq?] 
 
 File a should be clean
 
@@ -462,7 +462,7 @@
   > EOF
   diff --git a/r b/r
   new file mode 100644
-  examine changes to 'r'? [Ynsfdaq?] 
+  examine changes to 'r'? [Ynesfdaq?] 
   r
   committed changeset 3:899491280810
   overwriting r expanding keywords
@@ -486,7 +486,7 @@
   > EOF
   diff --git a/i b/i
   new file mode 100644
-  examine changes to 'i'? [Ynsfdaq?] 
+  examine changes to 'i'? [Ynesfdaq?] 
   i
   committed changeset 3:5f40fe93bbdc
   $ cat i