- QString svnprefix = current;
- svnprefix.truncate(rule.rx.matchedLength());
-
- QString repository = svnprefix;
- QString branch = svnprefix;
- QString path = current.mid(rule.rx.matchedLength());
-
- // do the replacement
- repository.replace(rule.rx, rule.repository);
- branch.replace(rule.rx, rule.branch);
+ QString svnprefix, repository, branch, path;
+ splitPathName(rule, current, &svnprefix, &repository, &branch, &path);
+
+ if (path.isEmpty() && path_from != NULL) {
+ QString previous = QString::fromUtf8(path_from) + '/';
+ MatchRuleList::ConstIterator prevmatch =
+ findMatchRule(matchRules, rev_from, previous);
+ if (prevmatch != matchRules.constEnd()) {
+ QString prevsvnprefix, prevrepository, prevbranch, prevpath;
+ splitPathName(*prevmatch, previous, &prevsvnprefix, &prevrepository,
+ &prevbranch, &prevpath);
+
+ if (!prevpath.isEmpty()) {
+ qDebug() << qPrintable(current) << "is a partial branch of repository"
+ << qPrintable(prevrepository) << "branch"
+ << qPrintable(prevbranch) << "subdir"
+ << qPrintable(prevpath);
+ } else if (prevrepository != repository) {
+ qWarning() << qPrintable(current) << "rev" << revnum
+ << "is a cross-repository copy (from repository"
+ << qPrintable(prevrepository) << "branch"
+ << qPrintable(prevbranch) << "path"
+ << qPrintable(prevpath) << "rev" << rev_from << ")";
+ } else if (prevbranch == branch) {
+ // same branch and same repository
+ qDebug() << qPrintable(current) << "rev" << revnum
+ << "is an SVN rename from"
+ << qPrintable(previous) << "rev" << rev_from;
+ continue;
+ } else {
+ // same repository but not same branch
+ // this means this is a plain branch
+ qDebug() << qPrintable(repository) << ": branch"
+ << qPrintable(branch) << "is branching from"
+ << qPrintable(prevbranch);
+
+ Repository *repo = repositories.value(repository, 0);
+ if (!repo) {
+ qCritical() << "Rule" << rule.rx.pattern() << "line" << rule.lineNumber
+ << "references unknown repository" << repository;
+ return EXIT_FAILURE;
+ }
+
+ repo->createBranch(branch, revnum, prevbranch, rev_from);
+ }
+ }
+ }