--- a/mercurial/util.py Tue Jul 22 13:03:31 2008 -0500
+++ b/mercurial/util.py Wed Jul 23 16:14:45 2008 +0200
@@ -1500,7 +1500,7 @@
mode += "b" # for that other OS
nlink = -1
- if mode[0] != "r":
+ if mode not in ("r", "rb"):
try:
nlink = nlinks(f)
except OSError:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-hardlinks-safety Wed Jul 23 16:14:45 2008 +0200
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# test mq hardlinking
+echo "[extensions]" >> $HGRCPATH
+echo "mq=" >> $HGRCPATH
+
+echo % init
+hg init a
+cd a
+
+hg qimport -n foo - << EOF
+diff -r 2588a8b53d66 a
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/a Wed Jul 23 15:54:29 2008 +0200
+@@ -0,0 +1,1 @@
++a
+EOF
+
+hg qpush
+
+cd ..
+cp -al a b
+cd b
+
+hg qimport -n bar - << EOF
+diff -r 2588a8b53d66 a
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/b Wed Jul 23 15:54:29 2008 +0200
+@@ -0,0 +1,1 @@
++b
+EOF
+
+hg qpush
+
+cat .hg/patches/status
+echo %
+cat .hg/patches/series
+echo %%%
+cat ../a/.hg/patches/status
+echo %
+cat ../a/.hg/patches/series
+
+# test tags hardlinking
+hg qdel -r qbase:qtip
+
+hg tag -l lfoo
+hg tag foo
+
+cd ..
+cp -al b c
+cd c
+
+hg tag -l -r 0 lbar
+hg tag -r 0 bar
+echo %%%
+cat .hgtags
+echo %
+cat .hg/localtags
+echo %%%
+cat ../b/.hgtags
+echo %
+cat ../b/.hg/localtags
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-hardlinks-safety.out Wed Jul 23 16:14:45 2008 +0200
@@ -0,0 +1,26 @@
+% init
+adding foo to series file
+applying foo
+Now at: foo
+adding bar to series file
+applying bar
+Now at: bar
+9373c9d7b61ff62edc4685b85115a54aa92cd6fa:foo
+6dd08b80614ae7ed7f9224fb089e90deb999ae76:bar
+%
+foo
+bar
+%%%
+9373c9d7b61ff62edc4685b85115a54aa92cd6fa:foo
+%
+foo
+%%%
+6dd08b80614ae7ed7f9224fb089e90deb999ae76 foo
+9373c9d7b61ff62edc4685b85115a54aa92cd6fa bar
+%
+6dd08b80614ae7ed7f9224fb089e90deb999ae76 lfoo
+9373c9d7b61ff62edc4685b85115a54aa92cd6fa lbar
+%%%
+6dd08b80614ae7ed7f9224fb089e90deb999ae76 foo
+%
+6dd08b80614ae7ed7f9224fb089e90deb999ae76 lfoo