From 2ae83eb1c5f9b4560e3fa808cb883829c7973a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 28 Sep 2010 22:01:29 +0200 Subject: Allow user-overriding of default email domain Lazy projects where svn user X has email X@project.org don't need to compile (and update) an identity-map for rolling conversions. This can be mixed with a real identity-map, so only misses in the map will have the user then show up as X@project.org Also change the defaults somewhat. I don't like the NFS reserved username nobody to show up in SVN or git logs, but am keeping that for now. --- src/main.cpp | 10 ++++++++-- src/svn.cpp | 12 ++++++++++-- src/svn.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 60c6bb8..09a4225 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -121,6 +121,7 @@ QSet loadRevisionsFile( const QString &fileName, Svn &svn ) static const CommandLineOption options[] = { {"--identity-map FILENAME", "provide map between svn username and email"}, + {"--identity-domain DOMAIN", "provide user domain if no map was given"}, {"--revisions-file FILENAME", "provide a file with revision number that should be processed"}, {"--rules FILENAME[,FILENAME]", "the rules file(s) that determines what goes where"}, {"--add-metadata", "if passed, each git commit will have svn commit info"}, @@ -172,9 +173,9 @@ int main(int argc, char **argv) out << "svn-all-fast-export failed: please specify the rules using the 'rules' argument\n"; return 11; } - if (!args->contains("identity-map")) { + if (!args->contains("identity-map") && !args->contains("identity-domain")) { QTextStream out(stderr); - out << "WARNING; no identity-map specified, all commits will be without email address\n\n"; + out << "WARNING; no identity-map or -domain specified, all commits will use default @localhost email address\n\n"; } QCoreApplication app(argc, argv); @@ -240,6 +241,11 @@ int main(int argc, char **argv) svn.setMatchRules(rulesList.allMatchRules()); svn.setRepositories(repositories); svn.setIdentityMap(loadIdentityMapFile(args->optionArgument("identity-map"))); + // Massage user input a little, no guarantees that input makes sense. + QString domain = args->optionArgument("identity-domain").simplified().remove(QChar('@')); + if (domain.isEmpty()) + domain = QString("localhost"); + svn.setIdentityDomain(domain); if (max_rev < 1) max_rev = svn.youngestRevision(); diff --git a/src/svn.cpp b/src/svn.cpp index c103728..92c8abf 100644 --- a/src/svn.cpp +++ b/src/svn.cpp @@ -79,6 +79,7 @@ public: QList allMatchRules; RepositoryHash repositories; IdentityHash identities; + QString userdomain; SvnPrivate(const QString &pathToRepository); ~SvnPrivate(); @@ -130,6 +131,11 @@ void Svn::setIdentityMap(const IdentityHash &identityMap) d->identities = identityMap; } +void Svn::setIdentityDomain(const QString &identityDomain) +{ + d->userdomain = identityDomain; +} + int Svn::youngestRevision() { return d->youngestRevision(); @@ -388,6 +394,7 @@ public: QList allMatchRules; RepositoryHash repositories; IdentityHash identities; + QString userdomain; svn_fs_t *fs; svn_fs_root_t *fs_root; @@ -436,6 +443,7 @@ int SvnPrivate::exportRevision(int revnum) rev.allMatchRules = allMatchRules; rev.repositories = repositories; rev.identities = identities; + rev.userdomain = userdomain; // open this revision: printf("Exporting revision %d ", revnum); @@ -506,8 +514,8 @@ int SvnRevision::fetchRevProps() if (!svnauthor || svn_string_isempty(svnauthor)) authorident = "nobody "; else - authorident = svnauthor->data + QByteArray(" <") + - svnauthor->data + QByteArray("@localhost>"); + authorident = svnauthor->data + QByteArray(" <") + svnauthor->data + + QByteArray("@") + userdomain.toUtf8() + QByteArray(">"); } propsFetched = true; return EXIT_SUCCESS; diff --git a/src/svn.h b/src/svn.h index 5fb3245..b0ada88 100644 --- a/src/svn.h +++ b/src/svn.h @@ -36,6 +36,7 @@ public: void setMatchRules(const QList > &matchRules); void setRepositories(const QHash &repositories); void setIdentityMap(const QHash &identityMap); + void setIdentityDomain(const QString &identityDomain); int youngestRevision(); bool exportRevision(int revnum); -- cgit v1.2.1 From 51e59b58c2deb94312a72291be0d76749010e015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sat, 12 May 2012 17:53:42 +0200 Subject: Fix timestamps of notes to adhere to git standards by using +0000 instead of -0000. --- src/repository.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/repository.cpp b/src/repository.cpp index beb8caf..25215ae 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -674,7 +674,7 @@ void Repository::Transaction::commitNote(const QByteArray ¬eText, bool append QTextStream s(&repository->fastImport); s << "commit refs/notes/commits" << endl - << "committer " << QString::fromUtf8(author) << ' ' << datetime << " -0000" << endl + << "committer " << QString::fromUtf8(author) << ' ' << datetime << " +0000" << endl << "data " << message.length() << endl << message << endl << "N inline " << commitRef << endl -- cgit v1.2.1 From c0187417902b10698135727d911ab9018f4941eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Wed, 19 Sep 2012 21:59:35 +0200 Subject: Remove the branch copy heuristic The FreeBSD project has a different approach to branches than the standard SVN or GIT models of how branches should work. An MFC from head/ to stable/8 is a cherry-pick in git and should never result in a merge commit. Sadly, this means that "IFCs" from head/ to project/foo also no longer are merge commits, though they really are ... Reported by: Ryan Stone --- src/svn.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/svn.cpp b/src/svn.cpp index 92c8abf..0c28cf2 100644 --- a/src/svn.cpp +++ b/src/svn.cpp @@ -779,18 +779,6 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *cha transactions.insert(repository + branch, txn); } - // - // If this path was copied from elsewhere, use it to infer _some_ - // merge points. This heuristic is fairly useful for tracking - // changes across directory re-organizations and wholesale branch - // imports. - // - if (path_from != NULL && prevrepository == repository && prevbranch != branch) { - if(ruledebug) - qDebug() << "copy from branch" << prevbranch << "to branch" << branch << "@rev" << rev_from; - txn->noteCopyFromBranch (prevbranch, rev_from); - } - if (change->change_kind == svn_fs_path_change_replace && path_from == NULL) { if(ruledebug) qDebug() << "replaced with empty path (" << branch << path << ")"; -- cgit v1.2.1 From 8f8d4c770ac4884dc6c7909a342b27b28f23cbd9 Mon Sep 17 00:00:00 2001 From: Daniel Hagerty Date: Sun, 7 Oct 2012 15:26:26 +0200 Subject: Set marks on notes, so fast-load picks up from previous state. This should fix the notes upon successive, incremental conversions. --- src/repository.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/repository.cpp b/src/repository.cpp index 25215ae..abd037a 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -26,7 +26,7 @@ static const int maxSimultaneousProcesses = 100; -static const int maxMark = (1 << 20) - 1; // some versions of git-fast-import are buggy for larger values of maxMark +static const int maxMark = (1 << 20) - 2; // some versions of git-fast-import are buggy for larger values of maxMark class ProcessCache: QLinkedList { @@ -271,12 +271,15 @@ void Repository::closeFastImport() void Repository::reloadBranches() { + bool reset_notes = false; foreach (QString branch, branches.keys()) { Branch &br = branches[branch]; if (br.marks.isEmpty() || !br.marks.last()) continue; + reset_notes = true; + QByteArray branchRef = branch.toUtf8(); if (!branchRef.startsWith("refs/")) branchRef.prepend("refs/heads/"); @@ -285,6 +288,13 @@ void Repository::reloadBranches() "\nfrom :" + QByteArray::number(br.marks.last()) + "\n\n" "progress Branch " + branchRef + " reloaded\n"); } + + if (reset_notes && + CommandLineParser::instance()->contains("add-metadata-notes")) { + fastImport.write("reset refs/notes/commits\nfrom :" + + QByteArray::number(maxMark + 1) + + "\n"); + } } int Repository::markFrom(const QString &branchFrom, int branchRevNum, QByteArray &branchFromDesc) @@ -674,6 +684,7 @@ void Repository::Transaction::commitNote(const QByteArray ¬eText, bool append QTextStream s(&repository->fastImport); s << "commit refs/notes/commits" << endl + << "mark :" << QByteArray::number(maxMark + 1) << endl << "committer " << QString::fromUtf8(author) << ' ' << datetime << " +0000" << endl << "data " << message.length() << endl << message << endl -- cgit v1.2.1