| 1 | package VCS::Rcs; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use vars qw($VERSION $LOG_CMD %LOG_CACHE); | ||
| 5 | use VCS::Rcs::Dir; | ||
| 6 | use VCS::Rcs::File; | ||
| 7 | use VCS::Rcs::Version; | ||
| 8 | use IPC::Open2; | ||
| 9 | |||
| 10 | $VERSION = '0.06'; | ||
| 11 | |||
| 12 | $LOG_CMD = "rlog"; | ||
| 13 | |||
| 14 | sub _boiler_plate_info { | ||
| 15 | my ($self, $what) = @_; | ||
| 16 | my ($header, $log) = $self->_split_log($self->{VERSION}); | ||
| 17 | my $rev_info = $self->_parse_log_rev($log); | ||
| 18 | $rev_info->{$what}; | ||
| 19 | } | ||
| 20 | |||
| 21 | sub _split_log { | ||
| 22 | my ($self, $version) = @_; | ||
| 23 | my $log_text; | ||
| 24 | my $cache_id = $self->url; | ||
| 25 | unless (defined($log_text = $LOG_CACHE{$cache_id})) { | ||
| 26 | my @cmd = ($LOG_CMD, (defined $version ? "-r$version" : ()), $self->path); | ||
| 27 | open2 my $fh, undef, @cmd; | ||
| 28 | $LOG_CACHE{$cache_id} = $log_text = join '', <$fh>; | ||
| 29 | } | ||
| 30 | my @sections = split /\n[=\-]+\n/, $log_text; | ||
| 31 | @sections = ($sections[0], grep {/^revision $version(\n|\s)/} @sections) if $version; | ||
| 32 | #map { print "SEC: $_\n" } @sections; | ||
| 33 | die "Failed to parse log info from '$log_text'\n" unless @sections; | ||
| 34 | @sections; | ||
| 35 | } | ||
| 36 | |||
| 37 | sub _parse_log_rev { | ||
| 38 | my ($self, $text) = @_; | ||
| 39 | my ($rev_line, $blurb, @reason) = split /\n/, $text; | ||
| 40 | my %info = map { | ||
| 41 | split /:\s+/ | ||
| 42 | } split /;\s*/, $blurb; | ||
| 43 | my ($junk, $rev) = split /\s+/, $rev_line; | ||
| 44 | $info{'revision'} = $rev; | ||
| 45 | $info{'reason'} = \@reason; | ||
| 46 | #print "REASON: @reason\n"; | ||
| 47 | #map { print "$_ => $info{$_}\n" } keys %info; | ||
| 48 | \%info; | ||
| 49 | } | ||
| 50 | |||
| 51 | sub _parse_log_header { | ||
| 52 | my ($self, $text) = @_; | ||
| 53 | $text =~ s#(description:.*)##s; | ||
| 54 | my $desc = join "\n ", split /\n/, $1; | ||
| 55 | $text .= $desc; | ||
| 56 | my @parts = $text =~ /^(\S.*?)(?=^\S|\Z)/gms; | ||
| 57 | chomp @parts; | ||
| 58 | #map { print "PART: $_\n" } @parts; | ||
| 59 | my %info = map { | ||
| 60 | split /:\s*/, $_, 2 | ||
| 61 | } @parts; | ||
| 62 | #map { print "$_ => $info{$_}\n" } keys %info; | ||
| 63 | \%info; | ||
| 64 | } | ||
| 65 | |||
| 66 | 1; | ||
| 67 | |||
| 68 | =head1 NAME | ||
| 69 | |||
| 70 | VCS::Rcs - notes for the rcs implementation | ||
| 71 | |||
| 72 | =head1 SYNOPSIS | ||
| 73 | |||
| 74 | use VCS; | ||
| 75 | $file = VCS::File->new('/source/rcsrepos/project/Makefile'); | ||
| 76 | |||
| 77 | =head1 DESCRIPTION | ||
| 78 | |||
| 79 | Currently, the user needs to ensure that their environment has the | ||
| 80 | B<rcs> toolset available, including B<rlog>, B<rcsdiff>, B<co>, et al. | ||
| 81 | On Unix like environments ensure that the C<$PATH> environment variable | ||
| 82 | has the appropriate directory listed. On Windows be sure that the C<%PATH%> | ||
| 83 | variable has the directory with B<rlog.exe> etc. in it. | ||
| 84 | |||
| 85 | =head1 AVAILABILITY | ||
| 86 | |||
| 87 | VCS::Rcs is currently part of the main VCS distribution. | ||
| 88 | |||
| 89 | =head1 COPYRIGHT | ||
| 90 | |||
| 91 | Copyright (c) 1998-2003 Leon Brocard & Greg McCarroll. All rights | ||
| 92 | reserved. This program is free software; you can redistribute it | ||
| 93 | and/or modify it under the same terms as Perl itself. | ||
| 94 | |||
| 95 | =head1 SEE ALSO | ||
| 96 | |||
| 97 | L<VCS>. | ||
| 98 | |||
| 99 | =cut |