Subversion Repositories DevTools

Rev

Rev 311 | Rev 363 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 311 Rev 353
Line 34... Line 34...
34
#
34
#
35
our $GBE_SVN_PATH;                      # Optional: SVN bin directory
35
our $GBE_SVN_PATH;                      # Optional: SVN bin directory
36
our $GBE_SVN_USERNAME;                  # Optional: User name
36
our $GBE_SVN_USERNAME;                  # Optional: User name
37
our $GBE_SVN_PASSWORD;                  # Optional: User passwrd
37
our $GBE_SVN_PASSWORD;                  # Optional: User passwrd
38
 
38
 
39
 
-
 
40
package JatsSvnCore;
39
package JatsSvnCore;
41
 
40
 
42
use JatsError;
41
use JatsError;
43
use JatsSystem;
42
use JatsSystem;
44
use IPC::Open3;
43
use IPC::Open3;
Line 59... Line 58...
59
                    SvnComment
58
                    SvnComment
60
                    
59
                    
61
                );
60
                );
62
@EXPORT_OK =  qw(
61
@EXPORT_OK =  qw(
63
                    ProcessRevNo
62
                    ProcessRevNo
-
 
63
                    %SVN_URLS
-
 
64
                    @SVN_URLS_LIST
-
 
65
                    
64
                );
66
                );
65
 
67
 
66
%EXPORT_TAGS = (All => [@EXPORT, @EXPORT_OK]);
68
%EXPORT_TAGS = (All => [@EXPORT, @EXPORT_OK]);
67
 
69
 
68
 
70
 
69
#
71
#
70
#   Package Global
72
#   Package Global
71
#
73
#
72
my $svn;                                # Abs path to 'svn' utility
74
my  $svn;                               # Abs path to 'svn' utility
73
my $stdmux;                             # Abs path to stdmux utlity
75
my  $stdmux;                            # Abs path to stdmux utlity
-
 
76
our %SVN_URLS;                          # Exported repository URLs
-
 
77
our @SVN_URLS_LIST;                     # Exported repository URLs scan order
74
 
78
 
75
#-------------------------------------------------------------------------------
79
#-------------------------------------------------------------------------------
76
# Function        : BEGIN
80
# Function        : BEGIN
77
#
81
#
78
# Description     : Module Initialization
82
# Description     : Module Initialization
Line 110... Line 114...
110
    Debug ("GBE_SVN_PASSWORD", $::GBE_SVN_PASSWORD);
114
    Debug ("GBE_SVN_PASSWORD", $::GBE_SVN_PASSWORD);
111
    Debug ("GBE_SVN_PATH", $::GBE_SVN_PATH);
115
    Debug ("GBE_SVN_PATH", $::GBE_SVN_PATH);
112
 
116
 
113
    $stdmux = LocateProgInPath ( 'stdmux');
117
    $stdmux = LocateProgInPath ( 'stdmux');
114
    $svn    = LocateProgInPath ( 'svn', '--All', '--Path=' . $::GBE_SVN_PATH );
118
    $svn    = LocateProgInPath ( 'svn', '--All', '--Path=' . $::GBE_SVN_PATH );
-
 
119
 
-
 
120
    #
-
 
121
    #   Extract GBE_SVN_XXXX_URL information from the environment
-
 
122
    #       XXXX is the first element of the repository path and will
-
 
123
    #            be globally (ERG) unique
-
 
124
    #       The value will be the URL to access this named repository path
-
 
125
    #       It will normally include the repository path
-
 
126
    #       The saved URL will be terminated with a single '/' to simplify usage
-
 
127
    #
-
 
128
    foreach ( sort keys %ENV )
-
 
129
    {
-
 
130
        if ( m ~^GBE_SVN_URL_*(.*)~ )
-
 
131
        {
-
 
132
            my $url = $ENV{$_};
-
 
133
            my $key = $1;
-
 
134
            $url =~ s~/*$~/~;
-
 
135
            $SVN_URLS{$key} = $url;
-
 
136
 
-
 
137
            #
-
 
138
            #   Ensure that it is in valid format
-
 
139
            #   Four forms are supported, although not all should be used
-
 
140
            #
-
 
141
            if ( $url =~ m{^svn://[^/]+} ) {
-
 
142
                #
-
 
143
                #   Type is SVN server
-
 
144
                #   Protocol + server name
-
 
145
                #
-
 
146
            } elsif ( $url =~ m{^https{0,1}://.+} ) {
-
 
147
                #
-
 
148
                #   Type is HTTP server
-
 
149
                #   Protocol + server name + path on server
-
 
150
                #
-
 
151
            } elsif ( $url =~ m{^file:///+[A-Z]:/} ) {
-
 
152
                #
-
 
153
                #   Type is local Repo (file)
-
 
154
                #   Windows absolute pathname
-
 
155
                #   file:///I:/path/...
-
 
156
                #
-
 
157
            } elsif ( $url =~ m{^file:///+[^/]} ) {
-
 
158
                #
-
 
159
                #   Type is local Repo (file)
-
 
160
                #   Unix absolute pathname
-
 
161
                #   file:///path/...
-
 
162
                #
-
 
163
            } else {
-
 
164
                ReportError ("GBE_SVN_URL format not understood","$key: $url");
-
 
165
            }
-
 
166
            
-
 
167
        }
-
 
168
    }
-
 
169
    @SVN_URLS_LIST = reverse sort keys %SVN_URLS;
-
 
170
    ErrorDoExit();
-
 
171
#DebugDumpData("%SVN_URLS", \%SVN_URLS, \@SVN_URLS_LIST);
115
}
172
}
116
 
173
 
117
#-------------------------------------------------------------------------------
174
#-------------------------------------------------------------------------------
118
# Function        : SvnSession
175
# Function        : SvnSession
119
#
176
#
Line 560... Line 617...
560
# Returns         : RMREF - String Reference
617
# Returns         : RMREF - String Reference
561
#
618
#
562
sub CalcRmReference
619
sub CalcRmReference
563
{
620
{
564
    my ($self, $target) = @_;
621
    my ($self, $target) = @_;
565
    Debug ("CalcRmReference");
-
 
566
    
-
 
567
    Error ("CalcRmReference: No Target") unless ( $target );
622
    Error ("CalcRmReference: No Target") unless ( $target );
-
 
623
    Debug ("CalcRmReference: $target");
-
 
624
 
-
 
625
    #
-
 
626
    #   Insert any revision information to create a pegged URL
-
 
627
    #
-
 
628
    $target .= '@' . $self->{REVNO} if $self->{REVNO};
568
 
629
 
569
    #
630
    #
570
    #   Take target and remove the reference to the local repository,
631
    #   Take target and remove the reference to the local repository,
571
    #   if its present. This will provide a ref that we can use on any site
632
    #   if its present. This will provide a ref that we can use on any site
572
    #
633
    #
573
    #   Note: GBE_SVN_URL will have a trailing '/'
634
    #   Note: %SVN_URLS values will have a trailing '/'
574
    #
635
    #
-
 
636
    #   Sort in reverse order to ensure that the default URL is found last
-
 
637
    #
575
    $target .= '@' . $self->{REVNO} if $self->{REVNO};
638
    foreach my $tag ( @SVN_URLS_LIST )
-
 
639
    {
576
    $target =~ s~^\Q$::GBE_SVN_URL\E~~ if ( $::GBE_SVN_URL );
640
        if ( $target =~ s~^\Q$SVN_URLS{$tag}\E~$tag/~ )
-
 
641
        {
-
 
642
            $target =~ s~^/~~;
-
 
643
            last;
-
 
644
        }
-
 
645
    }
577
    return $self->{RMREF} = $target;
646
    return $self->{RMREF} = $target;
578
}
647
}
579
 
648
 
580
#-------------------------------------------------------------------------------
649
#-------------------------------------------------------------------------------
581
# Function        : SvnComment
650
# Function        : SvnComment