convert: fix test-convert-svn-* problems with mtime not changing
authorPeter Arrenbrecht <peter.arrenbrecht@gmail.com>
Tue, 01 Apr 2008 09:17:11 +0200
changeset 6439 c1b47c0fd2b6
parent 6438 a60b711c7ac4
child 6440 00a3369d06b6
child 6443 34eeb891d227
convert: fix test-convert-svn-* problems with mtime not changing The `svn commit` command does not detect changed files unless their mtime has changed. A quick succession of, for instance, `svn co ...; echo x >> y; svn ci` can thus lead to the change to y being ignored. Edited by pmezard to write in binary mode.
tests/svn-safe-append.py
tests/test-convert-svn-branches
tests/test-convert-svn-move
tests/test-convert-svn-sink
tests/test-convert-svn-source
tests/test-convert-svn-startrev
tests/test-convert-svn-tags
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/svn-safe-append.py	Tue Apr 01 09:17:11 2008 +0200
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+__doc__ = """Same as `echo a >> b`, but ensures a changed mtime of b.
+Without this svn will not detect workspace changes."""
+
+import sys, os
+
+text = sys.argv[1]
+fname = sys.argv[2]
+
+f = open(fname, "ab")
+try:
+    before = os.fstat(f.fileno()).st_mtime
+    f.write(text)
+    f.write("\n")
+finally:
+    f.close()
+inc = 1
+now = os.stat(fname).st_mtime
+while now == before:
+    t = now + inc
+    inc += 1
+    os.utime(fname, (t, t))
+    now = os.stat(fname).st_mtime
+
--- a/tests/test-convert-svn-branches	Tue Apr 01 08:33:17 2008 +0200
+++ b/tests/test-convert-svn-branches	Tue Apr 01 09:17:11 2008 +0200
@@ -48,25 +48,25 @@
 svn up
 
 echo % update trunk
-echo "what can I say ?" >> trunk/letter.txt
+"$TESTDIR/svn-safe-append.py" "what can I say ?" trunk/letter.txt
 svn ci -m "change letter"
 
 echo % update old branch
-echo "what's up ?" >> branches/old/letter2.txt
+"$TESTDIR/svn-safe-append.py" "what's up ?" branches/old/letter2.txt
 svn ci -m "change letter2"
 
 echo % create a cross-branch revision
 svn move -m "move letter2" trunk/letter2.txt \
     branches/old/letter3.txt
-echo "I am fine" >> branches/old/letter3.txt
+"$TESTDIR/svn-safe-append.py" "I am fine" branches/old/letter3.txt
 svn ci -m "move and update letter3.txt"
 
 echo % update old branch again
-echo "bye" >> branches/old/letter2.txt
+"$TESTDIR/svn-safe-append.py" "bye" branches/old/letter2.txt
 svn ci -m "change letter2 again"
 
 echo % update trunk again
-echo "how are you ?" >> trunk/letter.txt
+"$TESTDIR/svn-safe-append.py" "how are you ?" trunk/letter.txt
 svn ci -m "last change to letter"
 cd ..
 
--- a/tests/test-convert-svn-move	Tue Apr 01 08:33:17 2008 +0200
+++ b/tests/test-convert-svn-move	Tue Apr 01 09:17:11 2008 +0200
@@ -38,8 +38,8 @@
 echo % update svn repository
 svn co $svnurl A | fix_path
 cd A
-echo a >> trunk/a
-echo c >> trunk/d1/c
+"$TESTDIR/svn-safe-append.py" a trunk/a
+"$TESTDIR/svn-safe-append.py" c trunk/d1/c
 svn ci -m commitbeforemove
 svn mv $svnurl/trunk $svnurl/subproject -m movedtrunk
 svn up
@@ -51,7 +51,7 @@
 svn ci -m createbranches
 svn mv $svnurl/subproject/d1 $svnurl/subproject/trunk/d1 -m moved1
 svn up
-echo b >> subproject/trunk/d1/b
+"$TESTDIR/svn-safe-append.py" b subproject/trunk/d1/b
 svn ci -m changeb
 svn mv $svnurl/subproject/trunk/d1 $svnurl/subproject/branches/d1 -m moved1again
 cd ..
--- a/tests/test-convert-svn-sink	Tue Apr 01 08:33:17 2008 +0200
+++ b/tests/test-convert-svn-sink	Tue Apr 01 09:17:11 2008 +0200
@@ -32,7 +32,7 @@
 echo % add
 hg --cwd a ci -d '0 0' -A -m 'add a file'
 
-echo a >> a/a
+"$TESTDIR/svn-safe-append.py" a a/a
 echo % modify
 hg --cwd a ci -d '1 0' -m 'modify a file'
 hg --cwd a tip -q
@@ -107,21 +107,21 @@
 echo base > b/b
 hg --cwd b ci -d '0 0' -Ambase
 
-echo left-1 >> b/b
+"$TESTDIR/svn-safe-append.py" left-1 b/b
 echo left-1 > b/left-1
 hg --cwd b ci -d '1 0' -Amleft-1
 
-echo left-2 >> b/b
+"$TESTDIR/svn-safe-append.py" left-2 b/b
 echo left-2 > b/left-2
 hg --cwd b ci -d '2 0' -Amleft-2
 
 hg --cwd b up 0
 
-echo right-1 >> b/b
+"$TESTDIR/svn-safe-append.py" right-1 b/b
 echo right-1 > b/right-1
 hg --cwd b ci -d '3 0' -Amright-1
 
-echo right-2 >> b/b
+"$TESTDIR/svn-safe-append.py" right-2 b/b
 echo right-2 > b/right-2
 hg --cwd b ci -d '4 0' -Amright-2
 
--- a/tests/test-convert-svn-source	Tue Apr 01 08:33:17 2008 +0200
+++ b/tests/test-convert-svn-source	Tue Apr 01 09:17:11 2008 +0200
@@ -41,12 +41,12 @@
 svn add letter.txt
 svn ci -m hello
 
-echo world >> letter.txt
+"$TESTDIR/svn-safe-append.py" world letter.txt
 svn ci -m world
 
 svn copy -m "tag v0.1" $svnurl/trunk $svnurl/tags/v0.1
 
-echo 'nice day today!' >> letter.txt
+"$TESTDIR/svn-safe-append.py" 'nice day today!' letter.txt
 svn ci -m "nice day"
 cd ..
 
@@ -55,14 +55,14 @@
 
 echo % update svn repository again
 cd B
-echo "see second letter" >> letter.txt
+"$TESTDIR/svn-safe-append.py" "see second letter" letter.txt
 echo "nice to meet you" > letter2.txt
 svn add letter2.txt
 svn ci -m "second letter"
 
 svn copy -m "tag v0.2" $svnurl/trunk $svnurl/tags/v0.2
 
-echo "blah-blah-blah" >> letter2.txt
+"$TESTDIR/svn-safe-append.py" "blah-blah-blah" letter2.txt
 svn ci -m "work in progress"
 cd ..
 
--- a/tests/test-convert-svn-startrev	Tue Apr 01 08:33:17 2008 +0200
+++ b/tests/test-convert-svn-startrev	Tue Apr 01 09:17:11 2008 +0200
@@ -42,16 +42,16 @@
 svn rm trunk/b
 svn ci -m removeb
 svn up
-echo a >> trunk/a
+"$TESTDIR/svn-safe-append.py" a trunk/a
 svn ci -m changeaa
 
 echo % branch
 svn up
 svn copy trunk branches/branch1
-echo a >> branches/branch1/a
+"$TESTDIR/svn-safe-append.py" a branches/branch1/a
 svn ci -m "branch, changeaaa"
 
-echo a >> branches/branch1/a
+"$TESTDIR/svn-safe-append.py" a branches/branch1/a
 echo c > branches/branch1/c
 svn add branches/branch1/c
 svn ci -m "addc,changeaaaa"
--- a/tests/test-convert-svn-tags	Tue Apr 01 08:33:17 2008 +0200
+++ b/tests/test-convert-svn-tags	Tue Apr 01 09:17:11 2008 +0200
@@ -39,13 +39,13 @@
 echo a > trunk/a
 svn add trunk/a
 svn ci -m adda
-echo a >> trunk/a
+"$TESTDIR/svn-safe-append.py" a trunk/a
 svn ci -m changea
-echo a >> trunk/a
+"$TESTDIR/svn-safe-append.py" a trunk/a
 svn ci -m changea2
 # Add an unrelated commit to test that tags are bound to the
 # correct "from" revision and not a dummy one
-echo a >> unrelated/dummy
+"$TESTDIR/svn-safe-append.py" a unrelated/dummy
 svn add unrelated/dummy
 svn ci -m unrelatedchange
 echo % tag current revision
@@ -53,7 +53,7 @@
 svn copy trunk tags/trunk.v1
 svn copy trunk tags/trunk.badtag
 svn ci -m "tagging trunk.v1 trunk.badtag"
-echo a >> trunk/a
+"$TESTDIR/svn-safe-append.py" a trunk/a
 svn ci -m changea3
 echo % fix the bad tag
 # trunk.badtag should not show in converted tags