Subversion Repositories DevTools

Rev

Rev 5709 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
392 dpurdie 3
#
4
# Module name   : cc2svn_locateTips.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Locate the tips in a package
10
#
11
# Usage:
12
#
13
# Version   Who      Date        Description
14
#
15
#......................................................................#
16
 
17
require 5.008_002;
18
use strict;
19
use warnings;
20
 
21
use Pod::Usage;
22
use Getopt::Long;
23
 
24
use JatsError;
25
use JatsSystem;
26
use JatsSvn qw(:All);
27
 
28
#
29
#   Options
30
#
31
my $opt_help = 0;
32
my $opt_manual = 0;
33
my $opt_verbose = 0;
34
my $opt_url;
35
 
36
#
37
#   Globals
38
#
39
my @dataItems;
40
 
41
#-------------------------------------------------------------------------------
42
# Function        : main
43
#
44
# Description     : Main entry point
45
#
46
# Inputs          : 
47
#
48
# Returns         : 
49
#
50
 
51
my $result = GetOptions (
52
                "help+"         => \$opt_help,          # Help
53
                "manual"        => \$opt_manual,        # Help
54
                "verbose:+"     => \$opt_verbose,       # Versose
55
                );
56
 
57
#
58
#   Process help and manual options
59
#
60
pod2usage(-verbose => 0 )  if ($opt_help == 1  || ! $result);
61
pod2usage(-verbose => 1)  if ($opt_help == 2 );
62
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
63
 
64
#
65
#   Configure the error reporting process now that we have the user options
66
#
67
SystemConfig ('ExitOnError' => 1);
68
ErrorConfig( 'name'    =>'CC2SVN_LOCATETIPS',
69
             'verbose' => $opt_verbose,
70
              );
71
 
72
$opt_url = shift (@ARGV) if ( $#ARGV == 0 );
73
Error ("No URL specified") unless ( $opt_url );
74
 
75
#
76
#   Create an SVN session
77
#
78
my $svn = NewSessionByUrl ( $opt_url );
79
 
80
#
81
#   extract data
82
#
83
DebugDumpData("SVN", $svn );
84
 
85
    $svn->SvnCmd ( 'log', '-v', '--xml', '--stop-on-copy', $svn->Full()
86
                    , { 'credentials' => 1,
87
                        'process' => \&ProcessLog,
88
                         }
89
                        );
90
 
91
#DebugDumpData("dataItems", @dataItems );
92
 
93
my %mdata;
94
my %target;
95
my %revToName;
96
my %tags;
97
my %branches;
98
my @nonTags;
99
 
100
foreach my $entry ( @dataItems )
101
{
102
    push @{$mdata{$entry->{fromPath}}}, $entry;
103
    $target{$entry->{target}} = $entry->{Rev};
104
    $revToName{$entry->{Rev}} = $entry->{target};
105
 
106
    my $name;
107
    my $target = $entry->{target};
108
    if ( $target =~ m~/tags/(.*)~ ) {
109
        $name = $1;
110
        $tags{$1} = 1;
111
    } elsif ( $target =~ m~/branches/(.*)~ )  {
112
        $name = $1;
113
#        $branches{$1} = 1;
114
    } else {
115
        push @nonTags, $target;
116
    }
117
 
118
    $entry->{fromPath} =~ m~/branches/(.*)~;
119
    my $fromBranch = $1;
120
    if ( defined($1) && ! exists $branches{$fromBranch} )
121
    {
122
        $branches{$fromBranch} = $name;
123
    }
124
}
125
 
126
Message ("Tags", sort keys %tags);
127
#Message ("Branches", sort keys %branches);
128
foreach my $branch ( sort keys %branches )
129
{
130
    Message ("$branch : $branches{$branch}");
131
}
132
Message ('NonTags', sort @nonTags );
133
 
134
#DebugDumpData("From", \%from);
135
#
136
#   Create a DOT file
137
#
138
 
139
    my $filebase = 'aaa';
140
    open (FH, ">$filebase.dot" ) or die "Cannot open output";
141
    print FH "digraph \"${filebase}\" {\n";
142
    #print FH "rankdir=LR;\n";
143
    print FH "node[fontsize=16];\n";
144
    print FH "node[target=_graphviz];\n";
145
 
146
    my %doneLabel;
147
    foreach my $root ( keys %mdata )
148
    {
149
        my $last = undef;
150
        my $first = 1;
151
 
152
        foreach my $entry ( @{$mdata{$root}} )
153
        {
154
#            DebugDumpData("dataItems", $entry );
155
print FH "//root      :$root\n";
156
print FH "//Rev       :$entry->{Rev}\n";
157
print FH "//target    :$entry->{target}\n";
158
print FH "//fromRev   :$entry->{fromRev}\n";
159
print FH "//fromPath  :$entry->{fromPath}\n";
160
 
161
            if ( $last )
162
            {
163
                print FH dotTag($revToName{$entry->{Rev}})  ,' -> ', dotTag($revToName{$last->{Rev}}) , ";\n";
164
            }
165
            else
166
            {
167
                #
168
                #   Display branch tip
169
                #
170
                my $tip_tag = 'BH_' . dotTag($root);
171
                print FH $tip_tag  ,'[shape=box label="', "BRANCH_HEAD\\nName: $root",'"];', "\n";
172
                print FH dotTag($revToName{$entry->{Rev}})  ,' -> ', $tip_tag , ";\n";
173
 
174
            }
175
 
176
 
1270 dpurdie 177
##=pod
178
##            print FH dotTag($entry->{fromRev})  ,' -> ', dotTag($entry->{Rev}) , ";\n";
179
##            my $text = $first ? "HEAD\\n" : '';
180
##            print FH $entry->{Rev}  ,'[label="', "$text$entry->{target}\\n$entry->{Rev}" , '"];', "\n";
181
###            print FH $entry->{fromRev}  ,'[label="', "ROOT\\n $entry->{fromPath}\\n$entry->{fromRev}",'"];', "\n"
182
###                unless $doneLabel{$root};
183
##            $doneLabel{$root} = 1;
184
##
185
##            if ( $last )
186
##            {
187
##                print FH dotTag($last->{Rev})  ,' -> ', dotTag($entry->{fromRev}) , ";\n";
188
##            }
189
##            else
190
##            {
191
##                #print FH dotTag($target{$entry->{fromPath}})  ,' -> ', dotTag($entry->{fromRev}) , ";\n" if $target{$entry->{fromPath}};
192
##            }
193
##=cut
392 dpurdie 194
 
195
            $last = $entry;
196
            $first = 0;
197
        }
198
 
199
        #
200
        #   Display branch point name
201
        #
202
        my $tag = dotTag($revToName{$last->{Rev}});
203
        print FH dotTag($root)  ,' -> ', $tag , ";\n" if $last;
204
        print FH dotTag($root)  ,'[label="', "BRANCH_NAME\\n" . $root , '"];', "\n";
205
        print FH $tag  ,'[label="', "BRANCH_POINT\\n" . $revToName{$last->{Rev}} , '"];', "\n";
206
 
207
    }
208
    print FH "\n};\n";
209
    close FH;
210
 
211
    #
212
    #   Convert DOT to a SVG
213
    #
214
    print "Generated: $filebase.dot\n";
215
 
216
sub dotTag
217
{
218
    my ($label) = @_;
219
    $label =~ s~[-() /.]~_~g;
220
    return $label;
221
}
222
 
223
 
224
 
225
#-------------------------------------------------------------------------------
226
# Function        : ProcessLog
227
#
228
# Description     :
229
#                   Parse
230
#                       <logentry
231
#                          revision="24272">
232
#                       <author>bivey</author>
233
#                       <date>2005-07-25T15:45:35.000000Z</date>
234
#                       <paths>
235
#                       <path
236
#                          prop-mods="false"
237
#                          text-mods="false"
238
#                          kind="dir"
239
#                          copyfrom-path="/enqdef/branches/Stockholm"
240
#                          copyfrom-rev="24271"
241
#                          action="A">/enqdef/tags/enqdef_24.0.1.sls</path>
242
#                       </paths>
243
#                       <msg>COTS/enqdef: Tagged by Jats Svn Import</msg>
244
#                       </logentry>
245
#
246
# Inputs          : 
247
#
248
# Returns         : 
249
#
250
my $entryData;
251
sub  ProcessLog
252
{
253
    my ($self, $line ) = @_;
254
#print "----- $line\n";
255
    if ( $line =~ m~^<logentry~ ) {
256
        $entryData = ();
257
 
258
    } elsif ( $line =~ m~^\s+revision="(\d+)"~ ) {
259
        $entryData->{Rev} = $1;
260
 
261
    } elsif ( $line =~ m~^\s+copyfrom-path="(.*)"~ ) {
262
        $entryData->{fromPath} = $1;
263
 
264
    } elsif ( $line =~ m~^\s+copyfrom-rev="(\d+)"~ ) {
265
        $entryData->{fromRev} = $1;
266
 
267
    } elsif ( $line =~ m~\s+action=.*?>(.*)</path~ ) {
268
        $entryData->{target} = $1;
269
 
270
    } elsif ( $line =~ m~</logentry~ ) {
271
        if ( exists $entryData->{fromPath} )
272
        {
273
#            DebugDumpData("Data", $entryData);
274
            push @dataItems, $entryData;
275
        }
276
    }
277
 
278
 
279
    #
280
    #   Return 0 to keep on going
281
    return 0;
282
}
283