Skip to content

Commit

Permalink
Revert "Revert Maintain annotated tags throughout incremental runs #60"
Browse files Browse the repository at this point in the history
This reverts commit 58378dc.
  • Loading branch information
tnyblom committed May 9, 2019
1 parent d2b6ef4 commit 3d583c8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
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
55 changes: 54 additions & 1 deletion src/repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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 @@ -186,6 +187,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 @@ -253,6 +255,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 @@ -272,6 +301,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 @@ -463,6 +499,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 @@ -734,7 +781,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

0 comments on commit 3d583c8

Please sign in to comment.