diff options
author | Torgny Nyblom <kde@nyblom.org> | 2010-03-15 19:45:14 +0100 |
---|---|---|
committer | Torgny Nyblom <kde@nyblom.org> | 2010-03-15 19:45:14 +0100 |
commit | 8b4c690f47700ceb242b39aef2609c370c67caf9 (patch) | |
tree | da63455c57ffa87507ed63b795bf4504669e2222 /src | |
parent | d563a594cfa5f5b6d48325dd3fc48df1b34e329f (diff) | |
download | svn2git-8b4c690f47700ceb242b39aef2609c370c67caf9.tar svn2git-8b4c690f47700ceb242b39aef2609c370c67caf9.tar.gz svn2git-8b4c690f47700ceb242b39aef2609c370c67caf9.tar.bz2 svn2git-8b4c690f47700ceb242b39aef2609c370c67caf9.tar.xz svn2git-8b4c690f47700ceb242b39aef2609c370c67caf9.zip |
Add support for a new rule tag:
rootdir /a/path/
This should be the part of the match that shouldn't be included in the
commited path.
Ex:
match /trunk/kdenetwork/kmail/
rootdir /trunk/kdenetwork/
repository KDE/kdepim
branch master
end match
This would but all matched files/directories under kmail into the
repository under the subdir kmail
Diffstat (limited to 'src')
-rw-r--r-- | src/ruleparser.cpp | 4 | ||||
-rw-r--r-- | src/ruleparser.h | 1 | ||||
-rw-r--r-- | src/svn.cpp | 21 |
3 files changed, 20 insertions, 6 deletions
diff --git a/src/ruleparser.cpp b/src/ruleparser.cpp index 7f6f050..c9279ac 100644 --- a/src/ruleparser.cpp +++ b/src/ruleparser.cpp @@ -55,6 +55,7 @@ void Rules::load() QRegExp matchBranchLine("branch\\s+(\\S+)", Qt::CaseInsensitive); QRegExp matchRevLine("(min|max) revision (\\d+)", Qt::CaseInsensitive); QRegExp matchAnnotateLine("annotated\\s+(\\S+)", Qt::CaseInsensitive); + QRegExp matchRootDirLine("rootdir\\s+(\\S+)", Qt::CaseInsensitive); QTextStream s(&file); enum { ReadingNone, ReadingRepository, ReadingMatch } state = ReadingNone; @@ -98,6 +99,9 @@ void Rules::load() else // must be max match.maxRevision = matchRevLine.cap(2).toInt(); continue; + } else if (matchRootDirLine.exactMatch(line)) { + match.rootdir = QRegExp(matchRootDirLine.cap(1), Qt::CaseSensitive, QRegExp::RegExp2); + continue; } else if (matchActionLine.exactMatch(line)) { QString action = matchActionLine.cap(1); if (action == "export") diff --git a/src/ruleparser.h b/src/ruleparser.h index 54405e8..4ff77a2 100644 --- a/src/ruleparser.h +++ b/src/ruleparser.h @@ -44,6 +44,7 @@ public: QRegExp rx; QString repository; QString branch; + QRegExp rootdir; int minRevision; int maxRevision; int lineNumber; diff --git a/src/svn.cpp b/src/svn.cpp index 9cc3081..ba15a2c 100644 --- a/src/svn.cpp +++ b/src/svn.cpp @@ -186,8 +186,10 @@ findMatchRule(const MatchRuleList &matchRules, int revnum, const QString ¤ continue; if (it->action == Rules::Match::Recurse && ruleMask & NoRecurseRule) continue; - if (it->rx.indexIn(current) == 0) + if (it->rx.indexIn(current) == 0) { + it->rootdir.indexIn(current); //Force a match run return it; + } } // no match @@ -198,22 +200,29 @@ static void splitPathName(const Rules::Match &rule, const QString &pathName, QSt QString *repository_p, QString *branch_p, QString *path_p) { QString svnprefix = pathName; - svnprefix.truncate(rule.rx.matchedLength()); - if (svnprefix_p) + QString fullsvnprefix = pathName; + if( rule.rootdir.pattern().isEmpty() ) + svnprefix.truncate(rule.rx.matchedLength()); + else + svnprefix.truncate(rule.rootdir.matchedLength()); + fullsvnprefix.truncate(rule.rx.matchedLength()); + if (svnprefix_p) { *svnprefix_p = svnprefix; + } if (repository_p) { - *repository_p = svnprefix; + *repository_p = fullsvnprefix; repository_p->replace(rule.rx, rule.repository); } if (branch_p) { - *branch_p = svnprefix; + *branch_p = fullsvnprefix; branch_p->replace(rule.rx, rule.branch); } - if (path_p) + if (path_p) { *path_p = pathName.mid(svnprefix.length()); + } } static int pathMode(svn_fs_root_t *fs_root, const char *pathname, apr_pool_t *pool) |