VCS::LibCVS::Slice - A slice through a CVS Repository.


VCS-LibCVS documentation Contained in the VCS-LibCVS distribution.

Index


Code Index:

NAME

Top

VCS::LibCVS::Slice - A slice through a CVS Repository.

SYNOPSIS

Top

DESCRIPTION

Top

A set of revisions in the repository, with at most one revision per file. Common examples of slices are the revisions of all files in a directory at a specific time, or all file revisions with a specific tag.

A slice is used to manipulate sets of revisions for operations such as tagging and retrieving known configurations.

INSTANCE ROUTINES

Top

get_revision()

$file_rev = $slice->get_revision($file)

argument 1 type: VCS::LibCVS::RepositoryFile
return type: VCS::LibCVS::FileRevision

Returns the revision of the given file in this slice, or undef if there isn't one.

get_revisions()

@file_revs = $slice->get_revisions()

return type: ref to array of VCS::LibCVS::FileRevision

Returns all the revisions in this slice, in a list.

add_revision()

$slice->add_revision($file_rev)

argument 1 type: VCS::LibCVS::FileRevision
return type: void

Adds the provided FileRevision to the slice. If the file already has a revision in this slice, it is overwritten.

tag()

$slice->tag($tag_name)

argument 1 type: string
return type: void

Tag the revisions in this slice with the given tag_name. If you want to create a branch at these revisions, use branch() instead.

SEE ALSO

Top

  VCS::LibCVS


VCS-LibCVS documentation Contained in the VCS-LibCVS distribution.
#
# Copyright (c) 2005 Alexander Taler (dissent@0--0.org)
#
# All rights reserved. This program is free software; you can redistribute it
# and/or modify it under the same terms as Perl itself.
#

package VCS::LibCVS::Slice;

use strict;
use Carp;

###############################################################################
# Class constants
###############################################################################

use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Slice.pm,v 1.2 2005/09/10 02:20:31 dissent Exp $ ';

###############################################################################
# Private variables
###############################################################################

# $self->{Revisions}  A hash ref containing the FileRevisions in this Slice
#                     Keys are the names of the files
#                     Values are FileRevision objects

###############################################################################
# Class routines
###############################################################################

sub new {
  my $class = shift;
  my $that = bless {}, $class;
  return $that;
}

###############################################################################
# Instance routines
###############################################################################

sub get_revision() {
  my $self = shift;
  my $file = shift;
  return $self->{Revisions}->{$file->get_name()};
}

sub get_revisions() {
  my $self = shift;
  my $file = shift;
  return values(%{$self->{Revisions}});
}

sub add_revision() {
  my $self = shift;
  my $file_rev = shift;
  $self->{Revisions}->{$file_rev->get_file()->get_name()} = $file_rev;
}

sub tag() {
  my $self = shift;
  my $tag_name = shift;
  my @file_revs = values %{$self->{Revisions}};
  my $command = VCS::LibCVS::Command->new({}, "tag", ["$tag_name"], \@file_revs);
  $command->issue($file_revs[0]->get_file()->get_repository());
  # issue() will throw an exception if there is an error.
}

###############################################################################
# Private routines
###############################################################################


1;