| 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::RepositoryDirectory; | ||||||||||||
| 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::RepositoryDirectory - A Directory in the repository. | ||||||||||||
| 16 | |||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||
| 18 | |||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||
| 20 | |||||||||||||
| 21 | Represents a directory 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/RepositoryDirectory.pm,v 1.10 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 | ############################################################################### | ||||||||||||
| 47 | # Class routines | ||||||||||||
| 48 | ############################################################################### | ||||||||||||
| 49 | |||||||||||||
| 50 | ############################################################################### | ||||||||||||
| 51 | # Instance routines | ||||||||||||
| 52 | ############################################################################### | ||||||||||||
| 53 | |||||||||||||
| 54 | =head1 INSTANCE ROUTINES | ||||||||||||
| 55 | |||||||||||||
| 56 | =head2 B<get_files()> | ||||||||||||
| 57 | |||||||||||||
| 58 | @r_files = $r_dir->get_files({ Recursive => 0 }) | ||||||||||||
| 59 | |||||||||||||
| 60 | =over 4 | ||||||||||||
| 61 | |||||||||||||
| 62 | =item argument 1 type: hash ref to options | ||||||||||||
| 63 | |||||||||||||
| 64 | =item return type: list of VCS::LibCVS::RepositoryFile | ||||||||||||
| 65 | |||||||||||||
| 66 | =back | ||||||||||||
| 67 | |||||||||||||
| 68 | Return a complete list of CVS files, regardless of which branches they are on, | ||||||||||||
| 69 | and whether they are alive or dead. The Recursive option may be set, to return | ||||||||||||
| 70 | all files in all subdirectories also, or the default which is to return only | ||||||||||||
| 71 | files in this directory. | ||||||||||||
| 72 | |||||||||||||
| 73 | Available options are: "Recursive". | ||||||||||||
| 74 | |||||||||||||
| 75 | =cut | ||||||||||||
| 76 | |||||||||||||
| 77 | 0 | ▶ | sub get_files { | ||||||||||
|
Subroutine
get_files: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||
| 79 | 0 | ▶ | my $options = shift || {}; | ||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 80 | |||||||||||||
| 81 | # For recursive mode, the rlog command is used to fetch the list of files. | ||||||||||||
| 82 | # log isn't appropriate for this because log requires each directory to be | ||||||||||||
| 83 | # reported as a working directory. For non-recursive mode, the log command | ||||||||||||
| 84 | # is used. It's better than rlog for this because some older versions (at | ||||||||||||
| 85 | # least 1.11.1p1) of log don't respect the "-l" option. In both cases the | ||||||||||||
| 86 | # "-R" option is used to output just the names of the RCS files, since that's | ||||||||||||
| 87 | # all that's needed. | ||||||||||||
| 88 | |||||||||||||
| 89 | 0 | ▶ | my $command_name = ($options->{Recursive}) ? "rlog" : "log"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 90 | 0 | my $command = VCS::LibCVS::Command->new({}, $command_name, ["-R"], [$self]); | |||||||||||
| 91 | 0 | $command->issue($self->get_repository()); | |||||||||||
| 92 | |||||||||||||
| 93 | # The filenames are returned as messages, containing absolute paths to the | ||||||||||||
| 94 | # RCS files on the cvs server machine. They are cleaned up by making them | ||||||||||||
| 95 | # relative to the repository root directory, removing the ",v", and the | ||||||||||||
| 96 | # optional Attic. Then a RepositoryFile object is created for each one. | ||||||||||||
| 97 | |||||||||||||
| 98 | 0 | my $repo_root = $self->get_repository()->get_root()->get_dir(); | |||||||||||
| 99 | my @files = map { | ||||||||||||
| 100 | 0 | $_ =~ s#^$repo_root/(.*?)(Attic/)?([^/]*)?,v#$1$3#; | |||||||||||
| 101 | 0 | VCS::LibCVS::RepositoryFile->new($self->{Repository}, $_); | |||||||||||
| 102 | } $command->get_messages(",v\$"); | ||||||||||||
| 103 | |||||||||||||
| 104 | 0 | return \@files; | |||||||||||
| 105 | } | ||||||||||||
| 106 | |||||||||||||
| 107 | =head2 B<get_file()> | ||||||||||||
| 108 | |||||||||||||
| 109 | $r_file = $r_dir->get_file($name) | ||||||||||||
| 110 | |||||||||||||
| 111 | =over 4 | ||||||||||||
| 112 | |||||||||||||
| 113 | =item argument 1 type: scalar string, the name of the file. | ||||||||||||
| 114 | |||||||||||||
| 115 | =item return type: VCS::LibCVS::RepositoryFile | ||||||||||||
| 116 | |||||||||||||
| 117 | =back | ||||||||||||
| 118 | |||||||||||||
| 119 | Return a single named repository file, which is in this directory. If there's | ||||||||||||
| 120 | no such file in this directory, an exception is thrown. | ||||||||||||
| 121 | |||||||||||||
| 122 | =cut | ||||||||||||
| 123 | |||||||||||||
| 124 | 0 | ▶ | sub get_file { | ||||||||||
|
Subroutine
get_file: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 125 | 0 | my $self = shift; | |||||||||||
| 126 | 0 | my $name = $self->get_name() . "/" . shift; | |||||||||||
| 127 | |||||||||||||
| 128 | 0 | return VCS::LibCVS::RepositoryFile->new($self->{Repository}, $name); | |||||||||||
| 129 | } | ||||||||||||
| 130 | |||||||||||||
| 131 | =head2 B<get_directories()> | ||||||||||||
| 132 | |||||||||||||
| 133 | @r_files = $r_dir->get_directories() | ||||||||||||
| 134 | |||||||||||||
| 135 | =over 4 | ||||||||||||
| 136 | |||||||||||||
| 137 | =item return type: list of VCS::LibCVS::RepositoryDirectory | ||||||||||||
| 138 | |||||||||||||
| 139 | =back | ||||||||||||
| 140 | |||||||||||||
| 141 | =cut | ||||||||||||
| 142 | |||||||||||||
| 143 | 0 | ▶ | sub get_directories { | ||||||||||
|
Subroutine
get_directories: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 144 | 0 | confess "Not Implemented"; | |||||||||||
| 145 | } | ||||||||||||
| 146 | |||||||||||||
| 147 | ############################################################################### | ||||||||||||
| 148 | # Private routines | ||||||||||||
| 149 | ############################################################################### | ||||||||||||
| 150 | |||||||||||||
| 151 | # Directory names for reporting to the server. | ||||||||||||
| 152 | # Routine called in Command.pm, see there for more details. | ||||||||||||
| 153 | 0 | ▶ | sub _get_repo_dirs { | ||||||||||
|
Subroutine
_get_repo_dirs: not called CC=1 SCAR=6.9
| |||||||||||||
| 154 | 0 | my $self = shift; | |||||||||||
| 155 | # Use the repository dir as the working directory required by the protocol | ||||||||||||
| 156 | 0 | return [ $self->get_name({}), $self->get_name({abs => 1}) ]; | |||||||||||
| 157 | } | ||||||||||||
| 158 | |||||||||||||
| 159 | |||||||||||||
| 160 | =head1 SEE ALSO | ||||||||||||
| 161 | |||||||||||||
| 162 | VCS::LibCVS | ||||||||||||
| 163 | |||||||||||||
| 164 | =cut | ||||||||||||
| 165 | |||||||||||||
| 166 | 1 | 1; | |||||||||||