From a85ac9698a77da1cd446e7d91010ebe62cbc5f76 Mon Sep 17 00:00:00 2001 From: Torgny Nyblom Date: Tue, 28 Sep 2010 20:40:05 +0200 Subject: Unify debug messages and Match structs --- src/svn.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/svn.cpp') diff --git a/src/svn.cpp b/src/svn.cpp index dd3ce53..7298e08 100644 --- a/src/svn.cpp +++ b/src/svn.cpp @@ -584,17 +584,17 @@ int SvnRevision::exportDispatch(const char *key, const svn_fs_path_change_t *cha case Rules::Match::Recurse: if(ruledebug) - qDebug() << "rev" << revnum << qPrintable(current) << "matched rule:" << rule.lineNumber << "(" << rule.rx.pattern() << ")" << " " << "recursing."; + qDebug() << "rev" << revnum << qPrintable(current) << "matched rule:" << rule.info() << " " << "recursing."; return recurse(key, change, path_from, rev_from, changes, pool); case Rules::Match::Export: if(ruledebug) - qDebug() << "rev" << revnum << qPrintable(current) << "matched rule:" << rule.lineNumber << "(" << rule.rx.pattern() << ")" << " " << "exporting."; + qDebug() << "rev" << revnum << qPrintable(current) << "matched rule:" << rule.info() << " " << "exporting."; if (exportInternal(key, change, path_from, rev_from, current, rule) == EXIT_SUCCESS) return EXIT_SUCCESS; if (change->change_kind != svn_fs_path_change_delete) { if(ruledebug) - qDebug() << "rev" << revnum << qPrintable(current) << "matched rule:" << rule.lineNumber << "(" << rule.rx.pattern() << ")" << " " << "Unable to export non path removal."; + qDebug() << "rev" << revnum << qPrintable(current) << "matched rule:" << rule.info() << " " << "Unable to export non path removal."; return EXIT_FAILURE; } // we know that the default action inside recurse is to recurse further or to ignore, -- cgit v1.2.1 From a741bdb1913c28a320ff0e01518e4d39ed430289 Mon Sep 17 00:00:00 2001 From: Torgny Nyblom Date: Wed, 29 Sep 2010 19:53:24 +0200 Subject: Allow more then one rule file to be used in a single run. --- src/svn.cpp | 72 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 30 deletions(-) (limited to 'src/svn.cpp') diff --git a/src/svn.cpp b/src/svn.cpp index 7298e08..c9b0f81 100644 --- a/src/svn.cpp +++ b/src/svn.cpp @@ -74,7 +74,7 @@ public: class SvnPrivate { public: - MatchRuleList matchRules; + QList allMatchRules; RepositoryHash repositories; IdentityHash identities; @@ -113,9 +113,9 @@ Svn::~Svn() delete d; } -void Svn::setMatchRules(const MatchRuleList &matchRules) +void Svn::setMatchRules(const QList &allMatchRules) { - d->matchRules = matchRules; + d->allMatchRules = allMatchRules; } void Svn::setRepositories(const RepositoryHash &repositories) @@ -370,7 +370,7 @@ class SvnRevision public: AprAutoPool pool; QHash transactions; - MatchRuleList matchRules; + QList allMatchRules; RepositoryHash repositories; IdentityHash identities; @@ -404,19 +404,19 @@ public: int exportDispatch(const char *path, const svn_fs_path_change_t *change, const char *path_from, svn_revnum_t rev_from, apr_hash_t *changes, const QString ¤t, const Rules::Match &rule, - apr_pool_t *pool); + const MatchRuleList &matchRules, apr_pool_t *pool); int exportInternal(const char *path, const svn_fs_path_change_t *change, const char *path_from, svn_revnum_t rev_from, - const QString ¤t, const Rules::Match &rule); + const QString ¤t, const Rules::Match &rule, const MatchRuleList &matchRules); int recurse(const char *path, const svn_fs_path_change_t *change, - const char *path_from, svn_revnum_t rev_from, + const char *path_from, const MatchRuleList &matchRules, svn_revnum_t rev_from, apr_hash_t *changes, apr_pool_t *pool); }; int SvnPrivate::exportRevision(int revnum) { SvnRevision rev(revnum, fs, global_pool); - rev.matchRules = matchRules; + rev.allMatchRules = allMatchRules; rev.repositories = repositories; rev.identities = identities; @@ -544,20 +544,33 @@ int SvnRevision::exportEntry(const char *key, const svn_fs_path_change_t *change if (is_dir) current += '/'; - // find the first rule that matches this pathname - MatchRuleList::ConstIterator match = findMatchRule(matchRules, revnum, current); - if (match != matchRules.constEnd()) { - const Rules::Match &rule = *match; - return exportDispatch(key, change, path_from, rev_from, changes, current, rule, revpool); + //MultiRule: loop start + //Replace all returns with continue, + bool isHandled = false; + foreach ( const MatchRuleList matchRules, allMatchRules ) { + // find the first rule that matches this pathname + MatchRuleList::ConstIterator match = findMatchRule(matchRules, revnum, current); + if (match != matchRules.constEnd()) { + const Rules::Match &rule = *match; + if ( exportDispatch(key, change, path_from, rev_from, changes, current, rule, matchRules, revpool) == EXIT_FAILURE ) + return EXIT_FAILURE; + isHandled = true; + } else if (is_dir && path_from != NULL) { + qDebug() << current << "is a copy-with-history, auto-recursing"; + if ( recurse(key, change, path_from, matchRules, rev_from, changes, revpool) == EXIT_FAILURE ) + return EXIT_FAILURE; + isHandled = true; + } else if (is_dir && change->change_kind == svn_fs_path_change_delete) { + qDebug() << current << "deleted, auto-recursing"; + if ( recurse(key, change, path_from, matchRules, rev_from, changes, revpool) == EXIT_FAILURE ) + return EXIT_FAILURE; + isHandled = true; + } } - - if (is_dir && path_from != NULL) { - qDebug() << current << "is a copy-with-history, auto-recursing"; - return recurse(key, change, path_from, rev_from, changes, revpool); - } else if (is_dir && change->change_kind == svn_fs_path_change_delete) { - qDebug() << current << "deleted, auto-recursing"; - return recurse(key, change, path_from, rev_from, changes, revpool); - } else if (wasDir(fs, revnum - 1, key, revpool)) { + if ( isHandled ) { + return EXIT_SUCCESS; + } + if (wasDir(fs, revnum - 1, key, revpool)) { qDebug() << current << "was a directory; ignoring"; } else if (change->change_kind == svn_fs_path_change_delete) { qDebug() << current << "is being deleted but I don't know anything about it; ignoring"; @@ -565,14 +578,13 @@ int SvnRevision::exportEntry(const char *key, const svn_fs_path_change_t *change qCritical() << current << "did not match any rules; cannot continue"; return EXIT_FAILURE; } - return EXIT_SUCCESS; } int SvnRevision::exportDispatch(const char *key, const svn_fs_path_change_t *change, const char *path_from, svn_revnum_t rev_from, apr_hash_t *changes, const QString ¤t, - const Rules::Match &rule, apr_pool_t *pool) + const Rules::Match &rule, const MatchRuleList &matchRules, apr_pool_t *pool) { //if(ruledebug) // qDebug() << "rev" << revnum << qPrintable(current) << "matched rule:" << rule.lineNumber << "(" << rule.rx.pattern() << ")"; @@ -585,12 +597,12 @@ int SvnRevision::exportDispatch(const char *key, const svn_fs_path_change_t *cha case Rules::Match::Recurse: if(ruledebug) qDebug() << "rev" << revnum << qPrintable(current) << "matched rule:" << rule.info() << " " << "recursing."; - return recurse(key, change, path_from, rev_from, changes, pool); + return recurse(key, change, path_from, matchRules, rev_from, changes, pool); case Rules::Match::Export: if(ruledebug) qDebug() << "rev" << revnum << qPrintable(current) << "matched rule:" << rule.info() << " " << "exporting."; - if (exportInternal(key, change, path_from, rev_from, current, rule) == EXIT_SUCCESS) + if (exportInternal(key, change, path_from, rev_from, current, rule, matchRules) == EXIT_SUCCESS) return EXIT_SUCCESS; if (change->change_kind != svn_fs_path_change_delete) { if(ruledebug) @@ -600,7 +612,7 @@ int SvnRevision::exportDispatch(const char *key, const svn_fs_path_change_t *cha // we know that the default action inside recurse is to recurse further or to ignore, // either of which is reasonably safe for deletion qWarning() << "deleting unknown path" << current << "; auto-recursing"; - return recurse(key, change, path_from, rev_from, changes, pool); + return recurse(key, change, path_from, matchRules, rev_from, changes, pool); } // never reached @@ -609,7 +621,7 @@ int SvnRevision::exportDispatch(const char *key, const svn_fs_path_change_t *cha int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *change, const char *path_from, svn_revnum_t rev_from, - const QString ¤t, const Rules::Match &rule) + const QString ¤t, const Rules::Match &rule, const MatchRuleList &matchRules) { QString svnprefix, repository, branch, path; splitPathName(rule, current, &svnprefix, &repository, &branch, &path); @@ -746,7 +758,7 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *cha } int SvnRevision::recurse(const char *path, const svn_fs_path_change_t *change, - const char *path_from, svn_revnum_t rev_from, + const char *path_from, const MatchRuleList &matchRules, svn_revnum_t rev_from, apr_hash_t *changes, apr_pool_t *pool) { svn_fs_root_t *fs_root = this->fs_root; @@ -797,13 +809,13 @@ int SvnRevision::recurse(const char *path, const svn_fs_path_change_t *change, MatchRuleList::ConstIterator match = findMatchRule(matchRules, revnum, current); if (match != matchRules.constEnd()) { if (exportDispatch(entry, change, entryFrom.isNull() ? 0 : entryFrom.constData(), - rev_from, changes, current, *match, dirpool) == EXIT_FAILURE) + rev_from, changes, current, *match, matchRules, dirpool) == EXIT_FAILURE) return EXIT_FAILURE; } else { qDebug() << current << "rev" << revnum << "did not match any rules; auto-recursing"; if (recurse(entry, change, entryFrom.isNull() ? 0 : entryFrom.constData(), - rev_from, changes, dirpool) == EXIT_FAILURE) + matchRules, rev_from, changes, dirpool) == EXIT_FAILURE) return EXIT_FAILURE; } } -- cgit v1.2.1