changeset 5253:fd371f99f20b

Automated merge with http://hg.intevation.org/mercurial/crew
author Bryan O'Sullivan <bos@serpentine.com>
date Mon, 27 Aug 2007 13:38:34 -0700
parents 0b0caffcf175 (current diff) 37c610c41ed6 (diff)
children b534c502bfb3
files tests/test-convert-svn
diffstat 4 files changed, 117 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/tests/hghave
+++ b/tests/hghave
@@ -5,11 +5,22 @@ prefixed with "no-", the absence of feat
 """
 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 @@ def has_lsprof():
         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 @@ checks = {
     "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
+++ b/tests/run-tests.py
@@ -152,7 +152,13 @@ def install_hg():
     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()
 
new file mode 100755
--- /dev/null
+++ b/tests/test-convert-svn
@@ -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
+
new file mode 100644
--- /dev/null
+++ b/tests/test-convert-svn.out
@@ -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