[PATCH] Make test-hardlinks-safety portable, inkl. actual hardlink check

Christian Ebert blacktrash at gmx.net
Wed Aug 20 10:31:22 CDT 2008


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1219245997 -7200
# Node ID 33923c0e2e277226cdd51b14cbcdf82dec6b1053
# Parent  7d1713353aaf24a31d358c7934868e4d31843ee2
Make test-hardlinks-safety portable

On some systems cp cannot create/preserve hardlinks.
Use util.copyfiles instead, after making sure it actually does
create hardlinks.

diff --git a/tests/test-hardlinks-safety b/tests/test-hardlinks-safety
--- a/tests/test-hardlinks-safety
+++ b/tests/test-hardlinks-safety
@@ -1,4 +1,21 @@
 #!/bin/sh
+
+# some implementations of cp can't create hardlinks
+cat > cp.py <<EOF
+from mercurial import util
+import sys
+args = sys.argv[1:]
+util.copyfiles(args[1], args[2], hardlink=args[0]=='hard')
+EOF
+
+# test hardlinking outside hg
+mkdir x
+echo foo > x/a
+
+python cp.py hard x y
+echo bar >> y/a
+echo % no diff if hardlink
+diff x/a y/a
 
 # test mq hardlinking
 echo "[extensions]" >> $HGRCPATH
@@ -21,7 +38,7 @@
 hg qpush
 
 cd ..
-cp -al a b
+python cp.py hard a b
 cd b
 
 hg qimport -n bar - << EOF
@@ -51,7 +68,7 @@
 hg tag foo
 
 cd ..
-cp -al b c
+python cp.py hard b c
 cd c
 
 hg tag -l -r 0 lbar
diff --git a/tests/test-hardlinks-safety.out b/tests/test-hardlinks-safety.out
--- a/tests/test-hardlinks-safety.out
+++ b/tests/test-hardlinks-safety.out
@@ -1,3 +1,4 @@
+% no diff if hardlink
 % init
 adding foo to series file
 applying foo


More information about the Mercurial-devel mailing list