]>
Commit | Line | Data |
---|---|---|
ae160384 TM |
1 | /* |
2 | * Copyright (C) 2007 Thiago Macieira <thiago@kde.org> | |
3 | * | |
4 | * This program is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation, either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | ||
18 | #include <QCoreApplication> | |
bb416d33 | 19 | #include <QFile> |
ae160384 TM |
20 | #include <QStringList> |
21 | ||
22 | #include <stdio.h> | |
23 | ||
1228bd7c | 24 | #include "options.h" |
ae160384 TM |
25 | #include "ruleparser.h" |
26 | #include "repository.h" | |
695ab9ee | 27 | #include "svn.h" |
ae160384 | 28 | |
bb416d33 TM |
29 | QHash<QByteArray, QByteArray> loadIdentityMapFile(const QString &fileName) |
30 | { | |
31 | QHash<QByteArray, QByteArray> result; | |
32 | if (fileName.isEmpty()) | |
33 | return result; | |
34 | ||
35 | QFile file(fileName); | |
e6174e93 TM |
36 | if (!file.open(QIODevice::ReadOnly)) { |
37 | fprintf(stderr, "Could not open file %s: %s", | |
38 | qPrintable(fileName), qPrintable(file.errorString())); | |
bb416d33 | 39 | return result; |
e6174e93 | 40 | } |
bb416d33 TM |
41 | |
42 | while (!file.atEnd()) { | |
43 | QByteArray line = file.readLine().trimmed(); | |
44 | int space = line.indexOf(' '); | |
45 | if (space == -1) | |
46 | continue; // invalid line | |
47 | ||
48 | QByteArray realname = line.mid(space).trimmed(); | |
49 | line.truncate(space); | |
50 | result.insert(line, realname); | |
51 | }; | |
52 | ||
53 | return result; | |
54 | } | |
55 | ||
ae160384 TM |
56 | int main(int argc, char **argv) |
57 | { | |
58 | QCoreApplication app(argc, argv); | |
59 | ||
1228bd7c TM |
60 | Options options; |
61 | options.parseArguments(app.arguments()); | |
ae160384 TM |
62 | |
63 | // Load the configuration | |
1228bd7c | 64 | Rules rules(options.ruleFile); |
ae160384 TM |
65 | rules.load(); |
66 | ||
1a688729 | 67 | int min_rev = options.options.value("resume-from").toInt(); |
61ae76bd | 68 | int max_rev = options.options.value("max-rev").toInt(); |
1a688729 TM |
69 | if (min_rev < 1) |
70 | min_rev = 1; | |
71 | ||
ae160384 TM |
72 | // create the repository list |
73 | QHash<QString, Repository *> repositories; | |
1a688729 TM |
74 | foreach (Rules::Repository rule, rules.repositories()) { |
75 | Repository *repo = new Repository(rule); | |
1a688729 TM |
76 | repositories.insert(rule.name, repo); |
77 | } | |
ae160384 | 78 | |
695ab9ee | 79 | Svn::initialize(); |
1228bd7c | 80 | Svn svn(options.pathToRepository); |
695ab9ee TM |
81 | svn.setMatchRules(rules.matchRules()); |
82 | svn.setRepositories(repositories); | |
bb416d33 | 83 | svn.setIdentityMap(loadIdentityMapFile(options.options.value("identity-map"))); |
695ab9ee | 84 | |
61ae76bd TM |
85 | if (max_rev < 1) |
86 | max_rev = svn.youngestRevision(); | |
1a688729 | 87 | for (int i = min_rev; i <= max_rev; ++i) |
ab162d73 TM |
88 | if (!svn.exportRevision(i)) |
89 | break; | |
695ab9ee | 90 | |
a5fd311b TM |
91 | foreach (Repository *repo, repositories) { |
92 | repo->finalizeTags(); | |
93 | delete repo; | |
94 | } | |
95 | ||
ae160384 TM |
96 | // success |
97 | return 0; | |
98 | } |