#!/opt/perl5/bin/perl

# read a STDIN string containing a RCS based history

$VERSION = sprintf "%d.%03d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/;

use Tk ;
use ExtUtils::testlib;
use VcsTools::LogParser ;
use Getopt::Long ;
use Puppet::VcsTools::History ;
require Tk::ErrorDialog; 

use strict ;
my $type = 'rcs';
my %dummy ; # no permanent storage
use vars qw/$description/;

GetOptions ('type=s' => \$type)
  || die "GetOptions failed\n";

if ($type eq 'rcs')
  {
    print "Using VcsTools::DataSpec::Rcs\n";
    require VcsTools::DataSpec::Rcs ;
    import VcsTools::DataSpec::Rcs qw($description readHook);
  }
elsif ($type eq 'tnd')
  {
    print "Using VcsTools::DataSpec::HpTnd\n";
    require  VcsTools::DataSpec::HpTnd ;
    import VcsTools::DataSpec::HpTnd qw($description readHook);
  }

my $ds = new VcsTools::LogParser
  (
   description => $description,
   readHook => \&readHook
  ) ;

my $mw = MainWindow-> new ;
$mw -> withdraw ;

my $hist = new Puppet::VcsTools::History 
  (
   storageArgs =>
   {
    dbHash => \%dummy,
    keyRoot => 'R'
   },
   'topTk' => $mw,
   name => 'file',
#   how => 'warn',
   dataScanner => $ds
  );

my @history = <STDIN> ;

$hist -> update (history => \@history, time => 10 );
$hist -> display(master => 1);

MainLoop ; # Tk's

__END__

=head1 NAME

viewHistory - VCS history viewer

=head1 SYNOPSIS

 # a la RCS
 rlog foo.c | viewHistory 
  
 # or as I do it at my workplace
 fhist bar.c | viewHistory -type tnd

=head1 DESCRIPTION

Launch a Tk application to display a graph of the history of your VCS file.


=head1 AUTHOR

Dominique Dumont    Dominique_Dumont@grenoble.hp.com

Copyright (c) 1998-1999 Dominique Dumont. All rights reserved.  This
program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 SEE ALSO

perl(1), L<Puppet::VcsTools::History>

=cut
