| 1293 |
dpurdie |
1 |
###############################################################################
|
|
|
2 |
# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
|
|
|
3 |
# sits@users.sourceforge.net
|
|
|
4 |
#
|
|
|
5 |
# This program is free software; you can redistribute it and modify it under
|
|
|
6 |
# the terms of the GPL.
|
|
|
7 |
|
|
|
8 |
# Factory class for retrieving a repository object.
|
|
|
9 |
|
|
|
10 |
package Codestriker::Repository::RepositoryFactory;
|
|
|
11 |
|
|
|
12 |
use strict;
|
|
|
13 |
|
|
|
14 |
use Codestriker::Repository::Cvs;
|
|
|
15 |
use Codestriker::Repository::ViewCvs;
|
|
|
16 |
use Codestriker::Repository::CvsWeb;
|
|
|
17 |
use Codestriker::Repository::Subversion;
|
|
|
18 |
use Codestriker::Repository::Perforce;
|
|
|
19 |
use Codestriker::Repository::Vss;
|
|
|
20 |
use Codestriker::Repository::ClearCaseSnapshot;
|
|
|
21 |
use Codestriker::Repository::ClearCaseDynamic;
|
|
|
22 |
|
|
|
23 |
# Factory method for retrieving a Repository object, given a descriptor.
|
|
|
24 |
sub get ($$) {
|
|
|
25 |
my ($type, $repository) = @_;
|
|
|
26 |
|
|
|
27 |
if (!(defined $repository) || $repository eq "") {
|
|
|
28 |
return undef;
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
if ($repository =~ /^\s*(\/.*?)\/*\s*$/) {
|
|
|
32 |
# CVS repository on the local machine.
|
|
|
33 |
return Codestriker::Repository::Cvs->build_local($1, '');
|
|
|
34 |
|
|
|
35 |
} elsif ($repository =~ /^\s*:local:([A-z]:[\\\/].*?)\\*\s*$/) {
|
|
|
36 |
# Windoze "local" CVS repository.
|
|
|
37 |
return Codestriker::Repository::Cvs->build_local($1, ':local:');
|
|
|
38 |
|
|
|
39 |
} elsif ($repository =~ /^\s*([A-z]:[\\\/].*?)\\*\s*$/) {
|
|
|
40 |
# Windoze CVS repository.
|
|
|
41 |
return Codestriker::Repository::Cvs->build_local($1, '');
|
|
|
42 |
|
|
|
43 |
} elsif ($repository =~ /^\s*:pserver(.*):(.*):(.*)@(.*):(.*)\s*$/i) {
|
|
|
44 |
# Pserver repository.
|
|
|
45 |
return Codestriker::Repository::Cvs->build_pserver($1, $2, $3, $4, $5);
|
|
|
46 |
|
|
|
47 |
} elsif ($repository =~ /^\s*:ext(.*):(.*)@(.*):(.*)\s*$/i) {
|
|
|
48 |
# Pserver repository.
|
|
|
49 |
return Codestriker::Repository::Cvs->build_ext($1, $2, $3, $4);
|
|
|
50 |
|
|
|
51 |
} elsif ($repository =~ /^\s*:sspi:(.*):(.*)@(.*):([A-z]:[\\\/].*?)\\*\s*(.*)\s*$/i) {
|
|
|
52 |
# NT SSPI CVS repository. Example:
|
|
|
53 |
# :sspi:MYNTDOMAIN\jdoe:password@mycvsserver:c:\repository_on_server
|
|
|
54 |
# :sspi:<host address>:\ANDCVS
|
|
|
55 |
return Codestriker::Repository::Cvs->build_sspi($1, $2, $3, $4);
|
|
|
56 |
|
|
|
57 |
} elsif ($repository =~ /^\s*(https?:\/\/.*viewcvs\.cgi)\/*\s+(.*?)\/*\s*$/i) {
|
|
|
58 |
# View CVS repository.
|
|
|
59 |
return Codestriker::Repository::ViewCvs->new($1, $2);
|
|
|
60 |
|
|
|
61 |
} elsif ($repository =~ /^\s*(https?:\/\/.*cvsweb\.cgi)\/*\s+(.*?)\/*\s*$/i) {
|
|
|
62 |
# CVS web repository.
|
|
|
63 |
return Codestriker::Repository::CvsWeb->new($1, $2);
|
|
|
64 |
} elsif ($repository =~ /^\s*(svn:\/\/.*)\s*;(.*);(.*)$/i) {
|
|
|
65 |
# Subversion repository using svnserver with username and password.
|
|
|
66 |
return Codestriker::Repository::Subversion->new($1, $2, $3);
|
|
|
67 |
} elsif ($repository =~ /^\s*(svn:\/\/.*)\s*$/i) {
|
|
|
68 |
return Codestriker::Repository::Subversion->new($1);
|
|
|
69 |
} elsif ($repository =~ /^\s*svn:(.*)\s*;(.*);(.*)$/i) {
|
|
|
70 |
# Subversion repository with username and password
|
|
|
71 |
return Codestriker::Repository::Subversion->new($1, $2, $3);
|
|
|
72 |
|
|
|
73 |
} elsif ($repository =~ /^\s*svn:(.*)\s*$/i) {
|
|
|
74 |
# Subversion repository.
|
|
|
75 |
return Codestriker::Repository::Subversion->new($1);
|
|
|
76 |
|
|
|
77 |
} elsif ($repository =~ /^\s*perforce:(.*):(.*)@(.*):(.*)\s*$/i) {
|
|
|
78 |
# Perforce repository.
|
|
|
79 |
return Codestriker::Repository::Perforce->new($1, $2, $3, $4);
|
|
|
80 |
|
|
|
81 |
} elsif ($repository =~ /^\s*perforce:(.*)@(.*):(.*)\s*$/i) {
|
|
|
82 |
# Perforce repository with no password.
|
|
|
83 |
return Codestriker::Repository::Perforce->new($1, '', $2, $3);
|
|
|
84 |
|
|
|
85 |
} elsif ($repository =~ /^\s*vss:(.*);(.*);(.*)$/i) {
|
|
|
86 |
# Visual Source Safe repository spec with SSDIR, user and password.
|
|
|
87 |
return Codestriker::Repository::Vss->new($2,$3,$1);
|
|
|
88 |
|
|
|
89 |
} elsif ($repository =~ /^\s*vss:(.*);(.*)$/i) {
|
|
|
90 |
# Visual Source Safe repository spec with user and password.
|
|
|
91 |
return Codestriker::Repository::Vss->new($1,$2);
|
|
|
92 |
|
|
|
93 |
} elsif ($repository =~ /^\s*vss:(.*):(.*)$/i) {
|
|
|
94 |
# Older-style Visual Source Safe (VSS) repository spec.
|
|
|
95 |
return Codestriker::Repository::Vss->new($1,$2);
|
|
|
96 |
}
|
|
|
97 |
elsif ($repository =~ /^\s*clearcase:dyn:(.*)$/i) {
|
|
|
98 |
# ClearCase Dynamic repository.
|
|
|
99 |
return Codestriker::Repository::ClearCaseDynamic->new($1);
|
|
|
100 |
} elsif ($repository =~ /^\s*clearcase:(.*)$/i) {
|
|
|
101 |
# ClearCase Snapshot repository.
|
|
|
102 |
return Codestriker::Repository::ClearCaseSnapshot->new($1);
|
|
|
103 |
|
|
|
104 |
} else {
|
|
|
105 |
# Unknown repository type.
|
|
|
106 |
print STDERR "Codestriker: Couldn't match repository: \"$repository\"\n";
|
|
|
107 |
return undef;
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
1;
|