use RcsLite; use Rcs; use TestUtil; sub readKnown { my( $file ) = @_; $rcs = RcsLite->new(); $rcs->process( $file ); print "Head = " . $rcs->head() . "\n"; print "Valid to = " . $rcs->validTo() . "\n"; print "Comment = \"" . $rcs->comment() . "\"\n"; print "Description = \"" . $rcs->description() . "\"\n"; for( my $i=$rcs->head(); $i>=$rcs->validTo(); $i-- ) { print "Version = $i\n"; print " Author = " . $rcs->author($i) . "\n"; print " Log = " . $rcs->log($i) . "\n"; print " Text = " . $rcs->delta($i) . "\n\n"; } for( my $i=$rcs->head(); $i>=$rcs->validTo(); $i-- ) { print "---\n Revision "; print $i; print "\n"; print $rcs->text($i); print "\n"; } #my $delta = RcsLite::_diffText( \$v3, \$v2 ); #print "Delta 3->2 = \n"; #print $delta; #print "\n"; } sub testCheckins { my( $count, $file, @vals ) = @_; unlink $file; unlink "$file,v"; print "\n\nTest $count\n"; my $rcs = Rcs::new( $file ); my $numRevs = $#vals + 1; for( my $i=0; $i<$numRevs; $i++ ) { $rcs->addRevision( $vals[$i], "comment " . $i, "JohnTalintyre" ); } my $rcsLite = RcsLite::new(); $rcsLite->process( "$file,v" ); TestUtil::check_equal( $rcsLite->head(), $numRevs, "Number of revisions should be the same" ); for( my $i=$numRevs; $i>0; $i-- ) { my $text = $rcsLite->text( $i ); TestUtil::check_equal( $text, $vals[$i-1], "Text should be same for revision $i" ); } } my $file1 = "c:/devel/rcs/data/d.txt"; # testCheckins( $file, ( "" ) ); This doesn't work testCheckins( 1, $file1, ( "a" ) ); testCheckins( 2, $file1, ( "a\n" ) ); testCheckins( 3, $file1, ( "a\n", "b\n" ) ); testCheckins( 4, $file1, ( "a\n", "b" ) ); #testCheckins( 5, $file1, ( "a\n", "a\n\n" ) ); # TODO: broken at present testCheckins( 6, $file1, ( "a\nb\n", "a\nc\n" ) ); testCheckins( 7, $file1, ( "one", "one\ntwo\n" ) ); #testCheckins( 8, $file1, ( "one\n", "one\ntwo\n" ) ); testCheckins( 9, $file1, ( "one\nthree\nfour\n", "one\ntwo\nthree\n" ) ); testCheckins( 10, $file1, ( "three\nfour\n", "one\ntwo\nthree\n" ) ); testCheckins( 11, $file1, ( "john.talintyre@drkw.com\n" ) ); #my $rcs = Rcs::new( "c:/devel/rcs/data/d.txt" ); #$rcs->addRevision( "one", "john comment", "JohnTalintyre" ); #readKnown( "$file1,v" ); #$rcs->addRevision( "one\ntwo\n", "john comment 2", "JohnTalintyre2" ); #readKnown( "$file1,v" );