diff options
author | Torgny Nyblom <kde@nyblom.org> | 2010-09-28 20:40:05 +0200 |
---|---|---|
committer | Torgny Nyblom <kde@nyblom.org> | 2010-09-28 20:40:05 +0200 |
commit | a85ac9698a77da1cd446e7d91010ebe62cbc5f76 (patch) | |
tree | bb8cc67898bb78e906a595dc79497816d3bb153f | |
parent | f11207edc33ccaf91b28fb86b135fa42cd5cf46b (diff) | |
download | svn2git-a85ac9698a77da1cd446e7d91010ebe62cbc5f76.tar svn2git-a85ac9698a77da1cd446e7d91010ebe62cbc5f76.tar.gz svn2git-a85ac9698a77da1cd446e7d91010ebe62cbc5f76.tar.bz2 svn2git-a85ac9698a77da1cd446e7d91010ebe62cbc5f76.tar.xz svn2git-a85ac9698a77da1cd446e7d91010ebe62cbc5f76.zip |
Unify debug messages and Match structs
-rw-r--r-- | src/repository.cpp | 2 | ||||
-rw-r--r-- | src/ruleparser.cpp | 4 | ||||
-rw-r--r-- | src/ruleparser.h | 26 | ||||
-rw-r--r-- | src/svn.cpp | 6 |
4 files changed, 27 insertions, 11 deletions
diff --git a/src/repository.cpp b/src/repository.cpp index d4cb2ad..2a2b436 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -275,7 +275,7 @@ Repository *makeRepository(const Rules::Repository &rule, const QHash<QString, R return new FastImportRepository(rule); Repository *r = repositories[rule.forwardTo]; if (!r) { - qCritical() << "no repository with name" << rule.forwardTo << "found at line" << rule.lineNumber; + qCritical() << "no repository with name" << rule.forwardTo << "found at" << rule.info(); return r; } return new PrefixingRepository(r, rule.prefix); diff --git a/src/ruleparser.cpp b/src/ruleparser.cpp index 10a22ac..5927c5a 100644 --- a/src/ruleparser.cpp +++ b/src/ruleparser.cpp @@ -187,12 +187,14 @@ void Rules::load() repo = Repository(); // clear repo.name = repoLine.cap(1); repo.lineNumber = lineNumber; + repo.filename = filename; } else if (isMatchRule) { // match rule state = ReadingMatch; match = Match(); match.rx = QRegExp(matchLine.cap(1), Qt::CaseSensitive, QRegExp::RegExp2); match.lineNumber = lineNumber; + match.filename = filename; } else if (isVariableRule) { QString variable = declareLine.cap(1); QString value = declareLine.cap(2); @@ -207,7 +209,7 @@ void Rules::load() #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug s, const Rules::Match &rule) { - s.nospace() << rule.rx.pattern() << " (line " << rule.lineNumber << ")"; + s.nospace() << rule.info(); return s.space(); } diff --git a/src/ruleparser.h b/src/ruleparser.h index afd1db2..e5cbaea 100644 --- a/src/ruleparser.h +++ b/src/ruleparser.h @@ -22,11 +22,18 @@ #include <QRegExp> #include <QString> #include <QStringList> +#include <QStringBuilder> class Rules { public: - struct Repository + struct Rule + { + QString filename; + int lineNumber; + Rule() : lineNumber(0) {} + }; + struct Repository : Rule { struct Branch { @@ -35,15 +42,19 @@ public: QString name; QList<Branch> branches; - int lineNumber; QString forwardTo; QString prefix; - Repository() : lineNumber(0) { } + Repository() { } + const QString info() const { + const QString info = Rule::filename % ":" % QByteArray::number(Rule::lineNumber); + return info; + } + }; - struct Match + struct Match : Rule { QRegExp rx; QString repository; @@ -51,7 +62,6 @@ public: QString prefix; int minRevision; int maxRevision; - int lineNumber; bool annotate; enum Action { @@ -60,7 +70,11 @@ public: Recurse } action; - Match() : minRevision(-1), maxRevision(-1), lineNumber(0), annotate(false), action(Ignore) { } + Match() : minRevision(-1), maxRevision(-1), annotate(false), action(Ignore) { } + const QString info() const { + const QString info = rx.pattern() % " (" % Rule::filename % ":" % QByteArray::number(Rule::lineNumber) % ")"; + return info; + } }; Rules(const QString &filename); 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, |