Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making the identityMap a String,String Dictionary #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@
#include "repository.h"
#include "svn.h"

QHash<QByteArray, QByteArray> loadIdentityMapFile(const QString &fileName)
QHash<QString, QString> loadIdentityMapFile(const QString &fileName)
{
QHash<QByteArray, QByteArray> result;
if (fileName.isEmpty())
QHash<QString, QString> result;
if (fileName.isEmpty()) {
return result;

}
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
fprintf(stderr, "Could not open file %s: %s",
qPrintable(fileName), qPrintable(file.errorString()));
return result;
}

while (!file.atEnd()) {
QByteArray line = file.readLine();
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
int comment_pos = line.indexOf('#');
if (comment_pos != -1)
line.truncate(comment_pos);
line = line.trimmed();
int space = line.indexOf(' ');
if (space == -1)
continue; // invalid line

if (space == -1) {
continue;
} // invalid line
// Support git-svn author files, too
// - svn2git native: loginname Joe User <user@example.com>
// - git-svn: loginname = Joe User <user@example.com>
Expand All @@ -64,9 +64,8 @@ QHash<QByteArray, QByteArray> loadIdentityMapFile(const QString &fileName)
rightspace += 2;
}

QByteArray realname = line.mid(rightspace).trimmed();
QString realname = line.mid(rightspace).trimmed();
line.truncate(leftspace);

result.insert(line, realname);
};
file.close();
Expand Down
14 changes: 8 additions & 6 deletions src/svn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

typedef QList<Rules::Match> MatchRuleList;
typedef QHash<QString, Repository *> RepositoryHash;
typedef QHash<QByteArray, QByteArray> IdentityHash;
typedef QHash<QString, QString> IdentityHash;

class AprAutoPool
{
Expand Down Expand Up @@ -403,7 +403,7 @@ class SvnRevision
int revnum;

// must call fetchRevProps first:
QByteArray authorident;
QString authorident;
QByteArray log;
uint epoch;
bool ruledebug;
Expand Down Expand Up @@ -575,9 +575,11 @@ int SvnRevision::fetchRevProps()
log = svnlog->data;
else
log.clear();
authorident = svnauthor ? identities.value(svnauthor->data) : QByteArray();
QByteArray svnByteArray = QByteArray((char*)svnauthor->data, 10);
authorident = svnauthor ? identities.value(svnByteArray) : QString();
epoch = svndate ? get_epoch(svndate->data) : 0;
if (authorident.isEmpty()) {
printf("Author Identity NOT Found in file\n");
if (!svnauthor || svn_string_isempty(svnauthor))
authorident = "nobody <nobody@localhost>";
else
Expand All @@ -598,7 +600,7 @@ int SvnRevision::commit()
}

foreach (Repository::Transaction *txn, transactions) {
txn->setAuthor(authorident);
txn->setAuthor(authorident.toUtf8());
txn->setDateTime(epoch);
txn->setLog(log);

Expand Down Expand Up @@ -852,7 +854,7 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change2_t *ch
if (rule.annotate) {
// create an annotated tag
fetchRevProps();
repo->createAnnotatedTag(branch, svnprefix, revnum, authorident,
repo->createAnnotatedTag(branch, svnprefix, revnum, authorident.toUtf8(),
epoch, log);
}
return EXIT_SUCCESS;
Expand Down Expand Up @@ -937,7 +939,7 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change2_t *ch
if (rule.annotate) {
// create an annotated tag
fetchRevProps();
repo->createAnnotatedTag(branch, svnprefix, revnum, authorident,
repo->createAnnotatedTag(branch, svnprefix, revnum, authorident.toUtf8(),
epoch, log);
}

Expand Down
2 changes: 1 addition & 1 deletion src/svn.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Svn

void setMatchRules(const QList<QList<Rules::Match> > &matchRules);
void setRepositories(const QHash<QString, Repository *> &repositories);
void setIdentityMap(const QHash<QByteArray, QByteArray> &identityMap);
void setIdentityMap(const QHash<QString, QString> &identityMap);
void setIdentityDomain(const QString &identityDomain);

int youngestRevision();
Expand Down