aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Guenther <marcguenther@me.com>2010-05-06 14:11:10 +0200
committerMarc Guenther <marcguenther@me.com>2010-05-06 14:11:10 +0200
commit54e55cfcb0ec8f634c1d5488232c54d1f7495882 (patch)
tree9e66046568979983a6ef135c8d30ba6560775de8 /src
parentb886ca85875859e7a3dd98aaf087abe9365c0646 (diff)
parent209e6ce4ddf114494d6d72455690af819dcbf18c (diff)
downloadsvn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.tar
svn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.tar.gz
svn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.tar.bz2
svn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.tar.xz
svn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.zip
Merge branch 'master' of gitorious.org:svn2git/svn2git
Diffstat (limited to 'src')
-rw-r--r--src/repository.cpp36
-rw-r--r--src/repository.h3
-rw-r--r--src/svn.cpp37
3 files changed, 55 insertions, 21 deletions
diff --git a/src/repository.cpp b/src/repository.cpp
index d589b6e..1398dd0 100644
--- a/src/repository.cpp
+++ b/src/repository.cpp
@@ -120,7 +120,7 @@ void Repository::reloadBranches()
}
void Repository::createBranch(const QString &branch, int revnum,
- const QString &branchFrom, int)
+ const QString &branchFrom, int branchRevNum)
{
startFastImport();
if (!branches.contains(branch)) {
@@ -129,8 +129,9 @@ void Repository::createBranch(const QString &branch, int revnum,
}
QByteArray branchRef = branch.toUtf8();
- if (!branchRef.startsWith("refs/"))
- branchRef.prepend("refs/heads/");
+ if (!branchRef.startsWith("refs/"))
+ branchRef.prepend("refs/heads/");
+
Branch &br = branches[branch];
if (br.created && br.created != revnum) {
@@ -142,9 +143,18 @@ void Repository::createBranch(const QString &branch, int revnum,
// now create the branch
br.created = revnum;
- QByteArray branchFromRef = branchFrom.toUtf8();
- if (!branchFromRef.startsWith("refs/"))
- branchFromRef.prepend("refs/heads/");
+ QByteArray branchFromRef;
+ const int closestCommit = *qLowerBound(exportedCommits, branchRevNum);
+ if(commitMarks.contains(closestCommit))
+ {
+ branchFromRef = ":" + QByteArray::number(commitMarks.value(closestCommit));
+ } else {
+ qWarning() << branch << "in repository" << name << "is branching but no exported commits exist in repository"
+ << "creating an empty branch.";
+ branchFromRef = branchFrom.toUtf8();
+ if (!branchFromRef.startsWith("refs/"))
+ branchFromRef.prepend("refs/heads/");
+ }
if (!branches.contains(branchFrom) || !branches.value(branchFrom).created) {
qCritical() << branch << "in repository" << name
@@ -155,7 +165,7 @@ void Repository::createBranch(const QString &branch, int revnum,
fastImport.write("reset " + branchRef + "\nfrom " + branchFromRef + "\n\n"
"progress Branch " + branchRef + " created from "
- + branchFromRef + " r" + QByteArray::number(revnum) + "\n\n");
+ + branchFromRef + " r" + QByteArray::number(branchRevNum) + "\n\n");
}
Repository::Transaction *Repository::newTransaction(const QString &branch, const QString &svnprefix,
@@ -177,8 +187,7 @@ Repository::Transaction *Repository::newTransaction(const QString &branch, const
if ((++commitCount % CommandLineParser::instance()->optionArgument(QLatin1String("commit-interval"), QLatin1String("10000")).toInt()) == 0)
// write everything to disk every 10000 commits
fastImport.write("checkpoint\n");
- if (outstandingTransactions++ == 0)
- lastmark = 1; // reset the mark number
+ outstandingTransactions++;
return txn;
}
@@ -347,6 +356,9 @@ void Repository::Transaction::commit()
QTextStream s(&repository->fastImport);
s << "commit " << branchRef << endl;
+ s << "mark :" << QByteArray::number(++repository->lastmark) << endl;
+ repository->commitMarks.insert(revnum, repository->lastmark);
+ repository->exportedCommits.append(revnum);
s << "committer " << QString::fromUtf8(author) << ' ' << datetime << " -0000" << endl;
Branch &br = repository->branches[branch];
@@ -376,9 +388,9 @@ void Repository::Transaction::commit()
QByteArray::number(repository->commitCount) +
" branch " + branch +
" = SVN r" + QByteArray::number(revnum) + "\n\n");
- printf(" %d modifications to \"%s\"",
- deletedFiles.count() + modifiedFiles.count(),
- qPrintable(repository->name));
+ printf(" %d modifications from SVN %s to %s/%s",
+ deletedFiles.count() + modifiedFiles.count(), svnprefix.data(),
+ qPrintable(repository->name), branch.data());
while (repository->fastImport.bytesToWrite())
if (!repository->fastImport.waitForBytesWritten(-1))
diff --git a/src/repository.h b/src/repository.h
index c00518a..629616b 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -20,6 +20,7 @@
#include <QHash>
#include <QProcess>
+#include <QVector>
#include "ruleparser.h"
@@ -84,6 +85,8 @@ private:
QHash<QString, Branch> branches;
QHash<QString, AnnotatedTag> annotatedTags;
+ QHash<int, int> commitMarks;
+ QVector<int> exportedCommits;
QString name;
QProcess fastImport;
int commitCount;
diff --git a/src/svn.cpp b/src/svn.cpp
index 0c859c9..bb00214 100644
--- a/src/svn.cpp
+++ b/src/svn.cpp
@@ -216,7 +216,8 @@ static void splitPathName(const Rules::Match &rule, const QString &pathName, QSt
}
if (path_p) {
- QString prefix = svnprefix.replace(rule.rx, rule.prefix);
+ QString prefix = svnprefix;
+ prefix.replace(rule.rx, rule.prefix);
*path_p = prefix + pathName.mid(svnprefix.length());
}
}
@@ -508,15 +509,31 @@ int SvnRevision::exportEntry(const char *key, const svn_fs_path_change_t *change
svn_boolean_t is_dir;
SVN_ERR(svn_fs_is_dir(&is_dir, fs_root, key, revpool));
if (is_dir) {
- if (path_from == NULL) {
- // no, it's a new directory being added
- // Git doesn't handle directories, so we don't either
- //qDebug() << " mkdir ignored:" << key;
- return EXIT_SUCCESS;
- }
-
current += '/';
- qDebug() << " " << key << "was copied from" << path_from << "rev" << rev_from;
+ if (change->change_kind == svn_fs_path_change_modify ||
+ change->change_kind == svn_fs_path_change_add) {
+ if (path_from == NULL) {
+ // freshly added directory, or modified properties
+ // Git doesn't handle directories, so we don't either
+ //qDebug() << " mkdir ignored:" << key;
+ return EXIT_SUCCESS;
+ }
+
+ qDebug() << " " << key << "was copied from" << path_from << "rev" << rev_from;
+ } else if (change->change_kind == svn_fs_path_change_delete) {
+ qDebug() << " " << key << "was deleted";
+ } else if (change->change_kind == svn_fs_path_change_replace) {
+ if (path_from == NULL)
+ qDebug() << " " << key << "was replaced";
+ else
+ qDebug() << " " << key << "was replaced from" << path_from << "rev" << rev_from;
+ } else if (change->change_kind == svn_fs_path_change_reset) {
+ qCritical() << " " << key << "was reset, panic!";
+ return EXIT_FAILURE;
+ } else {
+ qCritical() << " " << key << "has unhandled change kind " << change->change_kind << ", panic!";
+ return EXIT_FAILURE;
+ }
}
// find the first rule that matches this pathname
@@ -646,6 +663,8 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *cha
transactions.insert(repository + branch, txn);
}
+ if (change->change_kind == svn_fs_path_change_replace && path_from == NULL)
+ txn->deleteFile(path);
if (change->change_kind == svn_fs_path_change_delete) {
txn->deleteFile(path);
} else if (!current.endsWith('/')) {