Skip to content

Support both Qt 5 and Qt 6 at the same time (fixes #163) #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,23 @@ jobs:
matrix:
include:
- runs-on: ubuntu-24.04
qt: qt5-qmake
qt_major: 6
qt_qmake: qmake6
qt_packages: qmake6 qt6-base-dev qt6-5compat-dev
- runs-on: ubuntu-24.04
qt_major: 5
qt_qmake: qmake
qt_packages: qt5-qmake qtbase5-dev
- runs-on: ubuntu-22.04
qt_major: 6
qt_qmake: qmake6
qt_packages: qmake6 qt6-base-dev libqt6core5compat6-dev
- runs-on: ubuntu-22.04
qt: qt5-qmake
qt_major: 5
qt_qmake: qmake
qt_packages: qt5-qmake qtbase5-dev

name: Build (Linux, ${{ matrix.runs-on }})
name: Build (Linux, ${{ matrix.runs-on }}, Qt ${{ matrix.qt_major }})
runs-on: ${{ matrix.runs-on }}
steps:
- name: 'Install build dependencies'
Expand All @@ -49,8 +61,7 @@ jobs:
build-essential \
libapr1-dev \
libsvn-dev \
${{ matrix.qt }} \
qtbase5-dev \
${{ matrix.qt_packages }} \
subversion

- name: 'Checkout Git branch'
Expand All @@ -59,8 +70,10 @@ jobs:
submodules: true

- name: 'Configure'
env:
QMAKE: ${{ matrix.qt_qmake }}
run: |-
qmake
${QMAKE}

- name: 'Build'
run: |-
Expand Down
16 changes: 10 additions & 6 deletions src/CommandLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void CommandLineParser::Private::addDefinitions(const CommandLineOption * option
QString option = QString::fromLatin1(options[i].specification);
// options with optional params are written as "--option required[, optional]
if (option.indexOf(QLatin1Char(',')) >= 0 && ( option.indexOf(QLatin1Char('[')) < 0 || option.indexOf(QLatin1Char(']')) < 0) ) {
QStringList optionParts = option.split(QLatin1Char(','), QString::SkipEmptyParts);
QStringList optionParts = option.split(QLatin1Char(','), Qt::SkipEmptyParts);
if (optionParts.count() != 2) {
qWarning() << "WARN: option definition '" << option << "' is faulty; only one ',' allowed";
continue;
Expand All @@ -104,7 +104,7 @@ void CommandLineParser::Private::addDefinitions(const CommandLineOption * option
if(definition.name.isEmpty())
continue;
if (option.indexOf(QLatin1Char(' ')) > 0) {
QStringList optionParts = definition.name.split(QLatin1Char(' '), QString::SkipEmptyParts);
QStringList optionParts = definition.name.split(QLatin1Char(' '), Qt::SkipEmptyParts);
definition.name = optionParts[0];
bool first = true;
foreach (QString s, optionParts) {
Expand Down Expand Up @@ -137,7 +137,7 @@ void CommandLineParser::Private::setArgumentDefinition(const char *defs)
{
requiredArguments = 0;
argumentDefinition = QString::fromLatin1(defs);
QStringList optionParts = argumentDefinition.split(QLatin1Char(' '), QString::SkipEmptyParts);
QStringList optionParts = argumentDefinition.split(QLatin1Char(' '), Qt::SkipEmptyParts);
bool inArg = false;
foreach (QString s, optionParts) {
s = s.trimmed();
Expand Down Expand Up @@ -327,18 +327,22 @@ CommandLineParser::~CommandLineParser()

void CommandLineParser::usage(const QString &name, const QString &argumentDescription)
{
#if QT_VERSION >= 0x060000
QTextStream cout(stdout, QIODeviceBase::WriteOnly);
#else
QTextStream cout(stdout, QIODevice::WriteOnly);
#endif
cout << "Usage: " << d->argumentStrings[0];
if (! name.isEmpty())
cout << " " << name;
if (d->definitions.count())
cout << " [OPTION]";
if (! argumentDescription.isEmpty())
cout << " " << argumentDescription;
cout << endl << endl;
cout << Qt::endl << Qt::endl;

if (d->definitions.count() > 0)
cout << "Options:" << endl;
cout << "Options:" << Qt::endl;
int commandLength = 0;
foreach (Private::OptionDefinition definition, d->definitions)
commandLength = qMax(definition.name.length(), commandLength);
Expand All @@ -352,7 +356,7 @@ void CommandLineParser::usage(const QString &name, const QString &argumentDescri
cout << definition.name;
for (int i = definition.name.length(); i <= commandLength; i++)
cout << ' ';
cout << definition.comment <<endl;
cout << definition.comment << Qt::endl;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ int main(int argc, char **argv)
foreach (QString option, args->undefinedOptions()) {
if (!first)
out << " : ";
out << "unrecognized option or missing argument for; `" << option << "'" << endl;
out << "unrecognized option or missing argument for; `" << option << "'" << Qt::endl;
first = false;
}
return 10;
Expand Down
16 changes: 8 additions & 8 deletions src/repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ long long FastImportRepository::markFrom(const QString &branchFrom, int branchRe
return brFrom.marks.last();
}

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

Expand Down Expand Up @@ -1027,7 +1027,7 @@ QIODevice *FastImportRepository::Transaction::addFile(const QString &path, int m
modifiedFiles.append(" :");
modifiedFiles.append(QByteArray::number(mark));
modifiedFiles.append(' ');
modifiedFiles.append(repository->prefix + path.toUtf8());
modifiedFiles.append(repository->prefix.toUtf8() + path.toUtf8());
modifiedFiles.append("\n");

// it is returned for being written to, so start the process in any case
Expand Down Expand Up @@ -1080,11 +1080,11 @@ bool FastImportRepository::Transaction::commitNote(const QByteArray &noteText, b
QByteArray s("");
s.append("commit refs/notes/commits\n");
s.append("mark :" + QByteArray::number(maxMark) + "\n");
s.append("committer " + author + " " + QString::number(datetime) + " +0000" + "\n");
s.append("data " + QString::number(message.length()) + "\n");
s.append("committer " + author + " " + QByteArray::number(datetime) + " +0000" + "\n");
s.append("data " + QByteArray::number(message.length()) + "\n");
s.append(message + "\n");
s.append("N inline " + commitRef + "\n");
s.append("data " + QString::number(text.length()) + "\n");
s.append("data " + QByteArray::number(text.length()) + "\n");
s.append(text + "\n");
repository->startFastImport();
repository->fastImport.write(s);
Expand Down Expand Up @@ -1152,7 +1152,7 @@ int FastImportRepository::Transaction::commit()
s.append("commit " + branchRef + "\n");
s.append("mark :" + QByteArray::number(mark) + "\n");
s.append("committer " + author + " " + QString::number(datetime).toUtf8() + " +0000" + "\n");
s.append("data " + QString::number(message.length()) + "\n");
s.append("data " + QByteArray::number(message.length()) + "\n");
s.append(message + "\n");
repository->fastImport.write(s);

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

if(log.contains("This commit was manufactured by cvs2svn") && merges.count() > 1) {
qSort(merges);
std::sort(merges.begin(), merges.end());
repository->fastImport.write("merge :" + QByteArray::number(merges.last()) + "\n");
merges.pop_back();
qWarning() << "WARN: Discarding all but the highest merge point as a workaround for cvs2svn created branch/tag"
Expand Down
2 changes: 1 addition & 1 deletion src/ruleparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void Rules::load(const QString &filename)
qFatal("Could not read the rules file: %s", qPrintable(filename));

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

QStringList::iterator it;
for(it = lines.begin(); it != lines.end(); ++it) {
Expand Down
4 changes: 4 additions & 0 deletions src/ruleparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ class Rules
QString replacement;

bool isValid() { return !pattern.isEmpty(); }
#if QT_VERSION >= 0x060000
QString apply(QString &string) { return pattern.replaceIn(string, replacement); }
#else
QString& apply(QString &string) { return string.replace(pattern, replacement); }
#endif
};

QRegExp rx;
Expand Down
12 changes: 12 additions & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ if(!defined(VERSION, var)) {
VERSION = $$system(git --no-pager show --pretty=oneline --no-notes | head -1 | cut -b-40)
}

DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x05FFFF

VERSTR = '\\"$${VERSION}\\"' # place quotes around the version string
DEFINES += VER=\"$${VERSTR}\" # create a VER macro containing the version string

Expand All @@ -27,6 +29,16 @@ target.path = $$BINDIR
DEPENDPATH += .
QT = core

_MIN_QT_VERSION = 5.14.0

!versionAtLeast(QT_VERSION, $${_MIN_QT_VERSION}) {
error("Qt $${QT_VERSION} found but Qt >=$${_MIN_QT_VERSION} required, cannot continue.")
}

greaterThan(QT_MAJOR_VERSION, 5) {
QT += core5compat
}

INCLUDEPATH += . $$SVN_INCLUDE $$APR_INCLUDE
!isEmpty(SVN_LIBDIR): LIBS += -L$$SVN_LIBDIR
LIBS += -lsvn_fs-1 -lsvn_repos-1 -lapr-1 -lsvn_subr-1
Expand Down
Loading