| 1 | # | ||
| 2 | # Copyright (c) 2005 Alexander Taler (dissent@0--0.org) | ||
| 3 | # | ||
| 4 | # All rights reserved. This program is free software; you can redistribute it | ||
| 5 | # and/or modify it under the same terms as Perl itself. | ||
| 6 | # | ||
| 7 | |||
| 8 | package VCS::LibCVS::Slice; | ||
| 9 | |||
| 10 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 1 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | VCS::LibCVS::Slice - A slice through a CVS Repository. | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | =head1 DESCRIPTION | ||
| 20 | |||
| 21 | A set of revisions in the repository, with at most one revision per file. | ||
| 22 | Common examples of slices are the revisions of all files in a directory | ||
| 23 | at a specific time, or all file revisions with a specific tag. | ||
| 24 | |||
| 25 | A slice is used to manipulate sets of revisions for operations such as | ||
| 26 | tagging and retrieving known configurations. | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | ############################################################################### | ||
| 31 | # Class constants | ||
| 32 | ############################################################################### | ||
| 33 | |||
| 34 | 1 | ▶ | use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Slice.pm,v 1.2 2005/09/10 02:20:31 dissent Exp $ '; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 35 | |||
| 36 | ############################################################################### | ||
| 37 | # Private variables | ||
| 38 | ############################################################################### | ||
| 39 | |||
| 40 | # $self->{Revisions} A hash ref containing the FileRevisions in this Slice | ||
| 41 | # Keys are the names of the files | ||
| 42 | # Values are FileRevision objects | ||
| 43 | |||
| 44 | ############################################################################### | ||
| 45 | # Class routines | ||
| 46 | ############################################################################### | ||
| 47 | |||
| 48 | 0 | ▶ | sub new { |
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 49 | 0 | my $class = shift; | |
| 50 | 0 | my $that = bless {}, $class; | |
| 51 | 0 | return $that; | |
| 52 | } | ||
| 53 | |||
| 54 | ############################################################################### | ||
| 55 | # Instance routines | ||
| 56 | ############################################################################### | ||
| 57 | |||
| 58 | =head1 INSTANCE ROUTINES | ||
| 59 | |||
| 60 | =head2 B<get_revision()> | ||
| 61 | |||
| 62 | $file_rev = $slice->get_revision($file) | ||
| 63 | |||
| 64 | =over 4 | ||
| 65 | |||
| 66 | =item argument 1 type: VCS::LibCVS::RepositoryFile | ||
| 67 | |||
| 68 | =item return type: VCS::LibCVS::FileRevision | ||
| 69 | |||
| 70 | =back | ||
| 71 | |||
| 72 | Returns the revision of the given file in this slice, or undef if there isn't | ||
| 73 | one. | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | 0 | ▶ | sub get_revision() { |
|
Subroutine
get_revision: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 78 | 0 | my $self = shift; | |
| 79 | 0 | my $file = shift; | |
| 80 | 0 | return $self->{Revisions}->{$file->get_name()}; | |
| 81 | } | ||
| 82 | |||
| 83 | =head2 B<get_revisions()> | ||
| 84 | |||
| 85 | @file_revs = $slice->get_revisions() | ||
| 86 | |||
| 87 | =over 4 | ||
| 88 | |||
| 89 | =item return type: ref to array of VCS::LibCVS::FileRevision | ||
| 90 | |||
| 91 | =back | ||
| 92 | |||
| 93 | Returns all the revisions in this slice, in a list. | ||
| 94 | |||
| 95 | =cut | ||
| 96 | |||
| 97 | 0 | ▶ | sub get_revisions() { |
|
Subroutine
get_revisions: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 98 | 0 | my $self = shift; | |
| 99 | 0 | my $file = shift; | |
| 100 | 0 | return values(%{$self->{Revisions}}); | |
| 101 | } | ||
| 102 | |||
| 103 | =head2 B<add_revision()> | ||
| 104 | |||
| 105 | $slice->add_revision($file_rev) | ||
| 106 | |||
| 107 | =over 4 | ||
| 108 | |||
| 109 | =item argument 1 type: VCS::LibCVS::FileRevision | ||
| 110 | |||
| 111 | =item return type: void | ||
| 112 | |||
| 113 | =back | ||
| 114 | |||
| 115 | Adds the provided FileRevision to the slice. If the file already has a | ||
| 116 | revision in this slice, it is overwritten. | ||
| 117 | |||
| 118 | =cut | ||
| 119 | |||
| 120 | 0 | ▶ | sub add_revision() { |
|
Subroutine
add_revision: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 121 | 0 | my $self = shift; | |
| 122 | 0 | my $file_rev = shift; | |
| 123 | 0 | $self->{Revisions}->{$file_rev->get_file()->get_name()} = $file_rev; | |
| 124 | } | ||
| 125 | |||
| 126 | =head2 B<tag()> | ||
| 127 | |||
| 128 | $slice->tag($tag_name) | ||
| 129 | |||
| 130 | =over 4 | ||
| 131 | |||
| 132 | =item argument 1 type: string | ||
| 133 | |||
| 134 | =item return type: void | ||
| 135 | |||
| 136 | =back | ||
| 137 | |||
| 138 | Tag the revisions in this slice with the given tag_name. If you want to create | ||
| 139 | a branch at these revisions, use branch() instead. | ||
| 140 | |||
| 141 | =cut | ||
| 142 | |||
| 143 | 0 | ▶ | sub tag() { |
|
Subroutine
tag: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 144 | 0 | my $self = shift; | |
| 145 | 0 | my $tag_name = shift; | |
| 146 | 0 | my @file_revs = values %{$self->{Revisions}}; | |
| 147 | 0 | my $command = VCS::LibCVS::Command->new({}, "tag", ["$tag_name"], \@file_revs); | |
| 148 | 0 | $command->issue($file_revs[0]->get_file()->get_repository()); | |
| 149 | # issue() will throw an exception if there is an error. | ||
| 150 | } | ||
| 151 | |||
| 152 | ############################################################################### | ||
| 153 | # Private routines | ||
| 154 | ############################################################################### | ||
| 155 | |||
| 156 | |||
| 157 | =head1 SEE ALSO | ||
| 158 | |||
| 159 | VCS::LibCVS | ||
| 160 | |||
| 161 | =cut | ||
| 162 | |||
| 163 | 1 | 1; | |