Skip to content

Commit fa63987

Browse files
committed
Maintain annotated tags throughout incremental runs
1 parent 87a645e commit fa63987

File tree

3 files changed

+65
-10
lines changed

3 files changed

+65
-10
lines changed

src/main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ int main(int argc, char **argv)
211211
repositories.insert(rule.name, repo);
212212

213213
int repo_next = repo->setupIncremental(cutoff);
214+
repo->restoreAnnotatedTags();
214215

215216
/*
216217
* cutoff < resume_from => error exit eventually

src/repository.cpp

+63-10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ static const mark_t maxMark = ULONG_MAX;
3232
class FastImportRepository : public Repository
3333
{
3434
public:
35+
struct AnnotatedTag
36+
{
37+
QString supportingRef;
38+
QByteArray svnprefix;
39+
QByteArray author;
40+
QByteArray log;
41+
uint dt;
42+
int revnum;
43+
};
3544
class Transaction : public Repository::Transaction
3645
{
3746
Q_DISABLE_COPY(Transaction)
@@ -69,6 +78,7 @@ class FastImportRepository : public Repository
6978
};
7079
FastImportRepository(const Rules::Repository &rule);
7180
int setupIncremental(int &cutoff);
81+
void restoreAnnotatedTags();
7282
void restoreLog();
7383
~FastImportRepository();
7484

@@ -100,15 +110,6 @@ class FastImportRepository : public Repository
100110
QVector<int> marks;
101111
QByteArray note;
102112
};
103-
struct AnnotatedTag
104-
{
105-
QString supportingRef;
106-
QByteArray svnprefix;
107-
QByteArray author;
108-
QByteArray log;
109-
uint dt;
110-
int revnum;
111-
};
112113

113114
QHash<QString, Branch> branches;
114115
QHash<QString, AnnotatedTag> annotatedTags;
@@ -183,6 +184,7 @@ class ForwardingRepository : public Repository
183184
ForwardingRepository(const QString &n, Repository *r, const QString &p) : name(n), repo(r), prefix(p) {}
184185

185186
int setupIncremental(int &) { return 1; }
187+
void restoreAnnotatedTags() {}
186188
void restoreLog() {}
187189

188190
void reloadBranches() { return repo->reloadBranches(); }
@@ -248,6 +250,33 @@ class ProcessCache: QLinkedList<FastImportRepository *>
248250
};
249251
static ProcessCache processCache;
250252

253+
QDataStream &operator<<(QDataStream &out, const FastImportRepository::AnnotatedTag &annotatedTag)
254+
{
255+
out << annotatedTag.supportingRef
256+
<< annotatedTag.svnprefix
257+
<< annotatedTag.author
258+
<< annotatedTag.log
259+
<< (quint64) annotatedTag.dt
260+
<< (qint64) annotatedTag.revnum;
261+
return out;
262+
}
263+
264+
QDataStream &operator>>(QDataStream &in, FastImportRepository::AnnotatedTag &annotatedTag)
265+
{
266+
quint64 dt;
267+
qint64 revnum;
268+
269+
in >> annotatedTag.supportingRef
270+
>> annotatedTag.svnprefix
271+
>> annotatedTag.author
272+
>> annotatedTag.log
273+
>> dt
274+
>> revnum;
275+
annotatedTag.dt = (uint) dt;
276+
annotatedTag.revnum = (int) revnum;
277+
return in;
278+
}
279+
251280
Repository *createRepository(const Rules::Repository &rule, const QHash<QString, Repository *> &repositories)
252281
{
253282
if (rule.forwardTo.isEmpty())
@@ -267,6 +296,13 @@ static QString marksFileName(QString name)
267296
return name;
268297
}
269298

299+
static QString annotatedTagsFileName(QString name)
300+
{
301+
name.replace('/', '_');
302+
name.prepend("annotatedTags-");
303+
return name;
304+
}
305+
270306
FastImportRepository::FastImportRepository(const Rules::Repository &rule)
271307
: name(rule.name), prefix(rule.forwardTo), fastImport(name), commitCount(0), outstandingTransactions(0),
272308
last_commit_mark(0), next_file_mark(maxMark - 1), processHasStarted(false)
@@ -451,6 +487,17 @@ int FastImportRepository::setupIncremental(int &cutoff)
451487
return cutoff;
452488
}
453489

490+
void FastImportRepository::restoreAnnotatedTags()
491+
{
492+
QFile annotatedTagsFile(name + "/" + annotatedTagsFileName(name));
493+
if (!annotatedTagsFile.exists())
494+
return;
495+
annotatedTagsFile.open(QIODevice::ReadOnly);
496+
QDataStream annotatedTagsStream(&annotatedTagsFile);
497+
annotatedTagsStream >> annotatedTags;
498+
annotatedTagsFile.close();
499+
}
500+
454501
void FastImportRepository::restoreLog()
455502
{
456503
QString file = logFileName(name);
@@ -710,7 +757,13 @@ void FastImportRepository::finalizeTags()
710757
if (annotatedTags.isEmpty())
711758
return;
712759

713-
printf("Finalising tags for %s...", qPrintable(name));
760+
QFile annotatedTagsFile(name + "/" + annotatedTagsFileName(name));
761+
annotatedTagsFile.open(QIODevice::WriteOnly);
762+
QDataStream annotatedTagsStream(&annotatedTagsFile);
763+
annotatedTagsStream << annotatedTags;
764+
annotatedTagsFile.close();
765+
766+
printf("Finalising annotated tags for %s...", qPrintable(name));
714767
startFastImport();
715768

716769
QHash<QString, AnnotatedTag>::ConstIterator it = annotatedTags.constBegin();

src/repository.h

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class Repository
116116
const QByteArray &commit = QByteArray()) = 0;
117117
};
118118
virtual int setupIncremental(int &cutoff) = 0;
119+
virtual void restoreAnnotatedTags() = 0;
119120
virtual void restoreLog() = 0;
120121
virtual ~Repository() {}
121122

0 commit comments

Comments
 (0)