repository.cpp 2.94 KB
Newer Older
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
/*
 * Copyright (c) 2002 Christian Loose <christian.loose@hamburg.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 */

#include "repository.h"

#include <qfile.h>
#include <qstring.h>
#include <kapplication.h>
#include <kconfig.h>


struct Repository::Private
{
    QString client;
    QString location;
    QString rsh;
34
    QString server;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    int     compressionLevel;

    void readConfig();
};


void Repository::Private::readConfig()
{
    KConfig* config = kapp->config();
    config->setGroup(QString::fromLatin1("Repository-") + location);

    // see if there is a specific compression level set for this repository
    compressionLevel = config->readNumEntry("Compression", -1);

    // use default global compression level instead?
    if( compressionLevel < 0 )
    {
        config->setGroup("General");
        compressionLevel = config->readNumEntry("Compression", 0);
    }

56
57
58
59
60
    // get remote shell client to access the remote repository
    rsh = config->readEntry("rsh");
    
    // get program to start on the server side
    server = config->readEntry("cvs_server");
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
112
113
114
115
116
117
118
119
120
    
    // get path to cvs client programm
    config->setGroup("General");
    client = config->readEntry("CVSPath", "cvs");   
}



Repository::Repository(const QString& workingCopyDir)
    : d(new Private)
{
    // initialize private data
    d->compressionLevel = 0;

    // determine path to the repository
    QFile rootFile(workingCopyDir + "/CVS/Root");
    if( rootFile.open(IO_ReadOnly) ) 
    {
        QTextStream stream(&rootFile);
        d->location = stream.readLine();
    }
    rootFile.close();

    d->readConfig();
}


Repository::~Repository()
{
    delete d;
}


QString Repository::cvsClient() const
{
    QString client(d->client);

    // suppress reading of the '.cvsrc' file
    client += " -f";

    // we don't need the command line option if there is no compression level set
    if( d->compressionLevel > 0 )
    {
        client += " -z" + QString::number(d->compressionLevel) + " ";
    }

    return client;
}


void Repository::updateConfig()
{
    d->readConfig();
}


QString Repository::location() const
{
    return d->location;
}
121
122
123
124
125
126

    
QString Repository::rsh() const
{
    return d->rsh;
}
127
128
129
130
131
132


QString Repository::server() const
{
    return d->server;
}