]> andersk Git - svn-all-fast-export.git/blame - src/svn.cpp
Reintroduce the recurse rule. It's useful if you have a catch-all ignore rule.
[svn-all-fast-export.git] / src / svn.cpp
CommitLineData
d3e9398d
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
af010386
TM
18/*
19 * Based on svn-fast-export by Chris Lee <clee@kde.org>
20 * License: MIT <http://www.opensource.org/licenses/mit-license.php>
21 * URL: git://repo.or.cz/fast-import.git http://repo.or.cz/w/fast-export.git
22 */
23
24#define _XOPEN_SOURCE
25#define _LARGEFILE_SUPPORT
26#define _LARGEFILE64_SUPPORT
27
d3e9398d 28#include "svn.h"
af010386
TM
29
30#include <unistd.h>
31#include <string.h>
32#include <stdio.h>
33#include <time.h>
34#include <unistd.h>
35
36#include <apr_lib.h>
37#include <apr_getopt.h>
38#include <apr_general.h>
39
40#include <svn_fs.h>
41#include <svn_pools.h>
42#include <svn_repos.h>
43#include <svn_types.h>
44
45#include <QFile>
46#include <QDebug>
47
d3e9398d
TM
48#include "repository.h"
49
af010386
TM
50#undef SVN_ERR
51#define SVN_ERR(expr) SVN_INT_ERR(expr)
52
d3e9398d
TM
53typedef QList<Rules::Match> MatchRuleList;
54typedef QHash<QString, Repository *> RepositoryHash;
af010386
TM
55typedef QHash<QByteArray, QByteArray> IdentityHash;
56
57class AprAutoPool
58{
59 apr_pool_t *pool;
b6ba9639
TM
60 AprAutoPool(const AprAutoPool &);
61 AprAutoPool &operator=(const AprAutoPool &);
af010386
TM
62public:
63 inline AprAutoPool(apr_pool_t *parent = NULL)
64 { pool = svn_pool_create(parent); }
65 inline ~AprAutoPool()
66 { svn_pool_destroy(pool); }
67
b6ba9639 68 inline void clear() { svn_pool_clear(pool); }
af010386
TM
69 inline apr_pool_t *data() const { return pool; }
70 inline operator apr_pool_t *() const { return pool; }
71};
d3e9398d
TM
72
73class SvnPrivate
74{
75public:
af010386
TM
76 MatchRuleList matchRules;
77 RepositoryHash repositories;
78 IdentityHash identities;
79
d3e9398d
TM
80 SvnPrivate(const QString &pathToRepository);
81 ~SvnPrivate();
82 int youngestRevision();
af010386 83 int exportRevision(int revnum);
d3e9398d 84
af010386
TM
85 int openRepository(const QString &pathToRepository);
86
87private:
88 AprAutoPool global_pool;
89 svn_fs_t *fs;
90 svn_revnum_t youngest_rev;
d3e9398d
TM
91};
92
93void Svn::initialize()
94{
af010386
TM
95 // initialize APR or exit
96 if (apr_initialize() != APR_SUCCESS) {
97 fprintf(stderr, "You lose at apr_initialize().\n");
98 exit(1);
99 }
100
101 // static destructor
102 static struct Destructor { ~Destructor() { apr_terminate(); } } destructor;
d3e9398d
TM
103}
104
105Svn::Svn(const QString &pathToRepository)
106 : d(new SvnPrivate(pathToRepository))
107{
108}
109
110Svn::~Svn()
111{
112 delete d;
113}
114
115void Svn::setMatchRules(const MatchRuleList &matchRules)
116{
117 d->matchRules = matchRules;
118}
119
120void Svn::setRepositories(const RepositoryHash &repositories)
121{
122 d->repositories = repositories;
123}
124
125int Svn::youngestRevision()
126{
127 return d->youngestRevision();
128}
129
af010386
TM
130bool Svn::exportRevision(int revnum)
131{
132 return d->exportRevision(revnum) == EXIT_SUCCESS;
133}
134
135SvnPrivate::SvnPrivate(const QString &pathToRepository)
136 : global_pool(NULL)
137{
138 openRepository(pathToRepository);
139
140 // get the youngest revision
141 svn_fs_youngest_rev(&youngest_rev, fs, global_pool);
142}
143
144SvnPrivate::~SvnPrivate()
145{
146 svn_pool_destroy(global_pool);
147}
148
149int SvnPrivate::youngestRevision()
150{
151 return youngest_rev;
152}
153
154int SvnPrivate::openRepository(const QString &pathToRepository)
155{
156 svn_repos_t *repos;
157 SVN_ERR(svn_repos_open(&repos, QFile::encodeName(pathToRepository), global_pool));
158 fs = svn_repos_fs(repos);
159
160 return EXIT_SUCCESS;
161}
162
16024419 163enum RuleType { AnyRule = 0, NoIgnoreRule = 0x01 };
97b52f78 164
f97a8dff 165static MatchRuleList::ConstIterator
97b52f78
TM
166findMatchRule(const MatchRuleList &matchRules, int revnum, const QString &current,
167 int ruleMask = AnyRule)
f97a8dff
TM
168{
169 MatchRuleList::ConstIterator it = matchRules.constBegin(),
170 end = matchRules.constEnd();
171 for ( ; it != end; ++it) {
172 if (it->minRevision > revnum)
173 continue;
174 if (it->maxRevision != -1 && it->maxRevision < revnum)
175 continue;
97b52f78
TM
176 if (it->action == Rules::Match::Ignore && ruleMask & NoIgnoreRule)
177 continue;
f97a8dff
TM
178 if (it->rx.indexIn(current) == 0)
179 return it;
180 }
181
182 // no match
183 return end;
184}
185
c338ae37
TM
186static void splitPathName(const Rules::Match &rule, const QString &pathName, QString *svnprefix_p,
187 QString *repository_p, QString *branch_p, QString *path_p)
188{
189 QString svnprefix = pathName;
190 svnprefix.truncate(rule.rx.matchedLength());
191 if (svnprefix_p)
192 *svnprefix_p = svnprefix;
193
194 if (repository_p) {
195 *repository_p = svnprefix;
196 repository_p->replace(rule.rx, rule.repository);
197 }
198
199 if (branch_p) {
200 *branch_p = svnprefix;
201 branch_p->replace(rule.rx, rule.branch);
202 }
203
204 if (path_p)
205 *path_p = pathName.mid(svnprefix.length());
206}
f97a8dff 207
af010386
TM
208static int pathMode(svn_fs_root_t *fs_root, const char *pathname, apr_pool_t *pool)
209{
210 svn_string_t *propvalue;
211 SVN_ERR(svn_fs_node_prop(&propvalue, fs_root, pathname, "svn:executable", pool));
212 int mode = 0100644;
213 if (propvalue)
214 mode = 0100755;
215
216 // maybe it's a symlink?
217 SVN_ERR(svn_fs_node_prop(&propvalue, fs_root, pathname, "svn:special", pool));
b6ba9639 218 if (propvalue && strcmp(propvalue->data, "symlink") == 0)
af010386
TM
219 mode = 0120000;
220
221 return mode;
222}
223
224svn_error_t *QIODevice_write(void *baton, const char *data, apr_size_t *len)
d3e9398d 225{
af010386
TM
226 QIODevice *device = reinterpret_cast<QIODevice *>(baton);
227 device->write(data, *len);
9c31646c
TM
228
229 if (device->bytesToWrite() > 16384)
230 device->waitForBytesWritten(0);
af010386 231 return SVN_NO_ERROR;
d3e9398d
TM
232}
233
af010386
TM
234static svn_stream_t *streamForDevice(QIODevice *device, apr_pool_t *pool)
235{
236 svn_stream_t *stream = svn_stream_create(device, pool);
237 svn_stream_set_write(stream, QIODevice_write);
238
239 return stream;
240}
241
242static int dumpBlob(Repository::Transaction *txn, svn_fs_root_t *fs_root,
b6ba9639 243 const char *pathname, const QString &finalPathName, apr_pool_t *pool)
af010386 244{
898704e4 245 AprAutoPool dumppool(pool);
af010386 246 // what type is it?
898704e4 247 int mode = pathMode(fs_root, pathname, dumppool);
af010386 248
af010386
TM
249 svn_filesize_t stream_length;
250
898704e4 251 SVN_ERR(svn_fs_file_length(&stream_length, fs_root, pathname, dumppool));
b6ba9639 252 QIODevice *io = txn->addFile(finalPathName, mode, stream_length);
af010386 253
688d69ec 254#ifndef DRY_RUN
af010386 255 // open the file
688d69ec 256 svn_stream_t *in_stream, *out_stream;
898704e4 257 SVN_ERR(svn_fs_file_contents(&in_stream, fs_root, pathname, dumppool));
af010386
TM
258
259 // open a generic svn_stream_t for the QIODevice
898704e4
TM
260 out_stream = streamForDevice(io, dumppool);
261 SVN_ERR(svn_stream_copy(in_stream, out_stream, dumppool));
af010386 262
9c31646c
TM
263 // print an ending newline
264 io->putChar('\n');
688d69ec 265#endif
9c31646c 266
af010386
TM
267 return EXIT_SUCCESS;
268}
269
14ddd2a5
TM
270static int recursiveDumpDir(Repository::Transaction *txn, svn_fs_root_t *fs_root,
271 const QByteArray &pathname, const QString &finalPathName,
272 apr_pool_t *pool)
273{
274 // get the dir listing
275 apr_hash_t *entries;
276 SVN_ERR(svn_fs_dir_entries(&entries, fs_root, pathname, pool));
277 AprAutoPool dirpool(pool);
278
279 for (apr_hash_index_t *i = apr_hash_first(pool, entries); i; i = apr_hash_next(i)) {
280 dirpool.clear();
281 const void *vkey;
282 void *value;
283 apr_hash_this(i, &vkey, NULL, &value);
284
285 svn_fs_dirent_t *dirent = reinterpret_cast<svn_fs_dirent_t *>(value);
286 QByteArray entryName = pathname + '/' + dirent->name;
5871af71 287 QString entryFinalName = finalPathName + dirent->name;
14ddd2a5
TM
288
289 if (dirent->kind == svn_node_dir) {
5871af71 290 entryFinalName += '/';
14ddd2a5
TM
291 if (recursiveDumpDir(txn, fs_root, entryName, entryFinalName, dirpool) == EXIT_FAILURE)
292 return EXIT_FAILURE;
293 } else if (dirent->kind == svn_node_file) {
c338ae37
TM
294 printf("+");
295 fflush(stdout);
14ddd2a5
TM
296 if (dumpBlob(txn, fs_root, entryName, entryFinalName, dirpool) == EXIT_FAILURE)
297 return EXIT_FAILURE;
298 }
299 }
898704e4
TM
300
301 return EXIT_SUCCESS;
14ddd2a5
TM
302}
303
5539acb4
TM
304static bool wasDir(svn_fs_t *fs, int revnum, const char *pathname, apr_pool_t *pool)
305{
306 AprAutoPool subpool(pool);
307 svn_fs_root_t *fs_root;
308 if (svn_fs_revision_root(&fs_root, fs, revnum, subpool) != SVN_NO_ERROR)
309 return false;
310
311 svn_boolean_t is_dir;
312 if (svn_fs_is_dir(&is_dir, fs_root, pathname, subpool) != SVN_NO_ERROR)
313 return false;
314
315 return is_dir;
316}
317
af010386
TM
318time_t get_epoch(char *svn_date)
319{
320 struct tm tm;
321 memset(&tm, 0, sizeof tm);
322 QByteArray date(svn_date, strlen(svn_date) - 8);
323 strptime(date, "%Y-%m-%dT%H:%M:%S", &tm);
324 return mktime(&tm);
325}
326
898704e4 327class SvnRevision
af010386 328{
898704e4
TM
329public:
330 AprAutoPool pool;
f97a8dff 331 QHash<QString, Repository::Transaction *> transactions;
898704e4
TM
332 MatchRuleList matchRules;
333 RepositoryHash repositories;
334 IdentityHash identities;
335
336 svn_fs_t *fs;
337 svn_fs_root_t *fs_root;
338 int revnum;
339
340 SvnRevision(int revision, svn_fs_t *f, apr_pool_t *parent_pool)
341 : pool(parent_pool), fs(f), fs_root(0), revnum(revision)
342 {
343 }
344
345 int open()
346 {
347 SVN_ERR(svn_fs_revision_root(&fs_root, fs, revnum, pool));
348 return EXIT_SUCCESS;
349 }
350
351 int prepareTransactions();
352 int commit();
353
8ca4b631 354 int exportEntry(const char *path, const svn_fs_path_change_t *change, apr_hash_t *changes);
b4cb5188
TM
355 int exportDispatch(const char *path, const svn_fs_path_change_t *change,
356 const char *path_from, svn_revnum_t rev_from,
357 apr_hash_t *changes, const QString &current, const Rules::Match &rule,
358 apr_pool_t *pool);
898704e4
TM
359 int exportInternal(const char *path, const svn_fs_path_change_t *change,
360 const char *path_from, svn_revnum_t rev_from,
361 const QString &current, const Rules::Match &rule);
362 int recurse(const char *path, const svn_fs_path_change_t *change,
8ca4b631
TM
363 const char *path_from, svn_revnum_t rev_from,
364 apr_hash_t *changes, apr_pool_t *pool);
898704e4
TM
365};
366
367int SvnPrivate::exportRevision(int revnum)
368{
369 SvnRevision rev(revnum, fs, global_pool);
370 rev.matchRules = matchRules;
371 rev.repositories = repositories;
372 rev.identities = identities;
af010386
TM
373
374 // open this revision:
dcbaff44
TM
375 printf("Exporting revision %d ", revnum);
376 fflush(stdout);
af010386 377
898704e4
TM
378 if (rev.open() == EXIT_FAILURE)
379 return EXIT_FAILURE;
380
381 if (rev.prepareTransactions() == EXIT_FAILURE)
382 return EXIT_FAILURE;
383
384 if (rev.transactions.isEmpty()) {
385 printf(" nothing to do\n");
386 return EXIT_SUCCESS; // no changes?
387 }
388
389 if (rev.commit() == EXIT_FAILURE)
390 return EXIT_FAILURE;
391
392 printf(" done\n");
393 return EXIT_SUCCESS;
394}
395
396int SvnRevision::prepareTransactions()
397{
af010386 398 // find out what was changed in this revision:
af010386
TM
399 apr_hash_t *changes;
400 SVN_ERR(svn_fs_paths_changed(&changes, fs_root, pool));
af010386 401 for (apr_hash_index_t *i = apr_hash_first(pool, changes); i; i = apr_hash_next(i)) {
af010386
TM
402 const void *vkey;
403 void *value;
404 apr_hash_this(i, &vkey, NULL, &value);
405 const char *key = reinterpret_cast<const char *>(vkey);
7a6160e7 406 svn_fs_path_change_t *change = reinterpret_cast<svn_fs_path_change_t *>(value);
af010386 407
8ca4b631 408 if (exportEntry(key, change, changes) == EXIT_FAILURE)
c338ae37 409 return EXIT_FAILURE;
af010386 410 }
af010386 411
898704e4
TM
412 return EXIT_SUCCESS;
413}
af010386 414
898704e4
TM
415int SvnRevision::commit()
416{
af010386
TM
417 // now create the commit
418 apr_hash_t *revprops;
419 SVN_ERR(svn_fs_revision_proplist(&revprops, fs, revnum, pool));
420 svn_string_t *svnauthor = (svn_string_t*)apr_hash_get(revprops, "svn:author", APR_HASH_KEY_STRING);
421 svn_string_t *svndate = (svn_string_t*)apr_hash_get(revprops, "svn:date", APR_HASH_KEY_STRING);
422 svn_string_t *svnlog = (svn_string_t*)apr_hash_get(revprops, "svn:log", APR_HASH_KEY_STRING);
423
424 QByteArray log = (char *)svnlog->data;
453ea6b6 425 QByteArray authorident = svnauthor ? identities.value((char *)svnauthor->data) : QByteArray();
af010386
TM
426 time_t epoch = get_epoch((char*)svndate->data);
427 if (authorident.isEmpty()) {
428 if (!svnauthor || svn_string_isempty(svnauthor))
429 authorident = "nobody <nobody@localhost>";
430 else
431 authorident = svnauthor->data + QByteArray(" <") +
432 svnauthor->data + QByteArray("@localhost>");
433 }
434
435 foreach (Repository::Transaction *txn, transactions) {
436 txn->setAuthor(authorident);
437 txn->setDateTime(epoch);
438 txn->setLog(log);
439
440 txn->commit();
441 delete txn;
442 }
443
444 return EXIT_SUCCESS;
445}
898704e4 446
8ca4b631
TM
447int SvnRevision::exportEntry(const char *key, const svn_fs_path_change_t *change,
448 apr_hash_t *changes)
898704e4
TM
449{
450 AprAutoPool revpool(pool.data());
451 QString current = QString::fromUtf8(key);
452
453 // was this copied from somewhere?
454 svn_revnum_t rev_from;
455 const char *path_from;
456 SVN_ERR(svn_fs_copied_from(&rev_from, &path_from, fs_root, key, revpool));
457
458 // is this a directory?
459 svn_boolean_t is_dir;
295db4b2 460 SVN_ERR(svn_fs_is_dir(&is_dir, fs_root, key, revpool));
898704e4
TM
461 if (is_dir) {
462 if (path_from == NULL) {
463 // no, it's a new directory being added
464 // Git doesn't handle directories, so we don't either
465 //qDebug() << " mkdir ignored:" << key;
466 return EXIT_SUCCESS;
467 }
468
469 current += '/';
470 qDebug() << " " << key << "was copied from" << path_from;
471 }
472
473 // find the first rule that matches this pathname
474 MatchRuleList::ConstIterator match = findMatchRule(matchRules, revnum, current);
475 if (match != matchRules.constEnd()) {
476 const Rules::Match &rule = *match;
b4cb5188 477 return exportDispatch(key, change, path_from, rev_from, changes, current, rule, revpool);
898704e4
TM
478 }
479
6b450d1d
TM
480 if (is_dir && path_from != NULL) {
481 qDebug() << current << "is a copy-with-history, auto-recursing";
8ca4b631 482 return recurse(key, change, path_from, rev_from, changes, revpool);
6b450d1d 483 } else if (wasDir(fs, revnum - 1, key, revpool)) {
898704e4
TM
484 qDebug() << current << "was a directory; ignoring";
485 } else if (change->change_kind == svn_fs_path_change_delete) {
486 qDebug() << current << "is being deleted but I don't know anything about it; ignoring";
487 } else {
488 qCritical() << current << "did not match any rules; cannot continue";
489 return EXIT_FAILURE;
490 }
491
492 return EXIT_SUCCESS;
493}
494
b4cb5188 495int SvnRevision::exportDispatch(const char *key, const svn_fs_path_change_t *change,
898704e4 496 const char *path_from, svn_revnum_t rev_from,
b4cb5188
TM
497 apr_hash_t *changes, const QString &current,
498 const Rules::Match &rule, apr_pool_t *pool)
898704e4 499{
b4cb5188
TM
500 switch (rule.action) {
501 case Rules::Match::Ignore:
16024419
TM
502 // ignore rule
503 qDebug() << " " << qPrintable(current) << "rev" << revnum
504 << "-> ignored (rule" << rule << ")";
505 return EXIT_SUCCESS;
b4cb5188
TM
506
507 case Rules::Match::Recurse:
508 return recurse(key, change, path_from, rev_from, changes, pool);
509
510 case Rules::Match::Export:
511 return exportInternal(key, change, path_from, rev_from, current, rule);
16024419 512 }
b4cb5188 513}
16024419 514
b4cb5188
TM
515int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *change,
516 const char *path_from, svn_revnum_t rev_from,
517 const QString &current, const Rules::Match &rule)
518{
898704e4
TM
519 QString svnprefix, repository, branch, path;
520 splitPathName(rule, current, &svnprefix, &repository, &branch, &path);
521
522 printf(".");
523 fflush(stdout);
524// qDebug() << " " << qPrintable(current) << "rev" << revnum << "->"
525// << qPrintable(repository) << qPrintable(branch) << qPrintable(path);
526
527 if (path.isEmpty() && path_from != NULL) {
528 QString previous = QString::fromUtf8(path_from) + '/';
529 MatchRuleList::ConstIterator prevmatch =
16024419 530 findMatchRule(matchRules, rev_from, previous, NoIgnoreRule);
898704e4
TM
531 if (prevmatch != matchRules.constEnd()) {
532 QString prevsvnprefix, prevrepository, prevbranch, prevpath;
533 splitPathName(*prevmatch, previous, &prevsvnprefix, &prevrepository,
534 &prevbranch, &prevpath);
535
536 if (!prevpath.isEmpty()) {
537 qDebug() << qPrintable(current) << "is a partial branch of repository"
538 << qPrintable(prevrepository) << "branch"
539 << qPrintable(prevbranch) << "subdir"
540 << qPrintable(prevpath);
541 } else if (prevrepository != repository) {
542 qWarning() << qPrintable(current) << "rev" << revnum
543 << "is a cross-repository copy (from repository"
544 << qPrintable(prevrepository) << "branch"
545 << qPrintable(prevbranch) << "path"
546 << qPrintable(prevpath) << "rev" << rev_from << ")";
547 } else if (prevbranch == branch) {
548 // same branch and same repository
549 qDebug() << qPrintable(current) << "rev" << revnum
550 << "is an SVN rename from"
551 << qPrintable(previous) << "rev" << rev_from;
552 return EXIT_SUCCESS;
553 } else {
554 // same repository but not same branch
555 // this means this is a plain branch
556 qDebug() << qPrintable(repository) << ": branch"
557 << qPrintable(branch) << "is branching from"
558 << qPrintable(prevbranch);
559
560 Repository *repo = repositories.value(repository, 0);
561 if (!repo) {
2ddd1758 562 qCritical() << "Rule" << rule
898704e4
TM
563 << "references unknown repository" << repository;
564 return EXIT_FAILURE;
565 }
566
567 repo->createBranch(branch, revnum, prevbranch, rev_from);
844c7a90 568 return EXIT_SUCCESS;
898704e4
TM
569 }
570 }
571 }
572
b8549b90 573 Repository::Transaction *txn = transactions.value(repository + branch, 0);
898704e4
TM
574 if (!txn) {
575 Repository *repo = repositories.value(repository, 0);
576 if (!repo) {
2ddd1758 577 qCritical() << "Rule" << rule
898704e4
TM
578 << "references unknown repository" << repository;
579 return EXIT_FAILURE;
580 }
581
582 txn = repo->newTransaction(branch, svnprefix, revnum);
583 if (!txn)
584 return EXIT_FAILURE;
585
b8549b90 586 transactions.insert(repository + branch, txn);
898704e4
TM
587 }
588
6b450d1d 589 if (change->change_kind == svn_fs_path_change_delete) {
898704e4 590 txn->deleteFile(path);
6b450d1d 591 } else if (!current.endsWith('/')) {
898704e4 592 dumpBlob(txn, fs_root, key, path, pool);
6b450d1d 593 } else {
5871af71
TM
594 QString pathNoSlash = path;
595 pathNoSlash.chop(1);
596 txn->deleteFile(pathNoSlash);
898704e4 597 recursiveDumpDir(txn, fs_root, key, path, pool);
6b450d1d 598 }
898704e4
TM
599
600 return EXIT_SUCCESS;
601}
602
603int SvnRevision::recurse(const char *path, const svn_fs_path_change_t *change,
604 const char *path_from, svn_revnum_t rev_from,
8ca4b631 605 apr_hash_t *changes, apr_pool_t *pool)
898704e4
TM
606{
607 // get the dir listing
608 apr_hash_t *entries;
609 SVN_ERR(svn_fs_dir_entries(&entries, fs_root, path, pool));
610
611 AprAutoPool dirpool(pool);
612 for (apr_hash_index_t *i = apr_hash_first(pool, entries); i; i = apr_hash_next(i)) {
613 dirpool.clear();
614 const void *vkey;
615 void *value;
616 apr_hash_this(i, &vkey, NULL, &value);
617
618 svn_fs_dirent_t *dirent = reinterpret_cast<svn_fs_dirent_t *>(value);
619 QByteArray entry = path + QByteArray("/") + dirent->name;
6b450d1d
TM
620 QByteArray entryFrom;
621 if (path_from)
622 entryFrom = path_from + QByteArray("/") + dirent->name;
898704e4 623
8ca4b631
TM
624 // check if this entry is in the changelist for this revision already
625 if (apr_hash_get(changes, entry.constData(), APR_HASH_KEY_STRING)) {
626 qDebug() << entry << "rev" << revnum
627 << "is in the change-list, deferring to that one";
628 continue;
629 }
630
898704e4
TM
631 QString current = QString::fromUtf8(entry);
632 if (dirent->kind == svn_node_dir)
633 current += '/';
634
635 // find the first rule that matches this pathname
636 MatchRuleList::ConstIterator match = findMatchRule(matchRules, revnum, current);
637 if (match != matchRules.constEnd()) {
b4cb5188
TM
638 if (exportDispatch(entry, change, entryFrom.isNull() ? 0 : entryFrom.constData(),
639 rev_from, changes, current, *match, dirpool) == EXIT_FAILURE)
898704e4
TM
640 return EXIT_FAILURE;
641 } else {
d4c5541d
TM
642 qCritical() << current << "rev" << revnum
643 << "did not match any rules; cannot continue";
898704e4
TM
644 return EXIT_FAILURE;
645 }
646 }
1c5ce394
TM
647
648 return EXIT_SUCCESS;
898704e4 649}
This page took 0.144918 seconds and 5 git commands to generate.