| 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::WorkingFileOrDirectory; | ||||||||||||||||||||
| 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::WorkingFileOrDirectory - Something checked out with CVS. | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | A WorkingFileOrDirectory is the working version of something checked out of | ||||||||||||||||||||
| 22 | CVS. It implements a small amount of common functionality between files and | ||||||||||||||||||||
| 23 | directories. | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | The filename used to contruct the object may be relative or absolute, and is | ||||||||||||||||||||
| 26 | stored as such, so be careful if you changed the current directory. | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | There should be no need to create this object directly. Use WorkingFile and | ||||||||||||||||||||
| 29 | WorkingDirectory instead. | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | ############################################################################### | ||||||||||||||||||||
| 34 | # Class constants | ||||||||||||||||||||
| 35 | ############################################################################### | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 1 | ▶ | use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/WorkingFileOrDirectory.pm,v 1.6 2005/10/10 12:52:11 dissent Exp $ '; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | ############################################################################### | ||||||||||||||||||||
| 40 | # Class variables | ||||||||||||||||||||
| 41 | ############################################################################### | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | ############################################################################### | ||||||||||||||||||||
| 44 | # Private variables | ||||||||||||||||||||
| 45 | ############################################################################### | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | # $self->{Admin} Object of type VCS::LibCVS::Admin. Created by the | ||||||||||||||||||||
| 48 | # constructors in the subclasses. | ||||||||||||||||||||
| 49 | # | ||||||||||||||||||||
| 50 | # $self->{FileSpec} Path of $self in the local filesystem | ||||||||||||||||||||
| 51 | # Canonized with File::Spec. Relative or absolute. | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | ############################################################################### | ||||||||||||||||||||
| 54 | # Class routines | ||||||||||||||||||||
| 55 | ############################################################################### | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | =head1 CLASS ROUTINES | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | =head2 B<new()> | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | $working_thing = VCS::LibCVS::WorkingFileOrDirectory->new($filename) | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =over 4 | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | =item return type: VCS::LibCVS::WorkingFileOrDirectory | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =item argument 1 type: scalar string | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | The name of a file or directory which is under CVS control. | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =back | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | Creates a new WorkingFileOrDirectory. There's little good reason to call this | ||||||||||||||||||||
| 74 | constructor, instead you'll want to call the constructors of WorkingFile and | ||||||||||||||||||||
| 75 | WorkingDirectory, since they provide the fun routines. | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | The filename used to contruct the object may be relative or absolute, and is | ||||||||||||||||||||
| 78 | stored as such. | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 83 | 1 | my $class = shift; | |||||||||||||||||||
| 84 | 1 | my $that = bless {}, $class; | |||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | # Clean up the path | ||||||||||||||||||||
| 87 | 1 | $that->{FileSpec} = File::Spec->canonpath(shift); | |||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 1 | return $that; | |||||||||||||||||||
| 90 | } | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | ############################################################################### | ||||||||||||||||||||
| 93 | # Instance routines | ||||||||||||||||||||
| 94 | ############################################################################### | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | =head1 INSTANCE ROUTINES | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | =head2 B<get_name()> | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | $name = $r_obj->get_name({abs => 1}) | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | =over 4 | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =item return type: scalar string | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =item argument 1 type: hash ref of options | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | All options default to false. | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | $opts->{abs} False: Don't return absolute filename | ||||||||||||||||||||
| 111 | $opts->{no_dir} False: Include directory names | ||||||||||||||||||||
| 112 | $opts->{no_base} False: Include the filename within the directory | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | =back | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | Returns the filename of the object with the repository, formatted according to | ||||||||||||||||||||
| 117 | the options. | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | 1 | ▶ | sub get_name { | ||||||||||||||||||
|
Subroutine
get_name: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||
| 122 | 1 | my $self = shift; | |||||||||||||||||||
| 123 | 1 | ▶ | my $opts = shift || {}; | ||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | 1 | my $path = $self->{FileSpec}; | |||||||||||||||||||
| 126 | 1 | ▶ | $path = File::Spec->rel2abs($path) if ($opts->{abs}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | 1 | my ($vol, $dir, $base) = File::Spec->splitpath($path); | |||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 1 | ▶ | return $base if ($opts->{no_dir}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | 1 | ▶ | $path = File::Spec->catpath($vol, $dir, $opts->{no_base} ? "" : "$base"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 133 | # If there's no $dir, then it's the current dir, so return that | ||||||||||||||||||||
| 134 | 1 | ▶ | $path ||= File::Spec->curdir(); | ||||||||||||||||||
|
Condition33%1/3
$path ||= "File::Spec"->curdir
MC/DC0%0/2
$path ||= "File::Spec"->curdir
$path
"File::Spec"->curdir
Truth table33%1/3
A ||= B
A= $pathB= "File::Spec"->curdir
| |||||||||||||||||||||
| 135 | 1 | return File::Spec->canonpath($path); | |||||||||||||||||||
| 136 | } | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | =head2 B<get_repository()> | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | $rep = $l_obj->get_repository() | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | =over 4 | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | =item return type: VCS::LibCVS::Repository | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | Returns the repository in which this managed object lives. | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | =back | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | It reads the CVS sandbox administrative directory to get this info. | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | =cut | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | 0 | ▶ | sub get_repository { | ||||||||||||||||||
|
Subroutine
get_repository: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 155 | 0 | my $self = shift; | |||||||||||||||||||
| 156 | 0 | return VCS::LibCVS::Repository->new($self->{Admin}->get_Root()); | |||||||||||||||||||
| 157 | } | ||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | =head2 B<get_remote_object()> | ||||||||||||||||||||
| 160 | |||||||||||||||||||||
| 161 | $r_obj = $l_obj->get_remote_object() | ||||||||||||||||||||
| 162 | |||||||||||||||||||||
| 163 | =over 4 | ||||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | =item return type: VCS::LibCVS::ManagedObject | ||||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | Returns the remote object associated with this local object. | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | =back | ||||||||||||||||||||
| 170 | |||||||||||||||||||||
| 171 | It reads the CVS sandbox administrative directory to get this info. | ||||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | 0 | ▶ | sub get_remote_object { | ||||||||||||||||||
|
Subroutine
get_remote_object: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 176 | 0 | confess "Should be implemented in subclass."; | |||||||||||||||||||
| 177 | } | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | =head2 B<get_branch()> | ||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | $branch = $l_obj->get_branch() | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | =over 4 | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | =item return type: VCS::LibCVS::Branch | ||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | Returns the branch this local object is on. | ||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | =back | ||||||||||||||||||||
| 190 | |||||||||||||||||||||
| 191 | If there is no sticky branch tag, it returns the MAIN branch. | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | =cut | ||||||||||||||||||||
| 194 | |||||||||||||||||||||
| 195 | 0 | ▶ | sub get_branch { | ||||||||||||||||||
|
Subroutine
get_branch: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 196 | 0 | confess "Not Implemented"; | |||||||||||||||||||
| 197 | } | ||||||||||||||||||||
| 198 | |||||||||||||||||||||
| 199 | ############################################################################### | ||||||||||||||||||||
| 200 | # Private routines | ||||||||||||||||||||
| 201 | ############################################################################### | ||||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | =head1 SEE ALSO | ||||||||||||||||||||
| 204 | |||||||||||||||||||||
| 205 | VCS::LibCVS | ||||||||||||||||||||
| 206 | |||||||||||||||||||||
| 207 | =cut | ||||||||||||||||||||
| 208 | |||||||||||||||||||||
| 209 | 1 | 1; | |||||||||||||||||||