Add a test for monotone conversion
authorPatrick Mezard <pmezard@gmail.com>
Sun, 23 Mar 2008 23:18:20 +0100
changeset 6372 8f79820443a4
parent 6371 b2f1d97d10eb
child 6373 7010e4557963
Add a test for monotone conversion
tests/hghave
tests/test-convert-mtn
tests/test-convert-mtn.out
--- a/tests/hghave	Sun Mar 23 21:03:24 2008 -0300
+++ b/tests/hghave	Sun Mar 23 23:18:20 2008 +0100
@@ -33,6 +33,9 @@
 def has_darcs():
     return matchoutput('darcs', 'darcs version', True)
 
+def has_mtn():
+    return matchoutput('mtn --version', 'monotone', True)
+
 def has_eol_in_paths():
     try:
         fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r')
@@ -125,6 +128,7 @@
     "git": (has_git, "git command line client"),
     "hotshot": (has_hotshot, "python hotshot module"),
     "lsprof": (has_lsprof, "python lsprof module"),
+    "mtn": (has_mtn, "monotone client"),
     "svn": (has_svn, "subversion client and admin tools"),
     "svn-bindings": (has_svn_bindings, "subversion python bindings"),
     "symlink": (has_symlink, "symbolic links"),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-mtn	Sun Mar 23 23:18:20 2008 +0100
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" mtn || exit 80
+
+# Monotone directory is called .monotone on *nix and monotone
+# on Windows. Having a variable here ease test patching.
+mtndir=.monotone
+echo "[extensions]" >> $HGRCPATH
+echo "convert=" >> $HGRCPATH
+echo 'hgext.graphlog =' >> $HGRCPATH
+
+HOME=`pwd`/do_not_use_HOME_mtn; export HOME
+# Windows version of monotone home
+APPDATA=$HOME; export APPDATA
+
+echo % tedious monotone keys configuration
+# The /dev/null redirection is necessary under Windows, or
+# it complains about home directory permissions
+mtn --quiet genkey test@selenic.com 1>/dev/null 2>&1 <<EOF
+passphrase
+passphrase
+EOF
+cat >> $HOME/$mtndir/monotonerc <<EOF
+function get_passphrase(keypair_id)
+    return "passphrase"
+end
+EOF
+
+echo % create monotone repository
+mtn db init --db=repo.mtn
+mtn --db=repo.mtn --branch=com.selenic.test setup workingdir
+cd workingdir
+echo a > a
+mkdir dir
+echo b > dir/b
+python -c 'file("bin", "wb").write("a\\x00b")'
+echo c > c
+mtn add a dir/b c bin
+mtn ci -m initialize
+echo % update monotone working directory
+mtn mv a dir/a
+echo a >> dir/a
+echo b >> dir/b
+mtn drop c
+python -c 'file("bin", "wb").write("b\\x00c")'
+mtn ci -m update1
+cd ..
+
+echo % convert once
+hg convert -s mtn repo.mtn
+
+cd workingdir
+echo e > e
+mtn add e
+mtn drop dir/b
+mtn mv bin bin2
+mtn ci -m update2
+cd ..
+
+echo % convert incrementally
+hg convert -s mtn repo.mtn
+
+glog()
+{
+    hg glog --template '#rev# "#desc|firstline#" files: #files#\n' "$@"
+}
+
+cd repo.mtn-hg
+hg up -C
+glog
+echo % manifest
+# BUG: c and dir/b should not appear here
+hg manifest
+echo % contents
+cat dir/a
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-mtn.out	Sun Mar 23 23:18:20 2008 +0100
@@ -0,0 +1,50 @@
+% tedious monotone keys configuration
+% create monotone repository
+mtn: adding a to workspace manifest
+mtn: adding bin to workspace manifest
+mtn: adding c to workspace manifest
+mtn: adding dir to workspace manifest
+mtn: adding dir/b to workspace manifest
+mtn: beginning commit on branch 'com.selenic.test'
+mtn: committed revision 803ef0bf815e35b951dbd4310acd1e45e675016e
+% update monotone working directory
+mtn: skipping dir, already accounted for in workspace
+mtn: renaming a to dir/a in workspace manifest
+mtn: dropping c from workspace manifest
+mtn: beginning commit on branch 'com.selenic.test'
+mtn: committed revision 4daf60753d6fe21a06ce5f716303fe55fd6d3a56
+% convert once
+assuming destination repo.mtn-hg
+initializing destination repo.mtn-hg repository
+scanning source...
+sorting...
+converting...
+1 initialize
+0 update1
+mtn: adding e to workspace manifest
+mtn: dropping dir/b from workspace manifest
+mtn: renaming bin to bin2 in workspace manifest
+mtn: beginning commit on branch 'com.selenic.test'
+mtn: committed revision 6c6977a6ef609ec80e40779f89dbd2772c96de62
+% convert incrementally
+assuming destination repo.mtn-hg
+scanning source...
+sorting...
+converting...
+0 update2
+5 files updated, 0 files merged, 0 files removed, 0 files unresolved
+@  2 "update2" files: bin bin2 e
+|
+o  1 "update1" files: a bin dir/a dir/b
+|
+o  0 "initialize" files: a bin c dir/b
+
+% manifest
+bin2
+c
+dir/a
+dir/b
+e
+% contents
+a
+a