blib/lib/VCS/LibCVS/WorkingUnmanagedFile.pm

filter: Statementstmt 38.8% 14 / 36 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 2 / 2 totaltotal 37.7% 20 / 53 CC 5 SCAR 26.6
CC
5
Cov
32%
new
30.0
is_in_the_way
2.0
_get_repo_dirs
2.0
CRAP 14.4
« blib/lib/VCS/LibCVS/Repository.pm ↑ Summary blib/lib/VCS/LibCVS/Client/Request.pm »
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::WorkingUnmanagedFile;
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::WorkingUnmanagedFile - A file which is not managed by CVS.
16  
17 =head1 SYNOPSIS
18  
19 =head1 DESCRIPTION
20  
21 This object represents a file not from CVS.
22  
23 =head1 SUPERCLASS
24  
25 VCS::LibCVS::WorkingFileOrDirectory
26  
27 =cut
28  
29 ###############################################################################
30 # Class constants
31 ###############################################################################
32  
33 1 ▶use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/WorkingUnmanagedFile.pm,v 1.9 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::WorkingFileOrDirectory");
37  
38 ###############################################################################
39 # Class variables
40 ###############################################################################
41  
42 ###############################################################################
43 # Private variables
44 ###############################################################################
45  
46 ###############################################################################
47 # Class routines
48 ###############################################################################
49  
50 =head1 CLASS ROUTINES
51  
52 =head2 B<new()>
53  
54 $unmanaged_file = VCS::LibCVS::WorkingUnmanagedFile->new($filename)
55  
56 =over 4
57  
58 =item return type: VCS::LibCVS::WorkingUnmanagedFile
59  
60 =item argument 1 type: scalar string
61  
62 The name of the file which is not under CVS control.
63  
64 =back
65  
66 Creates a new WorkingUnmanagedFile. The filename may be relative or absolute,
67 and is stored as such.
68  
69 It throws an exception if the file is recorded in the CVS/Entries file, or
70 should be ignored by CVS.
71  
72 =cut
73  
74 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
75 0 my $class = shift;
76 0 my $that = $class->SUPER::new(@_);
77 0 my $full_name = $that->get_name();
78  
79 # Check if the file is managed by CVS
80 0 $that->{Admin} = VCS::LibCVS::Admin->new($that->get_name({no_base => 1}));
81 0 my $ent = $that->{Admin}->get_Entries()->{$that->get_name({no_dir => 1})};
82 0 ▶ confess "$full_name is managed by CVS" if $ent;
Branch: 1 branch
BranchTrueFalseTotal
if $ent 0 0 0
83  
84 # Check if the file should be ignored by CVS
85 0 my $ignorer = $that->get_repository()->get_ignoreChecker();
86 0 ▶ confess "No such file $full_name" unless -f $full_name;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $full_name 0 0 0
87 0 ▶ confess "That's the admin dir" if $full_name eq $VCS::LibCVS::Admin_Dir_Name;
Branch: 1 branch
BranchTrueFalseTotal
if $full_name eq $VCS::LibCVS::Admin_Dir_Name 0 0 0
88 0 ▶ confess "$full_name is being ignored" if $ignorer->ignore_check($full_name);
Branch: 1 branch
BranchTrueFalseTotal
if $ignorer->ignore_check($full_name) 0 0 0
89  
90 0 return $that;
91 }
92  
93 ###############################################################################
94 # Instance routines
95 ###############################################################################
96  
97 =head1 INSTANCE ROUTINES
98  
99 =head2 B<is_in_the_way()>
100  
101 if ($u_file->is_in_the_way()) {
102  
103 =over 4
104  
105 =item return type: boolean scalar
106  
107 =back
108  
109 Returns true if there is a file or a directory in the repository with the same
110 name as this file. This file is in the way because it prevents the update from
111 the repository.
112  
113 An unusual case occurs if this file has the same contents as the one in the
114 repository. In this case, "cvs update" will add the local administrative
115 information and not report "in the way". This routine will still return true
116 in that case.
117  
118 =cut
119  
120 # Perhaps make it return an enumerated state. See bug #14189.
121  
122 0 ▶sub is_in_the_way {
Subroutine is_in_the_way: not called CC=1 SCAR=6.9
Pod documented
123 0 my $self = shift;
124  
125 # Issue an update command. If it returns "nothing known about", then the
126 # file is not in the way. In any other case it is in the way, either because
127 # a directory is there, or another file.
128 0 my $up_c = new VCS::LibCVS::Command({}, "update", ["-ld"], [$self]);
129 0 $up_c->issue($self->get_repository());
130 0 my @errors = $up_c->get_errors("nothing known about");
131 0 return !@errors;
132 }
133  
134 ###############################################################################
135 # Private routines
136 ###############################################################################
137  
138 =head1 SEE ALSO
139  
140 VCS::LibCVS
141  
142 =cut
143  
144 # Directory names for reporting to the server.
145 # Routine called in Command.pm, see there for more details.
146 0 ▶sub _get_repo_dirs {
Subroutine _get_repo_dirs: not called CC=1 SCAR=6.9
147 0 my $self = shift;
148 0 my $l_dir = $self->get_name({no_base => 1});
149 0 my $root_repo_dir = $self->{Admin}->get_Root()->{RootDir};
150 0 my $within_repo_dir = $self->{Admin}->get_Repository()->as_string();
151 0 my $r_dir = File::Spec::Unix->catdir($root_repo_dir, $within_repo_dir);
152  
153 0 return [ $l_dir, $r_dir ];
154 }
155  
156 1 1;
« blib/lib/VCS/LibCVS/Repository.pm ↑ Summary blib/lib/VCS/LibCVS/Client/Request.pm »