| 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::Datum::LogMessage; | ||||||||||
| 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::Datum::LogMessage - A cvs log message. | ||||||||||
| 16 | |||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||
| 18 | |||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||
| 20 | |||||||||||
| 21 | A CVS log message for one revision. It parses a message of this format and | ||||||||||
| 22 | provides access to the various parts: | ||||||||||
| 23 | |||||||||||
| 24 | revision 1.2.2.1 | ||||||||||
| 25 | date: 2002/11/13 02:29:46; author: dissent; state: Exp; lines: +1 -0 | ||||||||||
| 26 | branches: 1.2.2; | ||||||||||
| 27 | this is a boring commit with a shortish log message | ||||||||||
| 28 | but it does have two lines to it | ||||||||||
| 29 | |||||||||||
| 30 | =head1 SUPERCLASS | ||||||||||
| 31 | |||||||||||
| 32 | VCS::LibCVS::Datum | ||||||||||
| 33 | |||||||||||
| 34 | =cut | ||||||||||
| 35 | |||||||||||
| 36 | ############################################################################### | ||||||||||
| 37 | # Class constants | ||||||||||
| 38 | ############################################################################### | ||||||||||
| 39 | |||||||||||
| 40 | 1 | ▶ | use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Datum/LogMessage.pm,v 1.7 2005/10/10 12:52:12 dissent Exp $ '; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | use vars ('@ISA'); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | 1 | @ISA = ("VCS::LibCVS::Datum"); | |||||||||
| 44 | |||||||||||
| 45 | ############################################################################### | ||||||||||
| 46 | # Class variables | ||||||||||
| 47 | ############################################################################### | ||||||||||
| 48 | |||||||||||
| 49 | ############################################################################### | ||||||||||
| 50 | # Private variables | ||||||||||
| 51 | ############################################################################### | ||||||||||
| 52 | |||||||||||
| 53 | # $self->{RevisionNumber} object of type VCS::LibCVS::Datum::RevisionNumber | ||||||||||
| 54 | # $self->{Text} scalar string -- the text of the message | ||||||||||
| 55 | # $that->{Date} the date of the commit | ||||||||||
| 56 | # $that->{Author} the author of the commit | ||||||||||
| 57 | # $that->{State} the state of the commit (Exp, . . .) | ||||||||||
| 58 | # $that->{Lines} the + - lines info of the commit | ||||||||||
| 59 | # $that->{Branches} ; separated list of branches from this log | ||||||||||
| 60 | # it should be make a list of RevisionNumbers | ||||||||||
| 61 | |||||||||||
| 62 | ############################################################################### | ||||||||||
| 63 | # Class routines | ||||||||||
| 64 | ############################################################################### | ||||||||||
| 65 | |||||||||||
| 66 | =head1 CLASS ROUTINES | ||||||||||
| 67 | |||||||||||
| 68 | =head2 B<new()> | ||||||||||
| 69 | |||||||||||
| 70 | $log_m = VCS::LibCVS::Datum::LogMessage->new($text) | ||||||||||
| 71 | |||||||||||
| 72 | =over 4 | ||||||||||
| 73 | |||||||||||
| 74 | =item return type: VCS::LibCVS::Datum::LogMessage | ||||||||||
| 75 | |||||||||||
| 76 | =item argument 1 type: array ref of lines | ||||||||||
| 77 | |||||||||||
| 78 | Entire log message as a ref to an array of lines, including additional | ||||||||||
| 79 | information in this form: | ||||||||||
| 80 | |||||||||||
| 81 | revision 1.2 | ||||||||||
| 82 | date: 2002/11/13 02:29:46; author: dissent; state: Exp; lines: +1 -0 | ||||||||||
| 83 | branches: 1.2.2; | ||||||||||
| 84 | |||||||||||
| 85 | It is parsed on creation. | ||||||||||
| 86 | |||||||||||
| 87 | =back | ||||||||||
| 88 | |||||||||||
| 89 | =cut | ||||||||||
| 90 | |||||||||||
| 91 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 92 | 0 | my $class = shift; | |||||||||
| 93 | 0 | my $that = bless {}, $class; | |||||||||
| 94 | |||||||||||
| 95 | 0 | my $log = shift; | |||||||||
| 96 | |||||||||||
| 97 | 0 | my ($rev_string) = ( (shift @$log) =~ /revision ([0-9.]+)/ ); | |||||||||
| 98 | 0 | $that->{Revision} = VCS::LibCVS::Datum::RevisionNumber->new($rev_string); | |||||||||
| 99 | |||||||||||
| 100 | 0 | (shift @$log) =~ /date: (.*); author: (.*); state: (.*);( lines: (.*))?/; | |||||||||
| 101 | 0 | $that->{Date} = $1; | |||||||||
| 102 | 0 | $that->{Author} = $2; | |||||||||
| 103 | 0 | $that->{State} = $3; | |||||||||
| 104 | 0 | $that->{Lines} = $5; | |||||||||
| 105 | |||||||||||
| 106 | 0 | ▶ | if ( $$log[0] =~ /^branches:/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 107 | # Parse out list of branches. See Issue 24. | ||||||||||
| 108 | 0 | $that->{Branches} = ( (shift @$log) =~ /branches: (.*)/ ); | |||||||||
| 109 | } | ||||||||||
| 110 | |||||||||||
| 111 | 0 | $that->{Text} = join("\n", @$log); | |||||||||
| 112 | |||||||||||
| 113 | 0 | return $that; | |||||||||
| 114 | } | ||||||||||
| 115 | |||||||||||
| 116 | ############################################################################### | ||||||||||
| 117 | # Instance routines | ||||||||||
| 118 | ############################################################################### | ||||||||||
| 119 | |||||||||||
| 120 | =head1 INSTANCE ROUTINES | ||||||||||
| 121 | |||||||||||
| 122 | =head2 B<get_revision()> | ||||||||||
| 123 | |||||||||||
| 124 | $revision = $log_m->get_revision() | ||||||||||
| 125 | |||||||||||
| 126 | =over 4 | ||||||||||
| 127 | |||||||||||
| 128 | =item return type: VCS::LibCVS::RevisionNumber | ||||||||||
| 129 | |||||||||||
| 130 | =back | ||||||||||
| 131 | |||||||||||
| 132 | =cut | ||||||||||
| 133 | |||||||||||
| 134 | 0 | ▶ | sub get_revision { | ||||||||
|
Subroutine
get_revision: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 135 | 0 | return shift->{Revision}; | |||||||||
| 136 | } | ||||||||||
| 137 | |||||||||||
| 138 | =head2 B<get_text()> | ||||||||||
| 139 | |||||||||||
| 140 | $text = $log_m->get_text() | ||||||||||
| 141 | |||||||||||
| 142 | =over 4 | ||||||||||
| 143 | |||||||||||
| 144 | =item return type: scalar string | ||||||||||
| 145 | |||||||||||
| 146 | =back | ||||||||||
| 147 | |||||||||||
| 148 | =cut | ||||||||||
| 149 | |||||||||||
| 150 | 0 | ▶ | sub get_text { | ||||||||
|
Subroutine
get_text: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 151 | 0 | return shift->{Text}; | |||||||||
| 152 | } | ||||||||||
| 153 | |||||||||||
| 154 | ############################################################################### | ||||||||||
| 155 | # Private routines | ||||||||||
| 156 | ############################################################################### | ||||||||||
| 157 | |||||||||||
| 158 | |||||||||||
| 159 | =head1 SEE ALSO | ||||||||||
| 160 | |||||||||||
| 161 | VCS::LibCVS | ||||||||||
| 162 | |||||||||||
| 163 | =cut | ||||||||||
| 164 | |||||||||||
| 165 | 1 | 1; | |||||||||