summaryrefslogtreecommitdiffstats
path: root/src/svnqt/cache/test/sqlite.cpp
blob: 979ca598c77c7416ebec9597facc641a541be35c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <tqsql.h>
#include <tqsqldatabase.h>
#include <tqstringlist.h>
#include <iostream>
#include <tqapplication.h>
#include <tqtextstream.h>

#include "svnqt/client.hpp"
#include "svnqt/svnqttypes.hpp"
#include "svnqt/log_entry.hpp"

#include "svnqt/cache/LogCache.hpp"
#include "svnqt/cache/ReposLog.hpp"
#include "svnqt/cache/test/testconfig.h"
#include "svnqt/cache/DatabaseException.hpp"

#if [[[TQT_VERSION IS DEPRECATED]]] < 0x040000
#else
#include <TQSqlQuery>
#include <TQSqlError>
#endif

int main(int argc,char**argv)
{
    TQApplication app(argc,argv);

    svn::ContextP m_CurrentContext;
    svn::Client* m_Svnclient;
    m_Svnclient=svn::Client::getobject(0,0);
    m_CurrentContext = new svn::Context();

    m_Svnclient->setContext(m_CurrentContext);

    TQStringList list;
    TQStringList::Iterator it;
    // goes into "self" of logcache
    new svn::cache::LogCache(TESTDBPATH);
    list = TQSqlDatabase::drivers();
    it = list.begin();
    while( it != list.end() ) {
        std::cout << (*it).TOUTF8().data() << std::endl;
        ++it;
    }
    svn::cache::ReposLog rl(m_Svnclient,"http://www.alwins-world.de/repos/kdesvn");
    TQDataBase db = rl.Database();
#if [[[TQT_VERSION IS DEPRECATED]]] < 0x040000
    if (!db) {
#else
    if (!db.isValid()) {
#endif
        std::cerr << "No database object."<<std::endl;
        exit(-1);
    }
#if [[[TQT_VERSION IS DEPRECATED]]] < 0x040000
    list = db->tables();
#else
    list = db.tables();
#endif
    it = list.begin();
    while( it != list.end() ) {
        std::cout << ( *it ).TOUTF8().data() << std::endl;
        ++it;
    }
    svn::LogEntriesMap lm;
    try {
        rl.simpleLog(lm,100,svn::Revision::HEAD);
    }
    catch (const svn::cache::DatabaseException&cl)
    {
        std::cerr << cl.msg().TOUTF8().data() <<std::endl;
    }
    catch (const svn::Exception&ce)
    {
        std::cerr << "Exception: " << ce.msg().TOUTF8().data() <<std::endl;
    }
    svn::LogEntriesMap::ConstIterator lit = lm.begin();
    std::cout<<"Count: "<<lm.count()<<std::endl;

    svn::Revision r("{2006-09-27}");
    std::cout << r.toString().TOUTF8().data() << " -> " << rl.date2numberRev(r).toString().TOUTF8().data()<<std::endl;
    r = svn::Revision::HEAD;
    std::cout << rl.date2numberRev(r).toString().TOUTF8().data()<<std::endl;
    try {
        rl.insertLogEntry(lm[100]);
    }
    catch (const svn::cache::DatabaseException&cl)
    {
        std::cerr << cl.msg().TOUTF8().data() << std::endl;
    }
    TQSqlQuery q("insert into logentries(revision,date,author,message) values ('100','1122591406','alwin','copy and moving works now in basic form')",db);
    q.exec();
    std::cerr << "\n" << q.lastError().text().TOUTF8().data()<<std::endl;

#if [[[TQT_VERSION IS DEPRECATED]]] < 0x040000
#else
    db=TQSqlDatabase();
#endif
    try {
        rl.log("/trunk/src/svnqt",1,1000,svn::Revision::UNDEFINED,lm,false,-1);
    }
    catch (const svn::cache::DatabaseException&cl)
    {
        std::cerr << cl.msg().TOUTF8().data() <<std::endl;
    }
    catch (const svn::Exception&ce)
    {
        std::cerr << "Exception: " << ce.msg().TOUTF8().data() <<std::endl;
    }
    std::cout<<"Count: "<<lm.count()<<std::endl;
    return 0;
}