# HG changeset patch # User Peter Arrenbrecht # Date 2008-04-01 07:17:11 # Node ID c1b47c0fd2b6a388b5eb7f97a95046ce88f82244 # Parent a60b711c7ac40d253d3629a4abf1c5ddd9fe95de 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. diff --git a/tests/svn-safe-append.py b/tests/svn-safe-append.py new file mode 100755 --- /dev/null +++ b/tests/svn-safe-append.py @@ -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 + diff --git a/tests/test-convert-svn-branches b/tests/test-convert-svn-branches --- a/tests/test-convert-svn-branches +++ b/tests/test-convert-svn-branches @@ -48,25 +48,25 @@ svn ci -m "branch trunk, remove letter3" 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 .. diff --git a/tests/test-convert-svn-move b/tests/test-convert-svn-move --- a/tests/test-convert-svn-move +++ b/tests/test-convert-svn-move @@ -38,8 +38,8 @@ svn import -m "init projA" projA $svnurl 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 add subproject/branches 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 .. diff --git a/tests/test-convert-svn-sink b/tests/test-convert-svn-sink --- a/tests/test-convert-svn-sink +++ b/tests/test-convert-svn-sink @@ -32,7 +32,7 @@ echo b > a/d1/d2/b 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 @@ hg init b 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 diff --git a/tests/test-convert-svn-source b/tests/test-convert-svn-source --- a/tests/test-convert-svn-source +++ b/tests/test-convert-svn-source @@ -41,12 +41,12 @@ echo hello > letter.txt 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 @@ hg convert $svnurl B-hg 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 .. diff --git a/tests/test-convert-svn-startrev b/tests/test-convert-svn-startrev --- a/tests/test-convert-svn-startrev +++ b/tests/test-convert-svn-startrev @@ -42,16 +42,16 @@ svn ci -m createab 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" diff --git a/tests/test-convert-svn-tags b/tests/test-convert-svn-tags --- a/tests/test-convert-svn-tags +++ b/tests/test-convert-svn-tags @@ -39,13 +39,13 @@ cd A 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 up 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