[PATCH 2 of 2] tests: add simple testcase for p4 source

Frank Kingswood frank at kingswood-consulting.co.uk
Mon Feb 23 06:51:21 CST 2009


# HG changeset patch
# User Frank Kingswood <frank at kingswood-consulting.co.uk>
# Date 1235393344 0
# Node ID 1721d1329260de4733239e767bc9bb7e5170299c
# Parent  2ecdf26af674526c0b77a9cfe9cdb8297f585487
tests: add simple testcase for p4 source

diff -r 2ecdf26af674 -r 1721d1329260 tests/hghave
--- a/tests/hghave	Mon Feb 23 12:48:45 2009 +0000
+++ b/tests/hghave	Mon Feb 23 12:49:04 2009 +0000
@@ -125,6 +125,9 @@
     except ImportError:
         return False
 
+def has_p4():
+    return matchoutput('p4 -V', r'Rev\. P4/') and matchoutput('p4d -V', r'Rev\. P4D/')
+
 def has_symlink():
     return hasattr(os, "symlink")
 
@@ -173,6 +176,7 @@
     "lsprof": (has_lsprof, "python lsprof module"),
     "mtn": (has_mtn, "monotone client (> 0.31)"),
     "outer-repo": (has_outer_repo, "outer repo"),
+    "p4": (has_p4, "Perforce server and client"),
     "pygments": (has_pygments, "Pygments source highlighting library"),
     "svn": (has_svn, "subversion client and admin tools"),
     "svn-bindings": (has_svn_bindings, "subversion python bindings"),
diff -r 2ecdf26af674 -r 1721d1329260 tests/test-convert-p4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-p4	Mon Feb 23 12:49:04 2009 +0000
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" p4 || exit 80
+
+echo "[extensions]" >> $HGRCPATH
+echo "convert = " >> $HGRCPATH
+
+echo % create p4 depot
+export P4ROOT=$PWD/depot
+export P4AUDIT=$P4ROOT/audit
+export P4JOURNAL=$P4ROOT/journal
+export P4LOG=$P4ROOT/log
+export P4PORT=localhost:16661
+export P4DEBUG=1
+
+echo % start the p4 server
+[ ! -d $P4ROOT ] && mkdir $P4ROOT
+p4d -f -J off >$P4ROOT/stdout 2>$P4ROOT/stderr &
+trap "echo % stop the p4 server ; p4 admin stop" EXIT
+
+# wait for the server to initialize
+sleep 1
+
+echo % create a client spec
+export P4CLIENT=hg-p4-import
+DEPOTPATH=//depot/test-mercurial-import/...
+p4 client -o | sed '/^View:/,$ d' >p4client
+echo View: >>p4client
+echo " $DEPOTPATH //$P4CLIENT/..." >>p4client
+p4 client -i <p4client
+
+echo % populate the depot
+echo a > a
+mkdir b
+echo c > b/c
+p4 add a b/c
+p4 submit -d initial
+
+echo % change some files
+p4 edit a
+echo aa >> a
+p4 submit -d "change a"
+
+p4 edit b/c
+echo cc >> b/c
+p4 submit -d "change b/c"
+
+echo % convert
+hg convert -s p4 $DEPOTPATH dst
+hg -R dst log --template 'rev=#rev# desc="#desc#" tags="#tags#" files="#files#"\n'
+
+echo % change some files
+p4 edit a b/c
+echo aaa >> a
+echo ccc >> b/c
+p4 submit -d "change a b/c"
+
+echo % convert again
+hg convert -s p4 $DEPOTPATH dst
+hg -R dst log --template 'rev=#rev# desc="#desc#" tags="#tags#" files="#files#"\n'
+
+
diff -r 2ecdf26af674 -r 1721d1329260 tests/test-convert-p4.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-p4.out	Mon Feb 23 12:49:04 2009 +0000
@@ -0,0 +1,68 @@
+% create p4 depot
+% start the p4 server
+% create a client spec
+Client hg-p4-import saved.
+% populate the depot
+//depot/test-mercurial-import/a#1 - opened for add
+//depot/test-mercurial-import/b/c#1 - opened for add
+Submitting change 1.
+Locking 2 files ...
+add //depot/test-mercurial-import/a#1
+add //depot/test-mercurial-import/b/c#1
+Change 1 submitted.
+% change some files
+//depot/test-mercurial-import/a#1 - opened for edit
+Submitting change 2.
+Locking 1 files ...
+edit //depot/test-mercurial-import/a#2
+Change 2 submitted.
+//depot/test-mercurial-import/b/c#1 - opened for edit
+Submitting change 3.
+Locking 1 files ...
+edit //depot/test-mercurial-import/b/c#2
+Change 3 submitted.
+% convert
+initializing destination dst repository
+reading p4 views
+collecting p4 changelists
+1 initial
+2 change a
+3 change b/c
+scanning source...
+sorting...
+converting...
+2 initial
+1 change a
+0 change b/c
+updating tags
+rev=3 desc="update tags" tags="tip" files=".hgtags"
+rev=2 desc="change b/c" tags="P4 3" files="b/c"
+rev=1 desc="change a" tags="" files="a"
+rev=0 desc="initial" tags="" files="a b/c"
+% change some files
+//depot/test-mercurial-import/a#2 - opened for edit
+//depot/test-mercurial-import/b/c#2 - opened for edit
+Submitting change 4.
+Locking 2 files ...
+edit //depot/test-mercurial-import/a#3
+edit //depot/test-mercurial-import/b/c#3
+Change 4 submitted.
+% convert again
+reading p4 views
+collecting p4 changelists
+1 initial
+2 change a
+3 change b/c
+4 change a b/c
+scanning source...
+sorting...
+converting...
+0 change a b/c
+updating tags
+rev=5 desc="update tags" tags="tip" files=".hgtags"
+rev=4 desc="change a b/c" tags="P4 4" files="a b/c"
+rev=3 desc="update tags" tags="" files=".hgtags"
+rev=2 desc="change b/c" tags="" files="b/c"
+rev=1 desc="change a" tags="" files="a"
+rev=0 desc="initial" tags="" files="a b/c"
+% stop the p4 server


More information about the Mercurial-devel mailing list