Automated merge with http://hg.intevation.org/mercurial/crew
authorBryan O'Sullivan <bos@serpentine.com>
Mon, 27 Aug 2007 13:38:34 -0700
changeset 5257 fd371f99f20b
parent 5256 0b0caffcf175 (current diff)
parent 5255 37c610c41ed6 (diff)
child 5258 b534c502bfb3
Automated merge with http://hg.intevation.org/mercurial/crew
tests/test-convert-svn
--- a/tests/hghave	Mon Aug 27 13:38:16 2007 -0700
+++ b/tests/hghave	Mon Aug 27 13:38:34 2007 -0700
@@ -5,11 +5,22 @@
 """
 import optparse
 import os
+import re
 import sys
 import tempfile
 
 tempprefix = 'hg-hghave-'
 
+def matchoutput(cmd, regexp):
+    """Return True if cmd executes successfully and its output
+    is matched by the supplied regular expression.
+    """
+    r = re.compile(regexp)
+    fh = os.popen(cmd)
+    s = fh.read()
+    ret = fh.close()
+    return ret is None and r.search(s)
+
 def has_symlink():
     return hasattr(os, "symlink")
 
@@ -52,10 +63,18 @@
         return False
 
 def has_git():
-    fh = os.popen('git --version 2>&1')
-    s = fh.read()
-    ret = fh.close()
-    return ret is None and s.startswith('git version')
+    return matchoutput('git --version 2>&1', r'^git version')
+
+def has_svn():
+    return matchoutput('svn --version 2>&1', r'^svn, version') and \
+        matchoutput('svnadmin --version 2>&1', r'^svnadmin, version')
+
+def has_svn_bindings():
+    try:
+        import svn.core
+        return True
+    except ImportError:
+        return False
 
 checks = {
     "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
@@ -64,6 +83,8 @@
     "fifo": (has_fifo, "named pipes"),
     "hotshot": (has_hotshot, "python hotshot module"),
     "lsprof": (has_lsprof, "python lsprof module"),
+    "svn": (has_svn, "subversion client and admin tools"),
+    "svn-bindings": (has_svn_bindings, "subversion python bindings"),
     "symlink": (has_symlink, "symbolic links"),
 }
 
--- a/tests/run-tests.py	Mon Aug 27 13:38:16 2007 -0700
+++ b/tests/run-tests.py	Mon Aug 27 13:38:34 2007 -0700
@@ -152,7 +152,13 @@
     os.chdir(TESTDIR)
 
     os.environ["PATH"] = "%s%s%s" % (BINDIR, os.pathsep, os.environ["PATH"])
-    os.environ["PYTHONPATH"] = PYTHONDIR
+
+    pythonpath = os.environ.get("PYTHONPATH")
+    if pythonpath:
+        pythonpath = PYTHONDIR + os.pathsep + pythonpath
+    else:
+        pythonpath = PYTHONDIR
+    os.environ["PYTHONPATH"] = pythonpath
 
     use_correct_python()
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-svn	Mon Aug 27 13:38:34 2007 -0700
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" svn svn-bindings || exit 80
+
+fix_path()
+{
+    tr '\\' /
+}
+
+echo "[extensions]" >> $HGRCPATH
+echo "convert = " >> $HGRCPATH
+
+svnadmin create svn-repo
+
+echo % initial svn import
+mkdir t
+cd t
+echo a > a
+cd ..
+
+svnpath=`pwd | tr '\\' /`
+# SVN wants all paths to start with a slash. Unfortunately,
+# Windows ones don't. Handle that.
+expr $svnpath : "\/" > /dev/null
+if [ $? -ne 0 ]; then
+    svnpath='/'$svnpath
+fi
+
+svnurl=file://$svnpath/svn-repo/trunk
+svn import -m init t $svnurl | fix_path
+
+echo % update svn repository
+svn co $svnurl t2 | fix_path
+cd t2
+echo b >> a
+echo b > b
+svn add b
+svn ci -m changea
+cd ..
+
+echo % convert to hg once
+hg convert $svnurl
+
+echo % update svn repository again
+cd t2
+echo c >> a
+echo c >> b
+svn ci -m changeb
+cd ..
+
+echo % test incremental conversion
+hg convert $svnurl
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-svn.out	Mon Aug 27 13:38:34 2007 -0700
@@ -0,0 +1,32 @@
+% initial svn import
+Adding         t/a
+
+Committed revision 1.
+% update svn repository
+A    t2/a
+Checked out revision 1.
+A         b
+Sending        a
+Adding         b
+Transmitting file data ..
+Committed revision 2.
+% convert to hg once
+assuming destination trunk-hg
+initializing destination trunk-hg repository
+scanning source...
+sorting...
+converting...
+1 init
+0 changea
+% update svn repository again
+Sending        a
+Sending        b
+Transmitting file data ..
+Committed revision 3.
+% test incremental conversion
+assuming destination trunk-hg
+destination trunk-hg is a Mercurial repository
+scanning source...
+sorting...
+converting...
+0 changeb