2626
2727static const int maxSimultaneousProcesses = 100 ;
2828
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;
3031
3132class FastImportRepository : public Repository
3233{
@@ -117,10 +118,10 @@ class FastImportRepository : public Repository
117118 QByteArray resetBranches;
118119
119120 /* starts at 0, and counts up. */
120- int last_commit_mark;
121+ mark_t last_commit_mark;
121122
122123 /* starts at maxMark and counts down. Reset after each SVN revision */
123- int next_file_mark;
124+ mark_t next_file_mark;
124125
125126 bool processHasStarted;
126127
@@ -130,8 +131,8 @@ class FastImportRepository : public Repository
130131 // called when a transaction is deleted
131132 void forgetTransaction (Transaction *t);
132133
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);
135136
136137 friend class ProcessCache ;
137138 Q_DISABLE_COPY (FastImportRepository)
@@ -302,13 +303,14 @@ static QString logFileName(QString name)
302303 return name;
303304}
304305
305- static int lastValidMark (QString name)
306+ static mark_t lastValidMark (QString name)
306307{
307308 QFile marksfile (name + " /" + marksFileName (name));
308309 if (!marksfile.open (QIODevice::ReadOnly))
309310 return 0 ;
310311
311- int prev_mark = 0 ;
312+ qDebug () << " marksfile " << marksfile.fileName () ;
313+ mark_t prev_mark = 0 ;
312314
313315 int lineno = 0 ;
314316 while (!marksfile.atEnd ()) {
@@ -317,17 +319,17 @@ static int lastValidMark(QString name)
317319 if (line.isEmpty ())
318320 continue ;
319321
320- int mark = 0 ;
322+ mark_t mark = 0 ;
321323 if (line[0 ] == ' :' ) {
322324 int sp = line.indexOf (' ' );
323325 if (sp != -1 ) {
324326 QString m = line.mid (1 , sp-1 );
325- mark = m.toInt ();
327+ mark = m.toULongLong ();
326328 }
327329 }
328330
329331 if (!mark) {
330- qCritical () << marksfile.fileName () << " line" << lineno << " marks file corrupt?" ;
332+ qCritical () << marksfile.fileName () << " line" << lineno << " marks file corrupt?" << " mark " << mark ;
331333 return 0 ;
332334 }
333335
@@ -360,7 +362,7 @@ int FastImportRepository::setupIncremental(int &cutoff)
360362
361363 QRegExp progress (" progress SVN r(\\ d+) branch (.*) = :(\\ d+)" );
362364
363- int last_valid_mark = lastValidMark (name);
365+ mark_t last_valid_mark = lastValidMark (name);
364366
365367 int last_revnum = 0 ;
366368 qint64 pos = 0 ;
@@ -381,7 +383,7 @@ int FastImportRepository::setupIncremental(int &cutoff)
381383
382384 int revnum = progress.cap (1 ).toInt ();
383385 QString branch = progress.cap (2 );
384- int mark = progress.cap (3 ).toInt ();
386+ mark_t mark = progress.cap (3 ).toULongLong ();
385387
386388 if (revnum >= cutoff)
387389 goto beyond_cutoff;
@@ -490,7 +492,7 @@ void FastImportRepository::reloadBranches()
490492 }
491493}
492494
493- int FastImportRepository::markFrom (const QString &branchFrom, int branchRevNum, QByteArray &branchFromDesc)
495+ long long FastImportRepository::markFrom (const QString &branchFrom, int branchRevNum, QByteArray &branchFromDesc)
494496{
495497 Branch &brFrom = branches[branchFrom];
496498 if (!brFrom.created )
@@ -524,7 +526,7 @@ int FastImportRepository::createBranch(const QString &branch, int revnum,
524526 const QString &branchFrom, int branchRevNum)
525527{
526528 QByteArray branchFromDesc = " from branch " + branchFrom.toUtf8 ();
527- int mark = markFrom (branchFrom, branchRevNum, branchFromDesc);
529+ long long mark = markFrom (branchFrom, branchRevNum, branchFromDesc);
528530
529531 if (mark == -1 ) {
530532 qCritical () << branch << " in repository" << name
@@ -557,7 +559,7 @@ int FastImportRepository::deleteBranch(const QString &branch, int revnum)
557559 return resetBranch (branch, revnum, 0 , null_sha, " delete" );
558560}
559561
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)
561563{
562564 QByteArray branchRef = branch.toUtf8 ();
563565 if (!branchRef.startsWith (" refs/" ))
@@ -805,7 +807,7 @@ void FastImportRepository::Transaction::noteCopyFromBranch(const QString &branch
805807 return ;
806808 }
807809 static QByteArray dummy;
808- int mark = repository->markFrom (branchFrom, branchRevNum, dummy);
810+ long long mark = repository->markFrom (branchFrom, branchRevNum, dummy);
809811 Q_ASSERT (dummy.isEmpty ());
810812
811813 if (mark == -1 ) {
@@ -836,7 +838,7 @@ void FastImportRepository::Transaction::deleteFile(const QString &path)
836838
837839QIODevice *FastImportRepository::Transaction::addFile (const QString &path, int mode, qint64 length)
838840{
839- int mark = repository->next_file_mark --;
841+ mark_t mark = repository->next_file_mark --;
840842
841843 // in case the two mark allocations meet, we might as well just abort
842844 Q_ASSERT (mark > repository->last_commit_mark + 1 );
@@ -903,7 +905,7 @@ void FastImportRepository::Transaction::commit()
903905 // We might be tempted to use the SVN revision number as the fast-import commit mark.
904906 // However, a single SVN revision can modify multple branches, and thus lead to multiple
905907 // 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 ;
907909
908910 // in case the two mark allocations meet, we might as well just abort
909911 Q_ASSERT (mark < repository->next_file_mark - 1 );
@@ -915,7 +917,7 @@ void FastImportRepository::Transaction::commit()
915917 if (CommandLineParser::instance ()->contains (" add-metadata" ))
916918 message += " \n " + Repository::formatMetadataMessage (svnprefix, revnum);
917919
918- int parentmark = 0 ;
920+ mark_t parentmark = 0 ;
919921 Branch &br = repository->branches [branch];
920922 if (br.created && !br.marks .isEmpty () && br.marks .last ()) {
921923 parentmark = br.marks .last ();
@@ -941,7 +943,7 @@ void FastImportRepository::Transaction::commit()
941943
942944 // note some of the inferred merges
943945 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
945947
946948 if (log.contains (" This commit was manufactured by cvs2svn" ) && merges.count () > 1 ) {
947949 qSort (merges);
@@ -950,7 +952,7 @@ void FastImportRepository::Transaction::commit()
950952 qWarning () << " WARN: Discarding all but the highest merge point as a workaround for cvs2svn created branch/tag"
951953 << " Discarded marks:" << merges;
952954 } else {
953- foreach (const int merge, merges) {
955+ foreach (const mark_t merge, merges) {
954956 if (merge == parentmark) {
955957 qDebug () << " Skipping marking" << merge << " as a merge point as it matches the parent" ;
956958 continue ;
0 commit comments