Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ int main(int argc, char **argv)
repositories.insert(rule.name, repo);

int repo_next = repo->setupIncremental(cutoff);
repo->restoreAnnotatedTags();
repo->restoreBranchNotes();

/*
Expand Down
73 changes: 63 additions & 10 deletions src/repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ static const mark_t maxMark = ULONG_MAX;
class FastImportRepository : public Repository
{
public:
struct AnnotatedTag
{
QString supportingRef;
QByteArray svnprefix;
QByteArray author;
QByteArray log;
uint dt;
int revnum;
};
class Transaction : public Repository::Transaction
{
Q_DISABLE_COPY(Transaction)
Expand Down Expand Up @@ -69,6 +78,7 @@ class FastImportRepository : public Repository
};
FastImportRepository(const Rules::Repository &rule);
int setupIncremental(int &cutoff);
void restoreAnnotatedTags();
void restoreBranchNotes();
void restoreLog();
~FastImportRepository();
Expand Down Expand Up @@ -101,15 +111,6 @@ class FastImportRepository : public Repository
QVector<int> commits;
QVector<int> marks;
};
struct AnnotatedTag
{
QString supportingRef;
QByteArray svnprefix;
QByteArray author;
QByteArray log;
uint dt;
int revnum;
};

QHash<QString, Branch> branches;
QHash<QString, QByteArray> branchNotes;
Expand Down Expand Up @@ -185,6 +186,7 @@ class ForwardingRepository : public Repository
ForwardingRepository(const QString &n, Repository *r, const QString &p) : name(n), repo(r), prefix(p) {}

int setupIncremental(int &) { return 1; }
void restoreAnnotatedTags() {}
void restoreBranchNotes() {}
void restoreLog() {}

Expand Down Expand Up @@ -252,6 +254,33 @@ class ProcessCache: QLinkedList<FastImportRepository *>
};
static ProcessCache processCache;

QDataStream &operator<<(QDataStream &out, const FastImportRepository::AnnotatedTag &annotatedTag)
{
out << annotatedTag.supportingRef
<< annotatedTag.svnprefix
<< annotatedTag.author
<< annotatedTag.log
<< (quint64) annotatedTag.dt
<< (qint64) annotatedTag.revnum;
return out;
}

QDataStream &operator>>(QDataStream &in, FastImportRepository::AnnotatedTag &annotatedTag)
{
quint64 dt;
qint64 revnum;

in >> annotatedTag.supportingRef
>> annotatedTag.svnprefix
>> annotatedTag.author
>> annotatedTag.log
>> dt
>> revnum;
annotatedTag.dt = (uint) dt;
annotatedTag.revnum = (int) revnum;
return in;
}

Repository *createRepository(const Rules::Repository &rule, const QHash<QString, Repository *> &repositories)
{
if (rule.forwardTo.isEmpty())
Expand All @@ -271,6 +300,13 @@ static QString marksFileName(QString name)
return name;
}

static QString annotatedTagsFileName(QString name)
{
name.replace('/', '_');
name.prepend("annotatedTags-");
return name;
}

static QString branchNotesFileName(QString name)
{
name.replace('/', '_');
Expand Down Expand Up @@ -462,6 +498,17 @@ int FastImportRepository::setupIncremental(int &cutoff)
return cutoff;
}

void FastImportRepository::restoreAnnotatedTags()
{
QFile annotatedTagsFile(name + "/" + annotatedTagsFileName(name));
if (!annotatedTagsFile.exists())
return;
annotatedTagsFile.open(QIODevice::ReadOnly);
QDataStream annotatedTagsStream(&annotatedTagsFile);
annotatedTagsStream >> annotatedTags;
annotatedTagsFile.close();
}

void FastImportRepository::restoreBranchNotes()
{
QFile branchNotesFile(name + "/" + branchNotesFileName(name));
Expand Down Expand Up @@ -732,7 +779,13 @@ void FastImportRepository::finalizeTags()
if (annotatedTags.isEmpty())
return;

printf("Finalising tags for %s...", qPrintable(name));
QFile annotatedTagsFile(name + "/" + annotatedTagsFileName(name));
annotatedTagsFile.open(QIODevice::WriteOnly);
QDataStream annotatedTagsStream(&annotatedTagsFile);
annotatedTagsStream << annotatedTags;
annotatedTagsFile.close();

printf("Finalising annotated tags for %s...", qPrintable(name));
startFastImport();

QHash<QString, AnnotatedTag>::ConstIterator it = annotatedTags.constBegin();
Expand Down
1 change: 1 addition & 0 deletions src/repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Repository
const QByteArray &commit = QByteArray()) = 0;
};
virtual int setupIncremental(int &cutoff) = 0;
virtual void restoreAnnotatedTags() = 0;
virtual void restoreBranchNotes() = 0;
virtual void restoreLog() = 0;
virtual ~Repository() {}
Expand Down