]> andersk Git - svn-all-fast-export.git/blame - src/main.cpp
Implement the identity map
[svn-all-fast-export.git] / src / main.cpp
CommitLineData
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
29QHash<QByteArray, QByteArray> loadIdentityMapFile(const QString &fileName)
30{
31 QHash<QByteArray, QByteArray> result;
32 if (fileName.isEmpty())
33 return result;
34
35 QFile file(fileName);
36 if (!file.open(QIODevice::ReadOnly))
37 return result;
38
39 while (!file.atEnd()) {
40 QByteArray line = file.readLine().trimmed();
41 int space = line.indexOf(' ');
42 if (space == -1)
43 continue; // invalid line
44
45 QByteArray realname = line.mid(space).trimmed();
46 line.truncate(space);
47 result.insert(line, realname);
48 };
49
50 return result;
51}
52
ae160384
TM
53int main(int argc, char **argv)
54{
55 QCoreApplication app(argc, argv);
56
1228bd7c
TM
57 Options options;
58 options.parseArguments(app.arguments());
ae160384
TM
59
60 // Load the configuration
1228bd7c 61 Rules rules(options.ruleFile);
ae160384
TM
62 rules.load();
63
1a688729 64 int min_rev = options.options.value("resume-from").toInt();
61ae76bd 65 int max_rev = options.options.value("max-rev").toInt();
1a688729
TM
66 if (min_rev < 1)
67 min_rev = 1;
68
ae160384
TM
69 // create the repository list
70 QHash<QString, Repository *> repositories;
1a688729
TM
71 foreach (Rules::Repository rule, rules.repositories()) {
72 Repository *repo = new Repository(rule);
73 if (min_rev > 1)
74 repo->reloadBranches();
75 repositories.insert(rule.name, repo);
76 }
ae160384 77
695ab9ee 78 Svn::initialize();
1228bd7c 79 Svn svn(options.pathToRepository);
695ab9ee
TM
80 svn.setMatchRules(rules.matchRules());
81 svn.setRepositories(repositories);
bb416d33 82 svn.setIdentityMap(loadIdentityMapFile(options.options.value("identity-map")));
695ab9ee 83
61ae76bd
TM
84 if (max_rev < 1)
85 max_rev = svn.youngestRevision();
1a688729 86 for (int i = min_rev; i <= max_rev; ++i)
ab162d73
TM
87 if (!svn.exportRevision(i))
88 break;
695ab9ee
TM
89
90 qDeleteAll(repositories);
ae160384
TM
91 // success
92 return 0;
93}
This page took 0.053825 seconds and 5 git commands to generate.