# HG changeset patch # User Patrick Mezard # Date 2008-03-23 22:18:20 # Node ID 8f79820443a4eec43b96f970d1942ead8e949bcf # Parent b2f1d97d10ebccf03b0ecdc5090f53d0b8df0a66 Add a test for monotone conversion diff --git a/tests/hghave b/tests/hghave --- a/tests/hghave +++ b/tests/hghave @@ -33,6 +33,9 @@ def has_cvsps(): 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 @@ checks = { "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"), diff --git a/tests/test-convert-mtn b/tests/test-convert-mtn new file mode 100755 --- /dev/null +++ b/tests/test-convert-mtn @@ -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 <> $HOME/$mtndir/monotonerc < 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 + diff --git a/tests/test-convert-mtn.out b/tests/test-convert-mtn.out new file mode 100644 --- /dev/null +++ b/tests/test-convert-mtn.out @@ -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