26
26
27
27
static const int maxSimultaneousProcesses = 100 ;
28
28
29
- static const int maxMark = (1 << 20 ) - 2 ; // some versions of git-fast-import are buggy for larger values of maxMark
29
+ typedef unsigned long long mark_t ;
30
+ static const mark_t maxMark = ULONG_MAX;
30
31
31
32
class FastImportRepository : public Repository
32
33
{
@@ -117,10 +118,10 @@ class FastImportRepository : public Repository
117
118
QByteArray resetBranches;
118
119
119
120
/* starts at 0, and counts up. */
120
- int last_commit_mark;
121
+ mark_t last_commit_mark;
121
122
122
123
/* starts at maxMark and counts down. Reset after each SVN revision */
123
- int next_file_mark;
124
+ mark_t next_file_mark;
124
125
125
126
bool processHasStarted;
126
127
@@ -130,8 +131,8 @@ class FastImportRepository : public Repository
130
131
// called when a transaction is deleted
131
132
void forgetTransaction (Transaction *t);
132
133
133
- int resetBranch (const QString &branch, int revnum, int mark, const QByteArray &resetTo, const QByteArray &comment);
134
- int markFrom (const QString &branchFrom, int branchRevNum, QByteArray &desc);
134
+ int resetBranch (const QString &branch, int revnum, mark_t mark, const QByteArray &resetTo, const QByteArray &comment);
135
+ long long markFrom (const QString &branchFrom, int branchRevNum, QByteArray &desc);
135
136
136
137
friend class ProcessCache ;
137
138
Q_DISABLE_COPY (FastImportRepository)
@@ -302,13 +303,14 @@ static QString logFileName(QString name)
302
303
return name;
303
304
}
304
305
305
- static int lastValidMark (QString name)
306
+ static mark_t lastValidMark (QString name)
306
307
{
307
308
QFile marksfile (name + " /" + marksFileName (name));
308
309
if (!marksfile.open (QIODevice::ReadOnly))
309
310
return 0 ;
310
311
311
- int prev_mark = 0 ;
312
+ qDebug () << " marksfile " << marksfile.fileName () ;
313
+ mark_t prev_mark = 0 ;
312
314
313
315
int lineno = 0 ;
314
316
while (!marksfile.atEnd ()) {
@@ -317,17 +319,17 @@ static int lastValidMark(QString name)
317
319
if (line.isEmpty ())
318
320
continue ;
319
321
320
- int mark = 0 ;
322
+ mark_t mark = 0 ;
321
323
if (line[0 ] == ' :' ) {
322
324
int sp = line.indexOf (' ' );
323
325
if (sp != -1 ) {
324
326
QString m = line.mid (1 , sp-1 );
325
- mark = m.toInt ();
327
+ mark = m.toULongLong ();
326
328
}
327
329
}
328
330
329
331
if (!mark) {
330
- qCritical () << marksfile.fileName () << " line" << lineno << " marks file corrupt?" ;
332
+ qCritical () << marksfile.fileName () << " line" << lineno << " marks file corrupt?" << " mark " << mark ;
331
333
return 0 ;
332
334
}
333
335
@@ -360,7 +362,7 @@ int FastImportRepository::setupIncremental(int &cutoff)
360
362
361
363
QRegExp progress (" progress SVN r(\\ d+) branch (.*) = :(\\ d+)" );
362
364
363
- int last_valid_mark = lastValidMark (name);
365
+ mark_t last_valid_mark = lastValidMark (name);
364
366
365
367
int last_revnum = 0 ;
366
368
qint64 pos = 0 ;
@@ -381,7 +383,7 @@ int FastImportRepository::setupIncremental(int &cutoff)
381
383
382
384
int revnum = progress.cap (1 ).toInt ();
383
385
QString branch = progress.cap (2 );
384
- int mark = progress.cap (3 ).toInt ();
386
+ mark_t mark = progress.cap (3 ).toULongLong ();
385
387
386
388
if (revnum >= cutoff)
387
389
goto beyond_cutoff;
@@ -490,7 +492,7 @@ void FastImportRepository::reloadBranches()
490
492
}
491
493
}
492
494
493
- int FastImportRepository::markFrom (const QString &branchFrom, int branchRevNum, QByteArray &branchFromDesc)
495
+ long long FastImportRepository::markFrom (const QString &branchFrom, int branchRevNum, QByteArray &branchFromDesc)
494
496
{
495
497
Branch &brFrom = branches[branchFrom];
496
498
if (!brFrom.created )
@@ -524,7 +526,7 @@ int FastImportRepository::createBranch(const QString &branch, int revnum,
524
526
const QString &branchFrom, int branchRevNum)
525
527
{
526
528
QByteArray branchFromDesc = " from branch " + branchFrom.toUtf8 ();
527
- int mark = markFrom (branchFrom, branchRevNum, branchFromDesc);
529
+ long long mark = markFrom (branchFrom, branchRevNum, branchFromDesc);
528
530
529
531
if (mark == -1 ) {
530
532
qCritical () << branch << " in repository" << name
@@ -557,7 +559,7 @@ int FastImportRepository::deleteBranch(const QString &branch, int revnum)
557
559
return resetBranch (branch, revnum, 0 , null_sha, " delete" );
558
560
}
559
561
560
- int FastImportRepository::resetBranch (const QString &branch, int revnum, int mark, const QByteArray &resetTo, const QByteArray &comment)
562
+ int FastImportRepository::resetBranch (const QString &branch, int revnum, mark_t mark, const QByteArray &resetTo, const QByteArray &comment)
561
563
{
562
564
QByteArray branchRef = branch.toUtf8 ();
563
565
if (!branchRef.startsWith (" refs/" ))
@@ -805,7 +807,7 @@ void FastImportRepository::Transaction::noteCopyFromBranch(const QString &branch
805
807
return ;
806
808
}
807
809
static QByteArray dummy;
808
- int mark = repository->markFrom (branchFrom, branchRevNum, dummy);
810
+ long long mark = repository->markFrom (branchFrom, branchRevNum, dummy);
809
811
Q_ASSERT (dummy.isEmpty ());
810
812
811
813
if (mark == -1 ) {
@@ -836,7 +838,7 @@ void FastImportRepository::Transaction::deleteFile(const QString &path)
836
838
837
839
QIODevice *FastImportRepository::Transaction::addFile (const QString &path, int mode, qint64 length)
838
840
{
839
- int mark = repository->next_file_mark --;
841
+ mark_t mark = repository->next_file_mark --;
840
842
841
843
// in case the two mark allocations meet, we might as well just abort
842
844
Q_ASSERT (mark > repository->last_commit_mark + 1 );
@@ -903,7 +905,7 @@ void FastImportRepository::Transaction::commit()
903
905
// We might be tempted to use the SVN revision number as the fast-import commit mark.
904
906
// However, a single SVN revision can modify multple branches, and thus lead to multiple
905
907
// commits in the same repo. So, we need to maintain a separate commit mark counter.
906
- int mark = ++repository->last_commit_mark ;
908
+ mark_t mark = ++repository->last_commit_mark ;
907
909
908
910
// in case the two mark allocations meet, we might as well just abort
909
911
Q_ASSERT (mark < repository->next_file_mark - 1 );
@@ -915,7 +917,7 @@ void FastImportRepository::Transaction::commit()
915
917
if (CommandLineParser::instance ()->contains (" add-metadata" ))
916
918
message += " \n " + Repository::formatMetadataMessage (svnprefix, revnum);
917
919
918
- int parentmark = 0 ;
920
+ mark_t parentmark = 0 ;
919
921
Branch &br = repository->branches [branch];
920
922
if (br.created && !br.marks .isEmpty () && br.marks .last ()) {
921
923
parentmark = br.marks .last ();
@@ -941,7 +943,7 @@ void FastImportRepository::Transaction::commit()
941
943
942
944
// note some of the inferred merges
943
945
QByteArray desc = " " ;
944
- int i = !!parentmark; // if parentmark != 0, there's at least one parent
946
+ mark_t i = !!parentmark; // if parentmark != 0, there's at least one parent
945
947
946
948
if (log.contains (" This commit was manufactured by cvs2svn" ) && merges.count () > 1 ) {
947
949
qSort (merges);
@@ -950,7 +952,7 @@ void FastImportRepository::Transaction::commit()
950
952
qWarning () << " WARN: Discarding all but the highest merge point as a workaround for cvs2svn created branch/tag"
951
953
<< " Discarded marks:" << merges;
952
954
} else {
953
- foreach (const int merge, merges) {
955
+ foreach (const mark_t merge, merges) {
954
956
if (merge == parentmark) {
955
957
qDebug () << " Skipping marking" << merge << " as a merge point as it matches the parent" ;
956
958
continue ;
0 commit comments