Skip to content

Commit c80db59

Browse files
author
Freddy Henin
committed
Making the identityMap a String,String Dictionary
1 parent 87a645e commit c80db59

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/main.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,29 @@
2929
#include "repository.h"
3030
#include "svn.h"
3131

32-
QHash<QByteArray, QByteArray> loadIdentityMapFile(const QString &fileName)
32+
QHash<QString, QString> loadIdentityMapFile(const QString &fileName)
3333
{
34-
QHash<QByteArray, QByteArray> result;
35-
if (fileName.isEmpty())
34+
QHash<QString, QString> result;
35+
if (fileName.isEmpty()) {
3636
return result;
37-
37+
}
3838
QFile file(fileName);
3939
if (!file.open(QIODevice::ReadOnly)) {
4040
fprintf(stderr, "Could not open file %s: %s",
4141
qPrintable(fileName), qPrintable(file.errorString()));
4242
return result;
4343
}
44-
45-
while (!file.atEnd()) {
46-
QByteArray line = file.readLine();
44+
QTextStream in(&file);
45+
while (!in.atEnd()) {
46+
QString line = in.readLine();
4747
int comment_pos = line.indexOf('#');
4848
if (comment_pos != -1)
4949
line.truncate(comment_pos);
5050
line = line.trimmed();
5151
int space = line.indexOf(' ');
52-
if (space == -1)
53-
continue; // invalid line
54-
52+
if (space == -1) {
53+
continue;
54+
} // invalid line
5555
// Support git-svn author files, too
5656
// - svn2git native: loginname Joe User <user@example.com>
5757
// - git-svn: loginname = Joe User <user@example.com>
@@ -64,9 +64,8 @@ QHash<QByteArray, QByteArray> loadIdentityMapFile(const QString &fileName)
6464
rightspace += 2;
6565
}
6666

67-
QByteArray realname = line.mid(rightspace).trimmed();
67+
QString realname = line.mid(rightspace).trimmed();
6868
line.truncate(leftspace);
69-
7069
result.insert(line, realname);
7170
};
7271
file.close();

src/svn.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
typedef QList<Rules::Match> MatchRuleList;
6060
typedef QHash<QString, Repository *> RepositoryHash;
61-
typedef QHash<QByteArray, QByteArray> IdentityHash;
61+
typedef QHash<QString, QString> IdentityHash;
6262

6363
class AprAutoPool
6464
{
@@ -403,7 +403,7 @@ class SvnRevision
403403
int revnum;
404404

405405
// must call fetchRevProps first:
406-
QByteArray authorident;
406+
QString authorident;
407407
QByteArray log;
408408
uint epoch;
409409
bool ruledebug;
@@ -575,9 +575,11 @@ int SvnRevision::fetchRevProps()
575575
log = svnlog->data;
576576
else
577577
log.clear();
578-
authorident = svnauthor ? identities.value(svnauthor->data) : QByteArray();
578+
QByteArray svnByteArray = QByteArray((char*)svnauthor->data, 10);
579+
authorident = svnauthor ? identities.value(svnByteArray) : QString();
579580
epoch = svndate ? get_epoch(svndate->data) : 0;
580581
if (authorident.isEmpty()) {
582+
printf("Author Identity NOT Found in file\n");
581583
if (!svnauthor || svn_string_isempty(svnauthor))
582584
authorident = "nobody <nobody@localhost>";
583585
else
@@ -598,7 +600,7 @@ int SvnRevision::commit()
598600
}
599601

600602
foreach (Repository::Transaction *txn, transactions) {
601-
txn->setAuthor(authorident);
603+
txn->setAuthor(authorident.toUtf8());
602604
txn->setDateTime(epoch);
603605
txn->setLog(log);
604606

@@ -852,7 +854,7 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change2_t *ch
852854
if (rule.annotate) {
853855
// create an annotated tag
854856
fetchRevProps();
855-
repo->createAnnotatedTag(branch, svnprefix, revnum, authorident,
857+
repo->createAnnotatedTag(branch, svnprefix, revnum, authorident.toUtf8(),
856858
epoch, log);
857859
}
858860
return EXIT_SUCCESS;
@@ -937,7 +939,7 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change2_t *ch
937939
if (rule.annotate) {
938940
// create an annotated tag
939941
fetchRevProps();
940-
repo->createAnnotatedTag(branch, svnprefix, revnum, authorident,
942+
repo->createAnnotatedTag(branch, svnprefix, revnum, authorident.toUtf8(),
941943
epoch, log);
942944
}
943945

src/svn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Svn
3535

3636
void setMatchRules(const QList<QList<Rules::Match> > &matchRules);
3737
void setRepositories(const QHash<QString, Repository *> &repositories);
38-
void setIdentityMap(const QHash<QByteArray, QByteArray> &identityMap);
38+
void setIdentityMap(const QHash<QString, QString> &identityMap);
3939
void setIdentityDomain(const QString &identityDomain);
4040

4141
int youngestRevision();

0 commit comments

Comments
 (0)