Skip to content

Commit c9376cf

Browse files
committed
Merge commit 'refs/merge-requests/20' of gitorious.org:svn2git/svn2git into mr/20
2 parents 2baedda + 8f8d4c7 commit c9376cf

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

src/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ QSet<int> loadRevisionsFile( const QString &fileName, Svn &svn )
127127

128128
static const CommandLineOption options[] = {
129129
{"--identity-map FILENAME", "provide map between svn username and email"},
130+
{"--identity-domain DOMAIN", "provide user domain if no map was given"},
130131
{"--revisions-file FILENAME", "provide a file with revision number that should be processed"},
131132
{"--rules FILENAME[,FILENAME]", "the rules file(s) that determines what goes where"},
132133
{"--add-metadata", "if passed, each git commit will have svn commit info"},
@@ -178,9 +179,9 @@ int main(int argc, char **argv)
178179
out << "svn-all-fast-export failed: please specify the rules using the 'rules' argument\n";
179180
return 11;
180181
}
181-
if (!args->contains("identity-map")) {
182+
if (!args->contains("identity-map") && !args->contains("identity-domain")) {
182183
QTextStream out(stderr);
183-
out << "WARNING; no identity-map specified, all commits will be without email address\n\n";
184+
out << "WARNING; no identity-map or -domain specified, all commits will use default @localhost email address\n\n";
184185
}
185186

186187
QCoreApplication app(argc, argv);
@@ -246,6 +247,11 @@ int main(int argc, char **argv)
246247
svn.setMatchRules(rulesList.allMatchRules());
247248
svn.setRepositories(repositories);
248249
svn.setIdentityMap(loadIdentityMapFile(args->optionArgument("identity-map")));
250+
// Massage user input a little, no guarantees that input makes sense.
251+
QString domain = args->optionArgument("identity-domain").simplified().remove(QChar('@'));
252+
if (domain.isEmpty())
253+
domain = QString("localhost");
254+
svn.setIdentityDomain(domain);
249255

250256
if (max_rev < 1)
251257
max_rev = svn.youngestRevision();

src/repository.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
static const int maxSimultaneousProcesses = 100;
2828

29-
static const int maxMark = (1 << 20) - 1; // some versions of git-fast-import are buggy for larger values of maxMark
29+
static const int maxMark = (1 << 20) - 2; // some versions of git-fast-import are buggy for larger values of maxMark
3030

3131
class ProcessCache: QLinkedList<Repository *>
3232
{
@@ -271,12 +271,15 @@ void Repository::closeFastImport()
271271

272272
void Repository::reloadBranches()
273273
{
274+
bool reset_notes = false;
274275
foreach (QString branch, branches.keys()) {
275276
Branch &br = branches[branch];
276277

277278
if (br.marks.isEmpty() || !br.marks.last())
278279
continue;
279280

281+
reset_notes = true;
282+
280283
QByteArray branchRef = branch.toUtf8();
281284
if (!branchRef.startsWith("refs/"))
282285
branchRef.prepend("refs/heads/");
@@ -285,6 +288,13 @@ void Repository::reloadBranches()
285288
"\nfrom :" + QByteArray::number(br.marks.last()) + "\n\n"
286289
"progress Branch " + branchRef + " reloaded\n");
287290
}
291+
292+
if (reset_notes &&
293+
CommandLineParser::instance()->contains("add-metadata-notes")) {
294+
fastImport.write("reset refs/notes/commits\nfrom :" +
295+
QByteArray::number(maxMark + 1) +
296+
"\n");
297+
}
288298
}
289299

290300
int Repository::markFrom(const QString &branchFrom, int branchRevNum, QByteArray &branchFromDesc)
@@ -674,7 +684,8 @@ void Repository::Transaction::commitNote(const QByteArray &noteText, bool append
674684

675685
QTextStream s(&repository->fastImport);
676686
s << "commit refs/notes/commits" << endl
677-
<< "committer " << QString::fromUtf8(author) << ' ' << datetime << " -0000" << endl
687+
<< "mark :" << QByteArray::number(maxMark + 1) << endl
688+
<< "committer " << QString::fromUtf8(author) << ' ' << datetime << " +0000" << endl
678689
<< "data " << message.length() << endl
679690
<< message << endl
680691
<< "N inline " << commitRef << endl

src/svn.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class SvnPrivate
7979
QList<MatchRuleList> allMatchRules;
8080
RepositoryHash repositories;
8181
IdentityHash identities;
82+
QString userdomain;
8283

8384
SvnPrivate(const QString &pathToRepository);
8485
~SvnPrivate();
@@ -130,6 +131,11 @@ void Svn::setIdentityMap(const IdentityHash &identityMap)
130131
d->identities = identityMap;
131132
}
132133

134+
void Svn::setIdentityDomain(const QString &identityDomain)
135+
{
136+
d->userdomain = identityDomain;
137+
}
138+
133139
int Svn::youngestRevision()
134140
{
135141
return d->youngestRevision();
@@ -388,6 +394,7 @@ class SvnRevision
388394
QList<MatchRuleList> allMatchRules;
389395
RepositoryHash repositories;
390396
IdentityHash identities;
397+
QString userdomain;
391398

392399
svn_fs_t *fs;
393400
svn_fs_root_t *fs_root;
@@ -436,6 +443,7 @@ int SvnPrivate::exportRevision(int revnum)
436443
rev.allMatchRules = allMatchRules;
437444
rev.repositories = repositories;
438445
rev.identities = identities;
446+
rev.userdomain = userdomain;
439447

440448
// open this revision:
441449
printf("Exporting revision %d ", revnum);
@@ -506,8 +514,8 @@ int SvnRevision::fetchRevProps()
506514
if (!svnauthor || svn_string_isempty(svnauthor))
507515
authorident = "nobody <nobody@localhost>";
508516
else
509-
authorident = svnauthor->data + QByteArray(" <") +
510-
svnauthor->data + QByteArray("@localhost>");
517+
authorident = svnauthor->data + QByteArray(" <") + svnauthor->data +
518+
QByteArray("@") + userdomain.toUtf8() + QByteArray(">");
511519
}
512520
propsFetched = true;
513521
return EXIT_SUCCESS;
@@ -771,18 +779,6 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *cha
771779
transactions.insert(repository + branch, txn);
772780
}
773781

774-
//
775-
// If this path was copied from elsewhere, use it to infer _some_
776-
// merge points. This heuristic is fairly useful for tracking
777-
// changes across directory re-organizations and wholesale branch
778-
// imports.
779-
//
780-
if (path_from != NULL && prevrepository == repository && prevbranch != branch) {
781-
if(ruledebug)
782-
qDebug() << "copy from branch" << prevbranch << "to branch" << branch << "@rev" << rev_from;
783-
txn->noteCopyFromBranch (prevbranch, rev_from);
784-
}
785-
786782
if (change->change_kind == svn_fs_path_change_replace && path_from == NULL) {
787783
if(ruledebug)
788784
qDebug() << "replaced with empty path (" << branch << path << ")";

src/svn.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Svn
3636
void setMatchRules(const QList<QList<Rules::Match> > &matchRules);
3737
void setRepositories(const QHash<QString, Repository *> &repositories);
3838
void setIdentityMap(const QHash<QByteArray, QByteArray> &identityMap);
39+
void setIdentityDomain(const QString &identityDomain);
3940

4041
int youngestRevision();
4142
bool exportRevision(int revnum);

0 commit comments

Comments
 (0)