Skip to content

Commit e0fff94

Browse files
authored
Merge pull request #165 from svn-all-fast-export/qt-5-and-qt-6
Support both Qt 5 and Qt 6 at the same time (fixes #163)
2 parents 7ec3d7f + 6333d1b commit e0fff94

File tree

8 files changed

+135
-22
lines changed

8 files changed

+135
-22
lines changed

.github/workflows/build.yaml

+19-6
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,23 @@ jobs:
3434
matrix:
3535
include:
3636
- runs-on: ubuntu-24.04
37-
qt: qt5-qmake
37+
qt_major: 6
38+
qt_qmake: qmake6
39+
qt_packages: qmake6 qt6-base-dev qt6-5compat-dev
40+
- runs-on: ubuntu-24.04
41+
qt_major: 5
42+
qt_qmake: qmake
43+
qt_packages: qt5-qmake qtbase5-dev
44+
- runs-on: ubuntu-22.04
45+
qt_major: 6
46+
qt_qmake: qmake6
47+
qt_packages: qmake6 qt6-base-dev libqt6core5compat6-dev
3848
- runs-on: ubuntu-22.04
39-
qt: qt5-qmake
49+
qt_major: 5
50+
qt_qmake: qmake
51+
qt_packages: qt5-qmake qtbase5-dev
4052

41-
name: Build (Linux, ${{ matrix.runs-on }})
53+
name: Build (Linux, ${{ matrix.runs-on }}, Qt ${{ matrix.qt_major }})
4254
runs-on: ${{ matrix.runs-on }}
4355
steps:
4456
- name: 'Install build dependencies'
@@ -49,8 +61,7 @@ jobs:
4961
build-essential \
5062
libapr1-dev \
5163
libsvn-dev \
52-
${{ matrix.qt }} \
53-
qtbase5-dev \
64+
${{ matrix.qt_packages }} \
5465
subversion
5566
5667
- name: 'Checkout Git branch'
@@ -59,8 +70,10 @@ jobs:
5970
submodules: true
6071

6172
- name: 'Configure'
73+
env:
74+
QMAKE: ${{ matrix.qt_qmake }}
6275
run: |-
63-
qmake
76+
${QMAKE}
6477
6578
- name: 'Build'
6679
run: |-

src/CommandLineParser.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void CommandLineParser::Private::addDefinitions(const CommandLineOption * option
7979
QString option = QString::fromLatin1(options[i].specification);
8080
// options with optional params are written as "--option required[, optional]
8181
if (option.indexOf(QLatin1Char(',')) >= 0 && ( option.indexOf(QLatin1Char('[')) < 0 || option.indexOf(QLatin1Char(']')) < 0) ) {
82-
QStringList optionParts = option.split(QLatin1Char(','), QString::SkipEmptyParts);
82+
QStringList optionParts = option.split(QLatin1Char(','), Qt::SkipEmptyParts);
8383
if (optionParts.count() != 2) {
8484
qWarning() << "WARN: option definition '" << option << "' is faulty; only one ',' allowed";
8585
continue;
@@ -104,7 +104,7 @@ void CommandLineParser::Private::addDefinitions(const CommandLineOption * option
104104
if(definition.name.isEmpty())
105105
continue;
106106
if (option.indexOf(QLatin1Char(' ')) > 0) {
107-
QStringList optionParts = definition.name.split(QLatin1Char(' '), QString::SkipEmptyParts);
107+
QStringList optionParts = definition.name.split(QLatin1Char(' '), Qt::SkipEmptyParts);
108108
definition.name = optionParts[0];
109109
bool first = true;
110110
foreach (QString s, optionParts) {
@@ -137,7 +137,7 @@ void CommandLineParser::Private::setArgumentDefinition(const char *defs)
137137
{
138138
requiredArguments = 0;
139139
argumentDefinition = QString::fromLatin1(defs);
140-
QStringList optionParts = argumentDefinition.split(QLatin1Char(' '), QString::SkipEmptyParts);
140+
QStringList optionParts = argumentDefinition.split(QLatin1Char(' '), Qt::SkipEmptyParts);
141141
bool inArg = false;
142142
foreach (QString s, optionParts) {
143143
s = s.trimmed();
@@ -327,18 +327,22 @@ CommandLineParser::~CommandLineParser()
327327

328328
void CommandLineParser::usage(const QString &name, const QString &argumentDescription)
329329
{
330+
#if QT_VERSION >= 0x060000
331+
QTextStream cout(stdout, QIODeviceBase::WriteOnly);
332+
#else
330333
QTextStream cout(stdout, QIODevice::WriteOnly);
334+
#endif
331335
cout << "Usage: " << d->argumentStrings[0];
332336
if (! name.isEmpty())
333337
cout << " " << name;
334338
if (d->definitions.count())
335339
cout << " [OPTION]";
336340
if (! argumentDescription.isEmpty())
337341
cout << " " << argumentDescription;
338-
cout << endl << endl;
342+
cout << Qt::endl << Qt::endl;
339343

340344
if (d->definitions.count() > 0)
341-
cout << "Options:" << endl;
345+
cout << "Options:" << Qt::endl;
342346
int commandLength = 0;
343347
foreach (Private::OptionDefinition definition, d->definitions)
344348
commandLength = qMax(definition.name.length(), commandLength);
@@ -352,7 +356,7 @@ void CommandLineParser::usage(const QString &name, const QString &argumentDescri
352356
cout << definition.name;
353357
for (int i = definition.name.length(); i <= commandLength; i++)
354358
cout << ' ';
355-
cout << definition.comment <<endl;
359+
cout << definition.comment << Qt::endl;
356360
}
357361
}
358362

src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int main(int argc, char **argv)
184184
foreach (QString option, args->undefinedOptions()) {
185185
if (!first)
186186
out << " : ";
187-
out << "unrecognized option or missing argument for; `" << option << "'" << endl;
187+
out << "unrecognized option or missing argument for; `" << option << "'" << Qt::endl;
188188
first = false;
189189
}
190190
return 10;

src/repository.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ long long FastImportRepository::markFrom(const QString &branchFrom, int branchRe
616616
return brFrom.marks.last();
617617
}
618618

619-
QVector<int>::const_iterator it = qUpperBound(brFrom.commits, branchRevNum);
619+
QVector<int>::const_iterator it = std::upper_bound(brFrom.commits.constBegin(), brFrom.commits.constEnd(), branchRevNum);
620620
if (it == brFrom.commits.begin()) {
621621
return 0;
622622
}
@@ -737,7 +737,7 @@ Repository::Transaction *FastImportRepository::newTransaction(const QString &bra
737737
int revnum)
738738
{
739739
if (!branchExists(branch)) {
740-
qWarning() << "WARN: Transaction:" << branch << "is not a known branch in repository" << name << endl
740+
qWarning() << "WARN: Transaction:" << branch << "is not a known branch in repository" << name << Qt::endl
741741
<< "Going to create it automatically";
742742
}
743743

@@ -1027,7 +1027,7 @@ QIODevice *FastImportRepository::Transaction::addFile(const QString &path, int m
10271027
modifiedFiles.append(" :");
10281028
modifiedFiles.append(QByteArray::number(mark));
10291029
modifiedFiles.append(' ');
1030-
modifiedFiles.append(repository->prefix + path.toUtf8());
1030+
modifiedFiles.append(repository->prefix.toUtf8() + path.toUtf8());
10311031
modifiedFiles.append("\n");
10321032

10331033
// it is returned for being written to, so start the process in any case
@@ -1080,11 +1080,11 @@ bool FastImportRepository::Transaction::commitNote(const QByteArray &noteText, b
10801080
QByteArray s("");
10811081
s.append("commit refs/notes/commits\n");
10821082
s.append("mark :" + QByteArray::number(maxMark) + "\n");
1083-
s.append("committer " + author + " " + QString::number(datetime) + " +0000" + "\n");
1084-
s.append("data " + QString::number(message.length()) + "\n");
1083+
s.append("committer " + author + " " + QByteArray::number(datetime) + " +0000" + "\n");
1084+
s.append("data " + QByteArray::number(message.length()) + "\n");
10851085
s.append(message + "\n");
10861086
s.append("N inline " + commitRef + "\n");
1087-
s.append("data " + QString::number(text.length()) + "\n");
1087+
s.append("data " + QByteArray::number(text.length()) + "\n");
10881088
s.append(text + "\n");
10891089
repository->startFastImport();
10901090
repository->fastImport.write(s);
@@ -1152,7 +1152,7 @@ int FastImportRepository::Transaction::commit()
11521152
s.append("commit " + branchRef + "\n");
11531153
s.append("mark :" + QByteArray::number(mark) + "\n");
11541154
s.append("committer " + author + " " + QString::number(datetime).toUtf8() + " +0000" + "\n");
1155-
s.append("data " + QString::number(message.length()) + "\n");
1155+
s.append("data " + QByteArray::number(message.length()) + "\n");
11561156
s.append(message + "\n");
11571157
repository->fastImport.write(s);
11581158

@@ -1161,7 +1161,7 @@ int FastImportRepository::Transaction::commit()
11611161
mark_t i = !!parentmark; // if parentmark != 0, there's at least one parent
11621162

11631163
if(log.contains("This commit was manufactured by cvs2svn") && merges.count() > 1) {
1164-
qSort(merges);
1164+
std::sort(merges.begin(), merges.end());
11651165
repository->fastImport.write("merge :" + QByteArray::number(merges.last()) + "\n");
11661166
merges.pop_back();
11671167
qWarning() << "WARN: Discarding all but the highest merge point as a workaround for cvs2svn created branch/tag"

src/ruleparser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void Rules::load(const QString &filename)
156156
qFatal("Could not read the rules file: %s", qPrintable(filename));
157157

158158
QTextStream s(&file);
159-
QStringList lines = s.readAll().split('\n', QString::KeepEmptyParts);
159+
QStringList lines = s.readAll().split('\n', Qt::KeepEmptyParts);
160160

161161
QStringList::iterator it;
162162
for(it = lines.begin(); it != lines.end(); ++it) {

src/ruleparser.h

+4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ class Rules
6363
QString replacement;
6464

6565
bool isValid() { return !pattern.isEmpty(); }
66+
#if QT_VERSION >= 0x060000
67+
QString apply(QString &string) { return pattern.replaceIn(string, replacement); }
68+
#else
6669
QString& apply(QString &string) { return string.replace(pattern, replacement); }
70+
#endif
6771
};
6872

6973
QRegExp rx;

src/src.pro

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if(!defined(VERSION, var)) {
1010
VERSION = $$system(git --no-pager show --pretty=oneline --no-notes | head -1 | cut -b-40)
1111
}
1212

13+
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x05FFFF
14+
1315
VERSTR = '\\"$${VERSION}\\"' # place quotes around the version string
1416
DEFINES += VER=\"$${VERSTR}\" # create a VER macro containing the version string
1517

@@ -27,6 +29,16 @@ target.path = $$BINDIR
2729
DEPENDPATH += .
2830
QT = core
2931

32+
_MIN_QT_VERSION = 5.14.0
33+
34+
!versionAtLeast(QT_VERSION, $${_MIN_QT_VERSION}) {
35+
error("Qt $${QT_VERSION} found but Qt >=$${_MIN_QT_VERSION} required, cannot continue.")
36+
}
37+
38+
greaterThan(QT_MAJOR_VERSION, 5) {
39+
QT += core5compat
40+
}
41+
3042
INCLUDEPATH += . $$SVN_INCLUDE $$APR_INCLUDE
3143
!isEmpty(SVN_LIBDIR): LIBS += -L$$SVN_LIBDIR
3244
LIBS += -lsvn_fs-1 -lsvn_repos-1 -lapr-1 -lsvn_subr-1

0 commit comments

Comments
 (0)