Skip to content

Commit 7d919c1

Browse files
DaElftnyblom
authored andcommitted
Svn deprecated functions (#11)
* Update the libsvn calls to current non-deprecated As of svn 1.9 this change cleans up the warnings. * The pools are cleaned up by AprAutoPool Adding the pools destroy to the Svn destructor results in a double free.
1 parent bed9282 commit 7d919c1

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/svn.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ class AprAutoPool
6262
AprAutoPool &operator=(const AprAutoPool &);
6363
public:
6464
inline AprAutoPool(apr_pool_t *parent = NULL)
65-
{ pool = svn_pool_create(parent); }
66-
inline ~AprAutoPool()
67-
{ svn_pool_destroy(pool); }
65+
{
66+
pool = svn_pool_create(parent);
67+
}
68+
inline ~AprAutoPool()
69+
{
70+
svn_pool_destroy(pool);
71+
}
6872

6973
inline void clear() { svn_pool_clear(pool); }
7074
inline apr_pool_t *data() const { return pool; }
@@ -88,6 +92,7 @@ class SvnPrivate
8892

8993
private:
9094
AprAutoPool global_pool;
95+
AprAutoPool scratch_pool;
9196
svn_fs_t *fs;
9297
svn_revnum_t youngest_rev;
9398
};
@@ -145,7 +150,7 @@ bool Svn::exportRevision(int revnum)
145150
}
146151

147152
SvnPrivate::SvnPrivate(const QString &pathToRepository)
148-
: global_pool(NULL)
153+
: global_pool(NULL) , scratch_pool(NULL)
149154
{
150155
if( openRepository(pathToRepository) != EXIT_SUCCESS) {
151156
qCritical() << "Failed to open repository";
@@ -156,10 +161,7 @@ SvnPrivate::SvnPrivate(const QString &pathToRepository)
156161
svn_fs_youngest_rev(&youngest_rev, fs, global_pool);
157162
}
158163

159-
SvnPrivate::~SvnPrivate()
160-
{
161-
svn_pool_destroy(global_pool);
162-
}
164+
SvnPrivate::~SvnPrivate() {}
163165

164166
int SvnPrivate::youngestRevision()
165167
{
@@ -172,7 +174,7 @@ int SvnPrivate::openRepository(const QString &pathToRepository)
172174
QString path = pathToRepository;
173175
while (path.endsWith('/')) // no trailing slash allowed
174176
path = path.mid(0, path.length()-1);
175-
SVN_ERR(svn_repos_open(&repos, QFile::encodeName(path), global_pool));
177+
SVN_ERR(svn_repos_open3(&repos, QFile::encodeName(path), NULL, global_pool, scratch_pool));
176178
fs = svn_repos_fs(repos);
177179

178180
return EXIT_SUCCESS;
@@ -297,7 +299,7 @@ static int dumpBlob(Repository::Transaction *txn, svn_fs_root_t *fs_root,
297299
if (!CommandLineParser::instance()->contains("dry-run")) {
298300
QByteArray buf;
299301
buf.reserve(len);
300-
SVN_ERR(svn_stream_read(in_stream, buf.data(), &len));
302+
SVN_ERR(svn_stream_read_full(in_stream, buf.data(), &len));
301303
if (len == strlen("link ") && strncmp(buf, "link ", len) == 0) {
302304
mode = 0120000;
303305
stream_length -= len;
@@ -316,9 +318,7 @@ static int dumpBlob(Repository::Transaction *txn, svn_fs_root_t *fs_root,
316318
if (!CommandLineParser::instance()->contains("dry-run")) {
317319
// open a generic svn_stream_t for the QIODevice
318320
out_stream = streamForDevice(io, dumppool);
319-
SVN_ERR(svn_stream_copy(in_stream, out_stream, dumppool));
320-
svn_stream_close(out_stream);
321-
svn_stream_close(in_stream);
321+
SVN_ERR(svn_stream_copy3(in_stream, out_stream, NULL, NULL, dumppool));
322322

323323
// print an ending newline
324324
io->putChar('\n');
@@ -430,15 +430,15 @@ class SvnRevision
430430
int fetchRevProps();
431431
int commit();
432432

433-
int exportEntry(const char *path, const svn_fs_path_change_t *change, apr_hash_t *changes);
434-
int exportDispatch(const char *path, const svn_fs_path_change_t *change,
433+
int exportEntry(const char *path, const svn_fs_path_change2_t *change, apr_hash_t *changes);
434+
int exportDispatch(const char *path, const svn_fs_path_change2_t *change,
435435
const char *path_from, svn_revnum_t rev_from,
436436
apr_hash_t *changes, const QString &current, const Rules::Match &rule,
437437
const MatchRuleList &matchRules, apr_pool_t *pool);
438-
int exportInternal(const char *path, const svn_fs_path_change_t *change,
438+
int exportInternal(const char *path, const svn_fs_path_change2_t *change,
439439
const char *path_from, svn_revnum_t rev_from,
440440
const QString &current, const Rules::Match &rule, const MatchRuleList &matchRules);
441-
int recurse(const char *path, const svn_fs_path_change_t *change,
441+
int recurse(const char *path, const svn_fs_path_change2_t *change,
442442
const char *path_from, const MatchRuleList &matchRules, svn_revnum_t rev_from,
443443
apr_hash_t *changes, apr_pool_t *pool);
444444
};
@@ -477,15 +477,15 @@ int SvnRevision::prepareTransactions()
477477
{
478478
// find out what was changed in this revision:
479479
apr_hash_t *changes;
480-
SVN_ERR(svn_fs_paths_changed(&changes, fs_root, pool));
480+
SVN_ERR(svn_fs_paths_changed2(&changes, fs_root, pool));
481481

482-
QMap<QByteArray, svn_fs_path_change_t*> map;
482+
QMap<QByteArray, svn_fs_path_change2_t*> map;
483483
for (apr_hash_index_t *i = apr_hash_first(pool, changes); i; i = apr_hash_next(i)) {
484484
const void *vkey;
485485
void *value;
486486
apr_hash_this(i, &vkey, NULL, &value);
487487
const char *key = reinterpret_cast<const char *>(vkey);
488-
svn_fs_path_change_t *change = reinterpret_cast<svn_fs_path_change_t *>(value);
488+
svn_fs_path_change2_t *change = reinterpret_cast<svn_fs_path_change2_t *>(value);
489489
// If we mix path deletions with path adds/replaces we might erase a
490490
// branch after that it has been reset -> history truncated
491491
if (map.contains(QByteArray(key))) {
@@ -502,7 +502,7 @@ int SvnRevision::prepareTransactions()
502502
map.insertMulti(QByteArray(key), change);
503503
}
504504

505-
QMapIterator<QByteArray, svn_fs_path_change_t*> i(map);
505+
QMapIterator<QByteArray, svn_fs_path_change2_t*> i(map);
506506
while (i.hasNext()) {
507507
i.next();
508508
if (exportEntry(i.key(), i.value(), changes) == EXIT_FAILURE)
@@ -561,7 +561,7 @@ int SvnRevision::commit()
561561
return EXIT_SUCCESS;
562562
}
563563

564-
int SvnRevision::exportEntry(const char *key, const svn_fs_path_change_t *change,
564+
int SvnRevision::exportEntry(const char *key, const svn_fs_path_change2_t *change,
565565
apr_hash_t *changes)
566566
{
567567
AprAutoPool revpool(pool.data());
@@ -647,7 +647,7 @@ int SvnRevision::exportEntry(const char *key, const svn_fs_path_change_t *change
647647
return EXIT_SUCCESS;
648648
}
649649

650-
int SvnRevision::exportDispatch(const char *key, const svn_fs_path_change_t *change,
650+
int SvnRevision::exportDispatch(const char *key, const svn_fs_path_change2_t *change,
651651
const char *path_from, svn_revnum_t rev_from,
652652
apr_hash_t *changes, const QString &current,
653653
const Rules::Match &rule, const MatchRuleList &matchRules, apr_pool_t *pool)
@@ -685,7 +685,7 @@ int SvnRevision::exportDispatch(const char *key, const svn_fs_path_change_t *cha
685685
return EXIT_FAILURE;
686686
}
687687

688-
int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *change,
688+
int SvnRevision::exportInternal(const char *key, const svn_fs_path_change2_t *change,
689689
const char *path_from, svn_revnum_t rev_from,
690690
const QString &current, const Rules::Match &rule, const MatchRuleList &matchRules)
691691
{
@@ -837,7 +837,7 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *cha
837837
return EXIT_SUCCESS;
838838
}
839839

840-
int SvnRevision::recurse(const char *path, const svn_fs_path_change_t *change,
840+
int SvnRevision::recurse(const char *path, const svn_fs_path_change2_t *change,
841841
const char *path_from, const MatchRuleList &matchRules, svn_revnum_t rev_from,
842842
apr_hash_t *changes, apr_pool_t *pool)
843843
{
@@ -882,8 +882,8 @@ int SvnRevision::recurse(const char *path, const svn_fs_path_change_t *change,
882882
entryFrom = path_from + QByteArray("/") + i.key();
883883

884884
// check if this entry is in the changelist for this revision already
885-
svn_fs_path_change_t *otherchange =
886-
(svn_fs_path_change_t*)apr_hash_get(changes, entry.constData(), APR_HASH_KEY_STRING);
885+
svn_fs_path_change2_t *otherchange =
886+
(svn_fs_path_change2_t*)apr_hash_get(changes, entry.constData(), APR_HASH_KEY_STRING);
887887
if (otherchange && otherchange->change_kind == svn_fs_path_change_add) {
888888
qDebug() << entry << "rev" << revnum
889889
<< "is in the change-list, deferring to that one";

0 commit comments

Comments
 (0)