| 1 | # | ||||||||||||||||||||||||||||
| 2 | # Copyright (c) 2003,2004,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::RepositoryFile; | ||||||||||||||||||||||||||||
| 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::RepositoryFile - A File in the CVS repository. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | Represents a file in the CVS repository. | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head1 SUPERCLASS | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | VCS::LibCVS::RepositoryFileOrDirectory | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =cut | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | ############################################################################### | ||||||||||||||||||||||||||||
| 30 | # Class constants | ||||||||||||||||||||||||||||
| 31 | ############################################################################### | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/RepositoryFile.pm,v 1.18 2005/10/10 12:52:11 dissent Exp $ '; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | use vars ('@ISA'); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | 1 | @ISA = ("VCS::LibCVS::RepositoryFileOrDirectory"); | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | ############################################################################### | ||||||||||||||||||||||||||||
| 39 | # Class variables | ||||||||||||||||||||||||||||
| 40 | ############################################################################### | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | ############################################################################### | ||||||||||||||||||||||||||||
| 43 | # Private variables | ||||||||||||||||||||||||||||
| 44 | ############################################################################### | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # $self->{Tags} A hash ref containing all the tags for this file | ||||||||||||||||||||||||||||
| 47 | # Keys are the names of tags as strings | ||||||||||||||||||||||||||||
| 48 | # Values are list refs: [ Datum::TagSpec, Datum::RevisionNumber ] | ||||||||||||||||||||||||||||
| 49 | # use _get_all_tags() to get at this | ||||||||||||||||||||||||||||
| 50 | # $self->{Logs} A hash ref containing all of the log messages for this file | ||||||||||||||||||||||||||||
| 51 | # Keys are revision numbers as strings | ||||||||||||||||||||||||||||
| 52 | # Values are Datum::LogMessage objects | ||||||||||||||||||||||||||||
| 53 | # use _get_log_messages() to get at this | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | ############################################################################### | ||||||||||||||||||||||||||||
| 56 | # Class routines | ||||||||||||||||||||||||||||
| 57 | ############################################################################### | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | my $that = $class->SUPER::new(@_); | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | my ($repo, $path) = @_; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | # Make sure that the file exists, by performing a repository action. If it | ||||||||||||||||||||||||||||
| 67 | # doesn't exist, remove it from the cache. | ||||||||||||||||||||||||||||
| 68 | 0 | eval { $that->_load_log_messages(); }; | |||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | delete $repo->{RepositoryFileOrDirectoryCache}->{$that->{FileSpec}}; | |||||||||||||||||||||||||||
| 71 | 0 | confess($@); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | return $that; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | ############################################################################### | ||||||||||||||||||||||||||||
| 79 | # Instance routines | ||||||||||||||||||||||||||||
| 80 | ############################################################################### | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head1 INSTANCE ROUTINES | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head2 B<get_tags()> | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | $files_tags = $cvs_file->get_tags() | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =over 4 | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =item return type: ref to list of scalar strings. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =back | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Returns a list of all the non-branch tags on the file. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub get_tags { | ||||||||||||||||||||||||||
|
Subroutine
get_tags: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 100 | 0 | my @ret_tags; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | foreach my $taginfo (values (%{$self->_get_all_tags()})) { | |||||||||||||||||||||||||||
| 103 | 0 | my ($tagspec, $revnum) = @{ $taginfo }; | |||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ($tagspec->get_type() eq VCS::LibCVS::Datum::TagSpec::TYPE_NONBRANCH) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | push(@ret_tags, $tagspec->get_name()); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | 0 | return \@ret_tags; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =head2 B<has_tag($name)> | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | if ($cvs_file->has_tag("foo_tag")) { . . . | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =over 4 | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =item return type: scalar boolean | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =back | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Returns true if the file has a non-branch tag by that name. | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =cut | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub has_tag { | ||||||||||||||||||||||||||
|
Subroutine
has_tag: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 126 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 127 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | my $taginfo = $self->_get_all_tags()->{$name}; | |||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ($taginfo) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 0 | my ($tagspec, $revnum) = @{ $taginfo }; | |||||||||||||||||||||||||||
| 132 | 0 | return ($tagspec->get_type() eq VCS::LibCVS::Datum::TagSpec::TYPE_NONBRANCH); | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 0 | return; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head2 B<get_branches()> | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | $files_branches = $cvs_file->get_branches() | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =over 4 | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =item return type: ref to list of VCS::LibCVS::FileBranch | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =back | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | Returns a list of all the named branches of the file. | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | This includes the revision 1 trunk, with the name .TRUNK, but does not include | ||||||||||||||||||||||||||||
| 150 | any other unnamed branches. | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =cut | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub get_branches { | ||||||||||||||||||||||||||
|
Subroutine
get_branches: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 155 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 156 | 0 | my @ret_branches; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | foreach my $taginfo (values (%{$self->_get_all_tags()})) { | |||||||||||||||||||||||||||
| 159 | 0 | my $b = $self->_make_FileBranch($taginfo); | |||||||||||||||||||||||||||
| 160 | 0 | ▶ | push(@ret_branches, $b) if ($b); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | # Put the trunk into the list | ||||||||||||||||||||||||||||
| 163 | 0 | push(@ret_branches, $self->_make_FileBranch_Trunk()); | |||||||||||||||||||||||||||
| 164 | 0 | return \@ret_branches; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =head2 B<get_branch($name_or_rev_or_branch)> | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | $files_branch = $cvs_file->get_branch("branch_1_1_4_stabilization") | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | =over 4 | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =item argument 1 type: scalar or VCS::LibCVS::Datum::RevisionNumber or VCS::LibCVS::Branch | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | =item return type: object of type VCS::LibCVS::FileBranch | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =back | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | Return the specified branch, or undef if there is no such branch. The branch | ||||||||||||||||||||||||||||
| 180 | can be specified by a name, a branch revision number, or a Branch. | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | =cut | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub get_branch { | ||||||||||||||||||||||||||
|
Subroutine
get_branch: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 186 | 0 | my $arg = shift; | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if (! ref $arg) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if ($arg eq ".TRUNK") { return $self->_make_FileBranch_Trunk(); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | my $taginfo = $self->_get_all_tags()->{$arg}; | |||||||||||||||||||||||||||
| 191 | 0 | ▶ | return $self->_make_FileBranch($taginfo) if $taginfo; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | } elsif ($arg->isa("VCS::LibCVS::Branch")) { | ||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ($arg->get_name() eq ".TRUNK") { return $self->_make_FileBranch_Trunk(); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | my $taginfo = $self->_get_all_tags()->{$arg->get_name()}; | |||||||||||||||||||||||||||
| 196 | 0 | ▶ | return $self->_make_FileBranch($taginfo) if $taginfo; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | } elsif ($arg->isa("VCS::LibCVS::Datum::RevisionNumber")) { | ||||||||||||||||||||||||||||
| 199 | 0 | my $rev = $arg; | |||||||||||||||||||||||||||
| 200 | 0 | ▶ | if (! $rev->is_branch()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | 0 | confess "Not a branch revision: " . $rev->as_string(); | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if ($rev->is_trunk()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | 0 | return $self->_make_FileBranch_Trunk($rev); | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | 0 | foreach my $taginfo (values (%{$self->_get_all_tags()})) { | |||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ($taginfo->[1]->equals($rev)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 0 | return $self->_make_FileBranch($taginfo); | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | } else { | ||||||||||||||||||||||||||||
| 212 | 0 | confess "get_branch() doesn't support objects of type " . ref $arg; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | return; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | =head2 B<get_revision()> | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | $files_rev = $cvs_file->get_revision($tag_or_revision) | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | =over 4 | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | =item argument 1 type: scalar string | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | =item return type: VCS::LibCVS::FileRevision | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | =back | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | Returns the revision of the file specified by the named tag or revision number, | ||||||||||||||||||||||||||||
| 231 | or raises an error if there is no such tag or revision. | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | The BASE tag is not supported, since this is a repository object with no | ||||||||||||||||||||||||||||
| 234 | knowledge of the working directory. The WorkingFile object will provide the | ||||||||||||||||||||||||||||
| 235 | necessary information. | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | =cut | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub get_revision { | ||||||||||||||||||||||||||
|
Subroutine
get_revision: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 240 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 241 | 0 | my $tag_or_rev = shift; | |||||||||||||||||||||||||||
| 242 | 0 | my $rev; | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | my $taginfo = $self->_get_all_tags()->{$tag_or_rev}; | |||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ($taginfo && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$taginfo and $taginfo->[0]->get_type eq "N"
MC/DC0%0/2
$taginfo and $taginfo->[0]->get_type eq "N"
$taginfo
$taginfo->[0]->get_type eq "N"
Truth table0%0/3
A and B
A= $taginfoB= $taginfo->[0]->get_type eq "N"
| |||||||||||||||||||||||||||||
| 246 | $taginfo->[0]->get_type() eq VCS::LibCVS::Datum::TagSpec::TYPE_NONBRANCH) { | ||||||||||||||||||||||||||||
| 247 | 0 | $rev = $taginfo->[1]; | |||||||||||||||||||||||||||
| 248 | } else { | ||||||||||||||||||||||||||||
| 249 | 0 | $rev = VCS::LibCVS::Datum::RevisionNumber->new($tag_or_rev); | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | return VCS::LibCVS::FileRevision->new($self, $rev); | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | ############################################################################### | ||||||||||||||||||||||||||||
| 256 | # Private routines | ||||||||||||||||||||||||||||
| 257 | ############################################################################### | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | # get the tag info from private variables | ||||||||||||||||||||||||||||
| 260 | # use this function instead of direct access to make it easier to add caching | ||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub _get_all_tags { | ||||||||||||||||||||||||||
|
Subroutine
_get_all_tags: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 262 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | $self->_load_tags(); | |||||||||||||||||||||||||||
| 265 | 0 | return $self->{Tags}; | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | # loads the tag info into the private variable Tags | ||||||||||||||||||||||||||||
| 269 | 0 | ▶ | sub _load_tags { | ||||||||||||||||||||||||||
|
Subroutine
_load_tags: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 270 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 0 | my $loginfo = $self->_get_loginfo_from_server({NoLog => 1}); | |||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | # The tag info is returned in this format: | ||||||||||||||||||||||||||||
| 275 | # | ||||||||||||||||||||||||||||
| 276 | # symbolic names: | ||||||||||||||||||||||||||||
| 277 | # REGULAR_TAG: 1.2.2.1 | ||||||||||||||||||||||||||||
| 278 | # foo_branch: 1.2.0.2 | ||||||||||||||||||||||||||||
| 279 | # | ||||||||||||||||||||||||||||
| 280 | # So it is processed by traversing the responses until we hit the string | ||||||||||||||||||||||||||||
| 281 | # "symbolic names:", after which we read them as tags. | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | # In addition, the head revision is found elsewhere in a line of this format: | ||||||||||||||||||||||||||||
| 284 | # head: 1.2 | ||||||||||||||||||||||||||||
| 285 | # It is used to put the HEAD tag in. | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | my %tags; | |||||||||||||||||||||||||||
| 288 | 0 | my $in_tags = 0; # true after the "symbolic names:" message | |||||||||||||||||||||||||||
| 289 | 0 | foreach my $line (@$loginfo) { | |||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ($in_tags) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 291 | # check if the line specifies a tag | ||||||||||||||||||||||||||||
| 292 | # if it doesn't, then there are no more | ||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ($line !~ /^\s+(.*): ([0-9.]*)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | 0 | last; | |||||||||||||||||||||||||||
| 295 | } else { | ||||||||||||||||||||||||||||
| 296 | 0 | my ($tag_string, $rev_string) = ($1, $2); | |||||||||||||||||||||||||||
| 297 | 0 | my $rev = VCS::LibCVS::Datum::RevisionNumber->new($rev_string); | |||||||||||||||||||||||||||
| 298 | 0 | ▶ | my $tagspec = VCS::LibCVS::Datum::TagSpec-> | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | new(($rev->is_branch() ? "T" : "N") . $tag_string); | ||||||||||||||||||||||||||||
| 300 | 0 | $tags{$tag_string} = [ $tagspec, $rev ]; | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | } elsif ($line eq "symbolic names:") { | ||||||||||||||||||||||||||||
| 303 | 0 | $in_tags = 1; | |||||||||||||||||||||||||||
| 304 | } elsif ($line =~ /head: ([0-9.]*)/) { | ||||||||||||||||||||||||||||
| 305 | 0 | my $rev = VCS::LibCVS::Datum::RevisionNumber->new($1); | |||||||||||||||||||||||||||
| 306 | 0 | my $tagspec = VCS::LibCVS::Datum::TagSpec->new("NHEAD"); | |||||||||||||||||||||||||||
| 307 | 0 | $tags{"HEAD"} = [ $tagspec, $rev ]; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | 0 | $self->{Tags} = \%tags; | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | # make a FileBranch from a $self->{Tags} entry. Return undef if it's not a | ||||||||||||||||||||||||||||
| 314 | # BRANCH tag. | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 0 | ▶ | sub _make_FileBranch { | ||||||||||||||||||||||||||
|
Subroutine
_make_FileBranch: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 317 | 0 | my ($self, $tags_entry) = @_; | |||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | 0 | my ($tagspec, $revnum) = @{ $tags_entry }; | |||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ($tagspec->get_type() eq VCS::LibCVS::Datum::TagSpec::TYPE_BRANCH) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 322 | 0 | return VCS::LibCVS::FileBranch->new($self, $tagspec, $revnum); | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | 0 | return; | |||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | # make a FileBranch object for the trunk. | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | ▶ | sub _make_FileBranch_Trunk { | ||||||||||||||||||||||||||
|
Subroutine
_make_FileBranch_Trunk: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 330 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 331 | 0 | ▶ | my $rev = shift || VCS::LibCVS::Datum::RevisionNumber->new("1"); | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || 'VCS::LibCVS::Datum::RevisionNumber'->new('1')
MC/DC0%0/2
shift() || 'VCS::LibCVS::Datum::RevisionNumber'->new('1')
shift()
'VCS::LibCVS::Datum::RevisionNumber'->new('1')
Truth table0%0/3
A || B
A= shift()B= 'VCS::LibCVS::Datum::RevisionNumber'->new('1')
| |||||||||||||||||||||||||||||
| 332 | 0 | my $tagspec = VCS::LibCVS::Datum::TagSpec->new("T.TRUNK"); | |||||||||||||||||||||||||||
| 333 | 0 | return VCS::LibCVS::FileBranch->new($self, $tagspec, $rev); | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | # get the log messages from private variables | ||||||||||||||||||||||||||||
| 337 | # use this function instead of direct access to make it easier to add caching | ||||||||||||||||||||||||||||
| 338 | 0 | ▶ | sub _get_log_messages { | ||||||||||||||||||||||||||
|
Subroutine
_get_log_messages: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 339 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 0 | $self->_load_log_messages(); | |||||||||||||||||||||||||||
| 342 | 0 | return $self->{Logs}; | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | # loads the log messages into the private variable Logs | ||||||||||||||||||||||||||||
| 346 | 0 | ▶ | sub _load_log_messages { | ||||||||||||||||||||||||||
|
Subroutine
_load_log_messages: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||
| 347 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 0 | my $loginfo = $self->_get_loginfo_from_server({NoTag => 1}); | |||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | # The log messages are returned in this format: | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | # <header stuff> | ||||||||||||||||||||||||||||
| 354 | # description: | ||||||||||||||||||||||||||||
| 355 | # ---------------------------- | ||||||||||||||||||||||||||||
| 356 | # revision 1.2 | ||||||||||||||||||||||||||||
| 357 | # date: 2002/11/13 02:29:46; author: dissent; state: Exp; lines: +1 -0 | ||||||||||||||||||||||||||||
| 358 | # branches: 1.2.2; | ||||||||||||||||||||||||||||
| 359 | # logmessage | ||||||||||||||||||||||||||||
| 360 | # ---------------------------- | ||||||||||||||||||||||||||||
| 361 | # revision 1.1 | ||||||||||||||||||||||||||||
| 362 | # date: 2002/11/13 02:29:33; author: dissent; state: Exp; | ||||||||||||||||||||||||||||
| 363 | # *** empty log message *** | ||||||||||||||||||||||||||||
| 364 | # ---------------------------- | ||||||||||||||||||||||||||||
| 365 | # revision 1.2.2.1 | ||||||||||||||||||||||||||||
| 366 | # date: 2003/01/11 16:39:04; author: dissent; state: Exp; lines: +1 -0 | ||||||||||||||||||||||||||||
| 367 | # mm | ||||||||||||||||||||||||||||
| 368 | # | ||||||||||||||||||||||||||||
| 369 | # So it is processed by traversing the responses until we hit the string | ||||||||||||||||||||||||||||
| 370 | # "description:", after which log messages are split by ------ lines | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 0 | ▶ | confess "Empty log, $self->{FileSpec} is a directory." if ( @$loginfo == 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | # Discard the header, everything up to and including the "description:" line | ||||||||||||||||||||||||||||
| 375 | 0 | ▶ | while ( @$loginfo ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 376 | # Validate that this loginfo is for the correct file. Generally this check | ||||||||||||||||||||||||||||
| 377 | # is not needed, but may be useful to help catch problems. There is one | ||||||||||||||||||||||||||||
| 378 | # case where it is needed, explained below [1]. | ||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if ($loginfo->[0] =~ /^Working file: (.*)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if ($1 ne $self->{FileSpec}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 381 | 0 | confess "Bad Working file in log, $self->{FileSpec} is a directory."; | |||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | 0 | ▶ | last if (shift @$loginfo) eq "description:"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | # the last line will be a bunch of ==, remove it now: | ||||||||||||||||||||||||||||
| 387 | 0 | my $last = pop @$loginfo; | |||||||||||||||||||||||||||
| 388 | 0 | ▶ | confess "Bad final log line: $last" unless $last =~ /={77}/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | # Collect all the log messages in a hash from revision to log message. | ||||||||||||||||||||||||||||
| 391 | 0 | my %logs; | |||||||||||||||||||||||||||
| 392 | 0 | my $log_entry_sep = qr/-{28}/; | |||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | # Collect the lines that make up a single log message into the | ||||||||||||||||||||||||||||
| 395 | # @log_mess_array, and use it to create a LogMessage. | ||||||||||||||||||||||||||||
| 396 | 0 | ▶ | while (@$loginfo) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | 0 | my $f_l = shift @$loginfo; | |||||||||||||||||||||||||||
| 398 | 0 | ▶ | confess "Bad log entry separator: $f_l" unless $f_l =~ $log_entry_sep; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 399 | 0 | my @log_mess_array; | |||||||||||||||||||||||||||
| 400 | 0 | ▶ | while (@$loginfo) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 401 | 0 | ▶ | last if (($loginfo->[0] =~ $log_entry_sep ) && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$loginfo->[0] =~ /$log_entry_sep/ and $loginfo->[1] =~ /^revision [0-9.]*/
MC/DC0%0/2
$loginfo->[0] =~ /$log_entry_sep/ and $loginfo->[1] =~ /^revision [0-9.]*/
$loginfo->[0] =~ /$log_entry_sep/
$loginfo->[1] =~ /^revision [0-9.]*/
Truth table0%0/3
A and B
A= $loginfo->[0] =~ /$log_entry_sep/B= $loginfo->[1] =~ /^revision [0-9.]*/
| |||||||||||||||||||||||||||||
| 402 | ($loginfo->[1] =~ /^revision [0-9.]*/ )); | ||||||||||||||||||||||||||||
| 403 | 0 | push (@log_mess_array, (shift @$loginfo)); | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | 0 | my $log_mess = VCS::LibCVS::Datum::LogMessage->new(\@log_mess_array); | |||||||||||||||||||||||||||
| 406 | 0 | $logs{$log_mess->get_revision()->as_string()} = $log_mess; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | 0 | $self->{Logs} = \%logs; | |||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | # get various bits of the log info. | ||||||||||||||||||||||||||||
| 412 | # may pass boolean options to select which bits to return: | ||||||||||||||||||||||||||||
| 413 | # $file->_get_loginfo_from_server({ NoTags => 1, NoLog => 0 }) | ||||||||||||||||||||||||||||
| 414 | # it returns the loginfo as a ref to an array of lines | ||||||||||||||||||||||||||||
| 415 | 0 | ▶ | sub _get_loginfo_from_server { | ||||||||||||||||||||||||||
|
Subroutine
_get_loginfo_from_server: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 416 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 417 | 0 | ▶ | my $options = shift || {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | # To turn off retrieving log info, ask only for revisions that precede 1.1 | ||||||||||||||||||||||||||||
| 420 | my $args = [ $options->{NoLog} ? "-r::1.1" : (), | ||||||||||||||||||||||||||||
| 421 | 0 | ▶ | $options->{NoTags} ? "-N" : () ]; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | 0 | my $command = VCS::LibCVS::Command->new({}, "log", $args, [$self]); | |||||||||||||||||||||||||||
| 424 | 0 | $command->issue($self->{Repository}); | |||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | # Return the responses as a list of lines | ||||||||||||||||||||||||||||
| 427 | 0 | return [ $command->get_messages() ]; | |||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | # Directory names for reporting to the server. | ||||||||||||||||||||||||||||
| 431 | # Routine called in Command.pm, see there for more details. | ||||||||||||||||||||||||||||
| 432 | 0 | ▶ | sub _get_repo_dirs { | ||||||||||||||||||||||||||
|
Subroutine
_get_repo_dirs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 433 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 434 | # Use the repository dir as the working directory required by the protocol | ||||||||||||||||||||||||||||
| 435 | 0 | my $l_dir = $self->get_name({no_base => 1}); | |||||||||||||||||||||||||||
| 436 | 0 | my $r_dir = $self->get_name({abs => 1, no_base => 1}); | |||||||||||||||||||||||||||
| 437 | 0 | return [ $l_dir, $r_dir ]; | |||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | VCS::LibCVS | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | =cut | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | 1 | 1; | |||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | ### Footnotes | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | # [1] The check _load_log_messages() that the log messages match the file is | ||||||||||||||||||||||||||||
| 451 | # used in the following circumstances. RepositoryFileOrDirectory->find() calls | ||||||||||||||||||||||||||||
| 452 | # the RepositoryFile constructor and if it fails concludes that the argument in | ||||||||||||||||||||||||||||
| 453 | # fact represents a directory. The constructor fails because | ||||||||||||||||||||||||||||
| 454 | # _load_log_messages() fails to retrieve any log messages for the directory. | ||||||||||||||||||||||||||||
| 455 | # No log messages are returned because no Directory request is submitted for | ||||||||||||||||||||||||||||
| 456 | # the subdirectory in the cvsclient protocol, only its parent. However, in the | ||||||||||||||||||||||||||||
| 457 | # case of the root directory of the repository, a Directory request _is_ | ||||||||||||||||||||||||||||
| 458 | # submitted, because this is always done in order not to break the protocol, | ||||||||||||||||||||||||||||
| 459 | # and so some log messages are returned. Without this check the constructor | ||||||||||||||||||||||||||||
| 460 | # would mistakenly conclude that "." is a file and not a directory. | ||||||||||||||||||||||||||||