Add test for relink extension stable
authorPatrick Mezard <pmezard@gmail.com>
Fri, 08 Jan 2010 22:30:07 +0100
branchstable
changeset 10217 2bbb4c8eb27e
parent 10211 a474f950357b
child 10218 750b7a4f01f6
Add test for relink extension
tests/test-relink
tests/test-relink.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-relink	Fri Jan 08 22:30:07 2010 +0100
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+echo "[extensions]" >> $HGRCPATH
+echo "relink=" >> $HGRCPATH
+
+cat > arelinked.py <<EOF
+import sys, os
+path1, path2 = sys.argv[1:3]
+if os.stat(path1).st_ino == os.stat(path2).st_ino:
+    print '%s == %s' % (path1, path2)
+else:
+    print '%s != %s' % (path1, path2)
+EOF
+
+echo '% create source repository'
+hg init repo
+cd repo
+echo '[ui]' > .hg/hgrc
+echo 'username= A. Foo <a.foo@bar.com>' >> .hg/hgrc
+echo a > a
+echo b > b
+hg ci -Am addfile
+echo a >> a
+echo a >> b
+hg ci -Am changefiles
+cd ..
+
+echo '% clone and pull to break links'
+hg clone --pull -r0 repo clone
+cd clone
+echo '[ui]' >> .hg/hgrc
+echo 'username= A. Baz <a.baz@bar.com>' >> .hg/hgrc
+hg pull -q
+echo b >> b
+hg ci -m changeb
+
+echo '% relink'
+hg relink --debug | sed 's:relinking.*store:relinking .hg/store:g'
+cd ..
+
+echo '% check hardlinks'
+python arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i
+python arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-relink.out	Fri Jan 08 22:30:07 2010 +0100
@@ -0,0 +1,24 @@
+% create source repository
+adding a
+adding b
+% clone and pull to break links
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 2 changes to 2 files
+updating to branch default
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+created new head
+% relink
+relinking .hg/store
+collected 4 candidate storage files
+not linkable: 00changelog.i
+not linkable: 00manifest.i
+not linkable: data/b.i
+pruned down to 1 probably relinkable files
+relink: data/a.i 1/1  files (1e+02%)
+relinked 1 files (136 bytes reclaimed)
+% check hardlinks
+repo/.hg/store/data/a.i == clone/.hg/store/data/a.i
+repo/.hg/store/data/b.i != clone/.hg/store/data/b.i