aboutsummaryrefslogtreecommitdiffstats
path: root/src/repository.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/repository.cpp')
-rw-r--r--src/repository.cpp52
1 files changed, 44 insertions, 8 deletions
diff --git a/src/repository.cpp b/src/repository.cpp
index 1398dd0..be73df6 100644
--- a/src/repository.cpp
+++ b/src/repository.cpp
@@ -52,7 +52,7 @@ public:
static ProcessCache processCache;
Repository::Repository(const Rules::Repository &rule)
- : name(rule.name), commitCount(0), outstandingTransactions(0), processHasStarted(false)
+ : name(rule.name), commitCount(0), outstandingTransactions(0), lastmark(0), processHasStarted(false)
{
foreach (Rules::Repository::Branch branchRule, rule.branches) {
Branch branch;
@@ -97,6 +97,19 @@ void Repository::closeFastImport()
}
processHasStarted = false;
processCache.remove(this);
+ // Save the exported marks
+ QString revsFile = name;
+ revsFile.replace('/', '_');
+ revsFile.prepend("revisions-");
+ QFile exportedMarks(revsFile);
+ qDebug() << exportedMarks.open(QIODevice::Truncate | QIODevice::Text | QIODevice::WriteOnly);
+
+ int mark;
+ foreach(mark, commitMarks.keys())
+ {
+ exportedMarks.write(QString(":%2 r%1\n").arg(mark).arg(commitMarks.value(mark)).toLocal8Bit());
+ }
+ exportedMarks.close();
}
void Repository::reloadBranches()
@@ -144,10 +157,27 @@ void Repository::createBranch(const QString &branch, int revnum,
// now create the branch
br.created = revnum;
QByteArray branchFromRef;
- const int closestCommit = *qLowerBound(exportedCommits, branchRevNum);
- if(commitMarks.contains(closestCommit))
+ const int closestCommit = *qLowerBound(commitMarks.keys(), branchRevNum);
+ if(exportedCommits.contains(closestCommit))
{
- branchFromRef = ":" + QByteArray::number(commitMarks.value(closestCommit));
+ bool pathFound = false;
+ QString path;
+ foreach(path, exportedCommits[closestCommit]) {
+ if(path.contains(branchFrom)) {
+ pathFound = true;
+ break;
+ }
+ }
+
+ if(pathFound) {
+ branchFromRef = ":" + QByteArray::number(commitMarks.value(closestCommit));
+ qDebug() << branch << "in repository" << name << "is branching from" << closestCommit << "(svn reports r" << branchRevNum << ") git mark:" << branchFromRef;
+ } else {
+ qWarning() << branch << "in repository" << name << "is branching from a revision that doesn't touch the branch from path, branching from current revision";
+ branchFromRef = branchFrom.toUtf8();
+ if (!branchFromRef.startsWith("refs/"))
+ branchFromRef.prepend("refs/heads/");
+ }
} else {
qWarning() << branch << "in repository" << name << "is branching but no exported commits exist in repository"
<< "creating an empty branch.";
@@ -165,7 +195,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(branchRevNum) + "\n\n");
+ + branchFromRef + " r" + QByteArray::number(branchRevNum) + "(at SVN" + QByteArray::number(revnum) + ")\n\n");
}
Repository::Transaction *Repository::newTransaction(const QString &branch, const QString &svnprefix,
@@ -269,6 +299,11 @@ void Repository::startFastImport()
processHasStarted = true;
// start the process
+ QString marksFile = name;
+ marksFile.replace('/', '_');
+ marksFile.prepend("marks-");
+ QStringList marksOptions;
+ marksOptions << "--export-marks=" + marksFile;
QString outputFile = name;
outputFile.replace('/', '_');
outputFile.prepend("log-");
@@ -276,7 +311,7 @@ void Repository::startFastImport()
fastImport.setProcessChannelMode(QProcess::MergedChannels);
if (!CommandLineParser::instance()->contains("dry-run")) {
- fastImport.start("git", QStringList() << "fast-import");
+ fastImport.start("git", QStringList() << "fast-import" << marksOptions);
} else {
fastImport.start("/bin/cat", QStringList());
}
@@ -311,6 +346,7 @@ void Repository::Transaction::deleteFile(const QString &path)
if(pathNoSlash.endsWith('/'))
pathNoSlash.chop(1);
deletedFiles.append(pathNoSlash);
+ modifiedPaths.append(path);
}
QIODevice *Repository::Transaction::addFile(const QString &path, int mode, qint64 length)
@@ -334,7 +370,7 @@ QIODevice *Repository::Transaction::addFile(const QString &path, int mode, qint6
repository->fastImport.write(QByteArray::number(length));
repository->fastImport.write("\n", 1);
}
-
+ modifiedPaths.append(branch + "/" + path);
return &repository->fastImport;
}
@@ -358,7 +394,7 @@ void Repository::Transaction::commit()
s << "commit " << branchRef << endl;
s << "mark :" << QByteArray::number(++repository->lastmark) << endl;
repository->commitMarks.insert(revnum, repository->lastmark);
- repository->exportedCommits.append(revnum);
+ repository->exportedCommits.insert(revnum, modifiedPaths);
s << "committer " << QString::fromUtf8(author) << ' ' << datetime << " -0000" << endl;
Branch &br = repository->branches[branch];