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/repository.cpp | 2 +- src/ruleparser.cpp | 4 +++- src/ruleparser.h | 26 ++++++++++++++++++++------ 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 #include #include +#include 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 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, -- cgit v1.2.1