summaryrefslogtreecommitdiffstats
path: root/src/svnqt/cache/ReposLog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/svnqt/cache/ReposLog.cpp')
-rw-r--r--src/svnqt/cache/ReposLog.cpp200
1 files changed, 57 insertions, 143 deletions
diff --git a/src/svnqt/cache/ReposLog.cpp b/src/svnqt/cache/ReposLog.cpp
index 89be2d0..54c4622 100644
--- a/src/svnqt/cache/ReposLog.cpp
+++ b/src/svnqt/cache/ReposLog.cpp
@@ -7,26 +7,14 @@
#include "svnqt/context_listener.hpp"
#include "svnqt/cache/DatabaseException.hpp"
-#include <qsqldatabase.h>
-
-#if QT_VERSION < 0x040000
-#else
-#include <QSqlError>
-#include <QSqlQuery>
-#include <QVariant>
-#define Q_LLONG qlonglong
-#endif
+#include <tqsqldatabase.h>
/*!
- \fn svn::cache::ReposLog::ReposLog(svn::Client*aClient,const QString&)
+ \fn svn::cache::ReposLog::ReposLog(svn::Client*aClient,const TQString&)
*/
-svn::cache::ReposLog::ReposLog(svn::Client*aClient,const QString&aRepository)
+svn::cache::ReposLog::ReposLog(svn::Client*aClient,const TQString&aRepository)
:m_Client(),
-#if QT_VERSION < 0x040000
m_Database(0),
-#else
- m_Database(),
-#endif
m_ReposRoot(aRepository),m_latestHead(svn::Revision::UNDEFINED)
{
m_Client=aClient;
@@ -45,17 +33,9 @@ svn::Revision svn::cache::ReposLog::latestHeadRev()
if (!m_Client||m_ReposRoot.isEmpty()) {
return svn::Revision::UNDEFINED;
}
-#if QT_VERSION < 0x040000
if (!m_Database) {
-#else
- if (!m_Database.isValid()) {
-#endif
m_Database = LogCache::self()->reposDb(m_ReposRoot);
-#if QT_VERSION < 0x040000
if (!m_Database) {
-#else
- if (!m_Database.isValid()) {
-#endif
return svn::Revision::UNDEFINED;
}
}
@@ -78,22 +58,15 @@ svn::Revision svn::cache::ReposLog::latestCachedRev()
if (m_ReposRoot.isEmpty()) {
return svn::Revision::UNDEFINED;
}
-#if QT_VERSION < 0x040000
if (!m_Database) {
-#else
- if (!m_Database.isValid()) {
-#endif
+
m_Database = LogCache::self()->reposDb(m_ReposRoot);
-#if QT_VERSION < 0x040000
if (!m_Database) {
-#else
- if (!m_Database.isValid()) {
-#endif
return svn::Revision::UNDEFINED;
}
}
- QString q("select revision from 'logentries' order by revision DESC limit 1");
- QSqlQuery _q(QString::null, m_Database);
+ TQString q("select revision from 'logentries' order by revision DESC limit 1");
+ TQSqlQuery _q(TQString(), m_Database);
if (!_q.exec(q)) {
qDebug(_q.lastError().text().TOUTF8().data());
return svn::Revision::UNDEFINED;
@@ -111,17 +84,9 @@ svn::Revision svn::cache::ReposLog::latestCachedRev()
bool svn::cache::ReposLog::checkFill(svn::Revision&start,svn::Revision&end,bool checkHead)
{
-#if QT_VERSION < 0x040000
if (!m_Database) {
-#else
- if (!m_Database.isValid()) {
-#endif
m_Database = LogCache::self()->reposDb(m_ReposRoot);
-#if QT_VERSION < 0x040000
if (!m_Database) {
-#else
- if (!m_Database.isValid()) {
-#endif
return false;
}
}
@@ -173,7 +138,7 @@ bool svn::cache::ReposLog::checkFill(svn::Revision&start,svn::Revision&end,bool
if (cp && cp->getListener()) {
//cp->getListener()->contextProgress(++icount,_internal.size());
if (cp->getListener()->contextCancel()) {
- throw DatabaseException(QString("Could not retrieve values: User cancel."));
+ throw DatabaseException(TQString("Could not retrieve values: User cancel."));
}
}
}
@@ -216,24 +181,24 @@ bool svn::cache::ReposLog::simpleLog(LogEntriesMap&target,const svn::Revision&_s
if (start==svn::Revision::HEAD) {
start=latestCachedRev();
}
- static QString sCount("select count(*) from logentries where revision<=? and revision>=?");
- static QString sEntry("select revision,author,date,message from logentries where revision<=? and revision>=?");
- static QString sItems("select changeditem,action,copyfrom,copyfromrev from changeditems where revision=?");
+ static TQString sCount("select count(*) from logentries where revision<=? and revision>=?");
+ static TQString sEntry("select revision,author,date,message from logentries where revision<=? and revision>=?");
+ static TQString sItems("select changeditem,action,copyfrom,copyfromrev from changeditems where revision=?");
- QSqlQuery bcount(QString::null,m_Database);
+ TQSqlQuery bcount(TQString(),m_Database);
bcount.prepare(sCount);
- QSqlQuery bcur(QString::null,m_Database);
+ TQSqlQuery bcur(TQString(),m_Database);
bcur.prepare(sEntry);
- QSqlQuery cur(QString::null,m_Database);
+ TQSqlQuery cur(TQString(),m_Database);
cur.prepare(sItems);
- bcount.bindValue(0,Q_LLONG(end.revnum()));
- bcount.bindValue(1,Q_LLONG(start.revnum()));
+ bcount.bindValue(0,TQ_LLONG(end.revnum()));
+ bcount.bindValue(1,TQ_LLONG(start.revnum()));
if (!bcount.exec()) {
qDebug(bcount.lastError().text().TOUTF8().data());
- throw svn::cache::DatabaseException(QString("Could not retrieve count: ")+bcount.lastError().text());
+ throw svn::cache::DatabaseException(TQString("Could not retrieve count: ")+bcount.lastError().text());
return false;
}
bcount.next();
@@ -242,21 +207,21 @@ bool svn::cache::ReposLog::simpleLog(LogEntriesMap&target,const svn::Revision&_s
return false;
}
- bcur.bindValue(0,Q_LLONG(end.revnum()));
- bcur.bindValue(1,Q_LLONG(start.revnum()));
+ bcur.bindValue(0,TQ_LLONG(end.revnum()));
+ bcur.bindValue(1,TQ_LLONG(start.revnum()));
if (!bcur.exec()) {
qDebug(bcur.lastError().text().TOUTF8().data());
- throw svn::cache::DatabaseException(QString("Could not retrieve values: ")+bcur.lastError().text());
+ throw svn::cache::DatabaseException(TQString("Could not retrieve values: ")+bcur.lastError().text());
return false;
}
- Q_LLONG revision;
+ TQ_LLONG revision;
while(bcur.next()) {
revision = bcur.value(0).toLongLong();
cur.bindValue(0,revision);
if (!cur.exec()) {
qDebug(cur.lastError().text().TOUTF8().data());
- throw svn::cache::DatabaseException(QString("Could not retrieve values: ")+cur.lastError().text()
+ throw svn::cache::DatabaseException(TQString("Could not retrieve values: ")+cur.lastError().text()
,cur.lastError().number());
return false;
}
@@ -266,12 +231,8 @@ bool svn::cache::ReposLog::simpleLog(LogEntriesMap&target,const svn::Revision&_s
target[revision].message=bcur.value(3).toString();
while(cur.next()) {
LogChangePathEntry lcp;
- QString ac = cur.value(1).toString();
-#if QT_VERSION < 0x040000
+ TQString ac = cur.value(1).toString();
lcp.action=ac[0].latin1();
-#else
- lcp.action=ac[0].toLatin1();
-#endif
lcp.copyFromPath=cur.value(2).toString();
lcp.path= cur.value(0).toString();
lcp.copyFromRevision=cur.value(3).toLongLong();
@@ -279,7 +240,7 @@ bool svn::cache::ReposLog::simpleLog(LogEntriesMap&target,const svn::Revision&_s
}
if (cp && cp->getListener()) {
if (cp->getListener()->contextCancel()) {
- throw svn::cache::DatabaseException(QString("Could not retrieve values: User cancel."));
+ throw svn::cache::DatabaseException(TQString("Could not retrieve values: User cancel."));
return false;
}
}
@@ -296,21 +257,13 @@ svn::Revision svn::cache::ReposLog::date2numberRev(const svn::Revision&aRev,bool
if (aRev!=svn::Revision::DATE) {
return aRev;
}
-#if QT_VERSION < 0x040000
if (!m_Database) {
-#else
- if (!m_Database.isValid()) {
-#endif
return svn::Revision::UNDEFINED;
}
- static QString _q("select revision from logentries where date<? order by revision desc");
- QSqlQuery query("select revision,date from logentries order by revision desc limit 1",m_Database);
+ static TQString _q("select revision from logentries where date<? order by revision desc");
+ TQSqlQuery query("select revision,date from logentries order by revision desc limit 1",m_Database);
-#if QT_VERSION < 0x040000
- if (query.lastError().type()!=QSqlError::None) {
-#else
- if (query.lastError().type()!=QSqlError::NoError) {
-#endif
+ if (query.lastError().type()!=TQSqlError::None) {
qDebug(query.lastError().text().TOUTF8().data());
}
bool must_remote=!noNetwork;
@@ -327,13 +280,9 @@ svn::Revision svn::cache::ReposLog::date2numberRev(const svn::Revision&aRev,bool
return e[0].revision();
}
query.prepare(_q);
- query.bindValue(0,Q_LLONG(aRev.date()));
+ query.bindValue(0,TQ_LLONG(aRev.date()));
query.exec();
-#if QT_VERSION < 0x040000
- if (query.lastError().type()!=QSqlError::None) {
-#else
- if (query.lastError().type()!=QSqlError::NoError) {
-#endif
+ if (query.lastError().type()!=TQSqlError::None) {
qDebug(query.lastError().text().TOUTF8().data());
}
if (query.next()) {
@@ -356,57 +305,40 @@ svn::Revision svn::cache::ReposLog::date2numberRev(const svn::Revision&aRev,bool
*/
bool svn::cache::ReposLog::_insertLogEntry(const svn::LogEntry&aEntry)
{
- QSqlRecord *buffer;
+ TQSqlRecord *buffer;
-#if QT_VERSION < 0x040000
m_Database->transaction();
- Q_LLONG j = aEntry.revision;
-#else
- m_Database.transaction();
- qlonglong j = aEntry.revision;
-#endif
- static QString qEntry("insert into logentries (revision,date,author,message) values (?,?,?,?)");
- static QString qPathes("insert into changeditems (revision,changeditem,action,copyfrom,copyfromrev) values (?,?,?,?,?)");
- QSqlQuery _q(QString::null,m_Database);
+ TQ_LLONG j = aEntry.revision;
+ static TQString qEntry("insert into logentries (revision,date,author,message) values (?,?,?,?)");
+ static TQString qPathes("insert into changeditems (revision,changeditem,action,copyfrom,copyfromrev) values (?,?,?,?,?)");
+ TQSqlQuery _q(TQString(),m_Database);
_q.prepare(qEntry);
_q.bindValue(0,j);
_q.bindValue(1,aEntry.date);
_q.bindValue(2,aEntry.author);
_q.bindValue(3,aEntry.message);
if (!_q.exec()) {
-#if QT_VERSION < 0x040000
m_Database->rollback();
-#else
- m_Database.rollback();
-#endif
qDebug("Could not insert values: %s",_q.lastError().text().TOUTF8().data());
qDebug(_q.lastQuery().TOUTF8().data());
- throw svn::cache::DatabaseException(QString("Could not insert values: ")+_q.lastError().text(),_q.lastError().number());
+ throw svn::cache::DatabaseException(TQString("Could not insert values: ")+_q.lastError().text(),_q.lastError().number());
}
_q.prepare(qPathes);
svn::LogChangePathEntries::ConstIterator cpit = aEntry.changedPaths.begin();
for (;cpit!=aEntry.changedPaths.end();++cpit){
_q.bindValue(0,j);
_q.bindValue(1,(*cpit).path);
- _q.bindValue(2,QString(QChar((*cpit).action)));
+ _q.bindValue(2,TQString(TQChar((*cpit).action)));
_q.bindValue(3,(*cpit).copyFromPath);
- _q.bindValue(4,Q_LLONG((*cpit).copyFromRevision));
+ _q.bindValue(4,TQ_LLONG((*cpit).copyFromRevision));
if (!_q.exec()) {
-#if QT_VERSION < 0x040000
m_Database->rollback();
-#else
- m_Database.rollback();
-#endif
qDebug("Could not insert values: %s",_q.lastError().text().TOUTF8().data());
qDebug(_q.lastQuery().TOUTF8().data());
- throw svn::cache::DatabaseException(QString("Could not insert values: ")+_q.lastError().text(),_q.lastError().number());
+ throw svn::cache::DatabaseException(TQString("Could not insert values: ")+_q.lastError().text(),_q.lastError().number());
}
}
-#if QT_VERSION < 0x040000
m_Database->commit();
-#else
- m_Database.commit();
-#endif
return true;
}
@@ -421,44 +353,43 @@ bool svn::cache::ReposLog::insertLogEntry(const svn::LogEntry&aEntry)
*/
bool svn::cache::ReposLog::log(const svn::Path&what,const svn::Revision&_start, const svn::Revision&_end,const svn::Revision&_peg,svn::LogEntriesMap&target, bool strictNodeHistory,int limit)
{
- static QString s_q("select logentries.revision,logentries.author,logentries.date,logentries.message from logentries where logentries.revision in (select changeditems.revision from changeditems where (changeditems.changeditem='%1' or changeditems.changeditem GLOB '%2/*') %3 GROUP BY changeditems.revision) ORDER BY logentries.revision DESC");
+ static TQString s_q("select logentries.revision,logentries.author,logentries.date,logentries.message from logentries where logentries.revision in (select changeditems.revision from changeditems where (changeditems.changeditem='%1' or changeditems.changeditem GLOB '%2/*') %3 GROUP BY changeditems.revision) ORDER BY logentries.revision DESC");
- static QString s_e("select changeditem,action,copyfrom,copyfromrev from changeditems where changeditems.revision='%1'");
+ static TQString s_e("select changeditem,action,copyfrom,copyfromrev from changeditems where changeditems.revision='%1'");
svn::Revision peg = date2numberRev(_peg,true);
svn::Revision end = date2numberRev(_end,true);
svn::Revision start = date2numberRev(_start,true);
- QString query_string = QString(s_q).arg(what.native()).arg(what.native()).arg((peg==svn::Revision::UNDEFINED?"":QString(" AND revision<=%1").arg(peg.revnum())));
+ TQString query_string = TQString(s_q).tqarg(what.native()).tqarg(what.native()).tqarg((peg==svn::Revision::UNDEFINED?"":TQString(" AND revision<=%1").tqarg(peg.revnum())));
if (peg==svn::Revision::UNDEFINED) {
peg = latestCachedRev();
}
if (!itemExists(peg,what)) {
- throw svn::cache::DatabaseException(QString("Entry '%1' does not exists at revision %2").arg(what.native()).arg(peg.toString()));
+ throw svn::cache::DatabaseException(TQString("Entry '%1' does not exists at revision %2").tqarg(what.native()).tqarg(peg.toString()));
}
if (limit>0) {
- query_string+=QString(" LIMIT %1").arg(limit);
+ query_string+=TQString(" LIMIT %1").tqarg(limit);
}
- QSqlQuery _q(QString::null,m_Database);
- QSqlQuery _q2(QString::null,m_Database);
+ TQSqlQuery _q(TQString(),m_Database);
+ TQSqlQuery _q2(TQString(),m_Database);
_q.prepare(query_string);
if (!_q.exec()) {
qDebug("Could not select values: %s",_q.lastError().text().TOUTF8().data());
qDebug(_q.lastQuery().TOUTF8().data());
- throw svn::cache::DatabaseException(QString("Could not select values: ")+_q.lastError().text(),_q.lastError().number());
+ throw svn::cache::DatabaseException(TQString("Could not select values: ")+_q.lastError().text(),_q.lastError().number());
}
while(_q.next()) {
- Q_LLONG revision = _q.value(0).toLongLong();
+ TQ_LLONG revision = _q.value(0).toLongLong();
target[revision].revision=revision;
target[revision].author=_q.value(1).toString();
target[revision].date=_q.value(2).toLongLong();
target[revision].message=_q.value(3).toString();
- query_string=s_e.arg(revision);
+ query_string=s_e.tqarg(revision);
_q2.prepare(query_string);
if (!_q2.exec()) {
qDebug("Could not select values: %s",_q2.lastError().text().TOUTF8().data());
} else {
while (_q2.next()) {
-#if QT_VERSION < 0x040000
target[revision].changedPaths.push_back (
LogChangePathEntry (_q2.value(0).toString(),
_q2.value(1).toString()[0],
@@ -466,15 +397,6 @@ bool svn::cache::ReposLog::log(const svn::Path&what,const svn::Revision&_start,
_q2.value(3).toLongLong()
)
);
-#else
- target[revision].changedPaths.push_back (
- LogChangePathEntry (_q2.value(0).toString(),
- _q2.value(1).toChar().toLatin1(),
- _q2.value(2).toString(),
- _q2.value(3).toLongLong()
- )
- );
-#endif
}
}
@@ -484,50 +406,42 @@ bool svn::cache::ReposLog::log(const svn::Path&what,const svn::Revision&_start,
/*!
- \fn svn::cache::ReposLog::itemExists(const svn::Revision&,const QString&)
+ \fn svn::cache::ReposLog::itemExists(const svn::Revision&,const TQString&)
*/
bool svn::cache::ReposLog::itemExists(const svn::Revision&peg,const svn::Path&path)
{
- /// @todo this moment I have no idea how to check real with all moves and deletes of parent folders without a hell of sql statements so we make it quite simple: it exists if we found it.
+ /// @todo this moment I have no idea how to check real with all moves and deletes of tqparent folders without a hell of sql statements so we make it quite simple: it exists if we found it.
#if 0
- static QString _s1("select revision from changeditems where changeditem='%1' and action='A' and revision<=%2 order by revision desc limit 1");
- QSqlQuery _q(QString::null,m_Database);
- QString query_string=QString(_s1).arg(path.native()).arg(peg.revnum());
+ static TQString _s1("select revision from changeditems where changeditem='%1' and action='A' and revision<=%2 order by revision desc limit 1");
+ TQSqlQuery _q(TQString(),m_Database);
+ TQString query_string=TQString(_s1).tqarg(path.native()).tqarg(peg.revnum());
if (!_q.exec(query_string)) {
qDebug("Could not select values: %s",_q.lastError().text().TOUTF8().data());
qDebug(_q.lastQuery().TOUTF8().data());
- throw svn::cache::DatabaseException(QString("Could not select values: ")+_q.lastError().text(),_q.lastError().number());
+ throw svn::cache::DatabaseException(TQString("Could not select values: ")+_q.lastError().text(),_q.lastError().number());
}
qDebug(_q.lastQuery().TOUTF8().data());
svn::Path _p = path;
- static QString _s2("select revision from changeditem where changeditem in (%1) and action='D' and revision>%2 and revision<=%3 order by revision desc limit 1");
- QStringList p_list;
+ static TQString _s2("select revision from changeditem where changeditem in (%1) and action='D' and revision>%2 and revision<=%3 order by revision desc limit 1");
+ TQStringList p_list;
while (_p.length()>0) {
- p_list.append(QString("'%1'").arg(_p.native()));
+ p_list.append(TQString("'%1'").tqarg(_p.native()));
_p.removeLast();
}
- query_string=QString(_s2).arg(p_list.join(",")).arg();
+ query_string=TQString(_s2).tqarg(p_list.join(",")).tqarg();
#endif
return true;
}
bool svn::cache::ReposLog::isValid()const
{
-#if QT_VERSION < 0x040000
if (!m_Database) {
-#else
- if (!m_Database.isValid()) {
-#endif
m_Database = LogCache::self()->reposDb(m_ReposRoot);
-#if QT_VERSION < 0x040000
if (!m_Database) {
-#else
- if (!m_Database.isValid()) {
-#endif
return false;
}
}