Apache::CVS::Diff - class that implements a CVS diff


Apache-CVS documentation Contained in the Apache-CVS distribution.

Index


Code Index:

NAME

Top

Apache::CVS::Diff - class that implements a CVS diff

SYNOPSIS

Top

 use Apache::CVS::File();
 use Apache::CVS::Diff();

 $diff = Apache::CVS::Diff->new($source, $target, $style);
 @content = @{ $diff->content() };

DESCRIPTION

Top

The Apache::CVS::Diff class implements a CVS diff. What you would get with your plain 'ol cvs diff command.

$diff = Apache::CVS::Diff->new($source, $target, $styles)

Construct a new Apache::CVS::Diff object. The first two arguments should be instancesof Apache::CVS::Version. The third is the arguments to rcsdiff(1). The style defaults to 'ua'.

$revision = $diff->source()

Returns the source revision of this diff.

$revision = $diff->target()

Returns the target revision of this diff.

$diff->style()

Returns or set the style of the diff.

$diff->content()

Returns the contents of the diff as a references to an array of lines.

SEE ALSO

Top

Apache::CVS, Apache::CVS::File

AUTHOR

Top

John Barbee <barbee@veribox.net>

COPYRIGHT

Top


Apache-CVS documentation Contained in the Apache-CVS distribution.
# $Id: Diff.pm,v 1.2 2002/04/23 04:18:28 barbee Exp $

package Apache::CVS::Diff;

use strict;

$Apache::CVS::Diff::VERSION = $Apache::CVS::VERSION;;

sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my $self = {};

    $self->{source} = shift;
    $self->{target} = shift;
    $self->{style} = shift;
    $self->{default_style} = shift;
    $self->{content} = undef;

    bless ($self, $class);
    return $self;
}

sub source {
    my $self = shift;
    return $self->{source};
}

sub target {
    my $self = shift;
    return $self->{target};
}

sub load {
    my $self = shift;
    my @content;
    eval {
        @content =
            $self->source()->rcs()->rcsdiff('-' . $self->style() . ' -r' .
                                            $self->source()->number(), '-r' .
                                            $self->target()->number());
    };
    if ($@) {
        die 'Apache::CVS::Diff ' . $@;
    }
    $self->content(\@content);
}

sub style {
    my $self = shift;
    $self->{style} = shift if scalar @_;
    $self->{style} = 'ua' unless $self->{style};
    return $self->{style};
}

sub content {
    my $self = shift;
    $self->{content} = shift if scalar @_;
    $self->load() unless $self->{content};
    return $self->{content};
}

1;