2
* Copyright (C) 2003 Robert Collins <robertc@squid-cache.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* DO NOT ALTER THE NEXT LINE
20
* arch-tag: fd65883c-807a-4ae7-8981-ec1e60b8e13b
25
#include "ConfigSource.h"
26
#include "ConfigArchSource.h"
27
#include "ConfigCVSSource.h"
28
#include "ConfigSVNSource.h"
29
#include "ConfigWGetSource.h"
30
#include "FileSystemVisitor.h"
33
ConfigSource::Create(string const &url) throw(exception *)
37
if (url.find(":") == string::npos) {
38
return new ConfigArchSource(url);
41
if (url.find("arch://") == 0)
42
return new ConfigArchSource(url.substr(7));
44
if (url.find("pserver://") == 0)
45
return new ConfigCVSSource(url);
47
if (url.find ("ext://") == 0)
48
return new ConfigCVSSource(url);
50
if (url.find ("http://") == 0)
51
return new ConfigWGetSource(url);
53
if (url.find ("ftp://") == 0)
54
return new ConfigWGetSource(url);
56
if (url.find ("svn") == 0)
57
return new ConfigSVNSource(url);
59
throw new runtime_error("Unknown RCS URL scheme.");
62
/* identify the rcs system used at a specific directory.
64
* if the dir has explicit markers for any given RCS system, use that.
65
* if the dir doesn't, and there is a parent RCS source, use that.
69
ConfigSource::Create(Path const &location, ConfigSource const *parent) throw (exception *)
71
ConfigSource *result = NULL;
72
/* Try each known type */
73
result = ConfigArchSource::Create(location);
76
result = ConfigCVSSource::Create(location, parent);
83
/* other module tests go here */
89
ConfigSource::run_query (string const &command, string const &type) const
92
cout << "Executing '" << command << "'" << endl;
94
int result = system(command.c_str());
97
throw new runtime_error(type + " command execution failed");
99
return WEXITSTATUS(result);
103
ConfigSource::run (string const &command, string const &type) const
105
if (run_query(command, type) != 0)
106
throw new runtime_error("Error returned by " + type + " command");
110
ConfigSource::Verbose(bool const &aBool)
116
ConfigSource::Verbose()
121
bool ConfigSource::Verbose_ = false;