SVN client - prefix error constants.

Avoid Windows clashes on common names (NO_ERROR, etc)
This commit is contained in:
James Turner 2013-06-19 08:42:30 +01:00
parent c391fcd345
commit 4d26e144ab
4 changed files with 29 additions and 33 deletions

View File

@ -154,10 +154,6 @@ namespace {
headerLength = p - _ptr; headerLength = p - _ptr;
_ptr = p; _ptr = p;
if (sourceViewOffset != 0) {
cout << "sourceViewOffset:" << sourceViewOffset << endl;
}
} }
bool apply(std::vector<char>& output, std::istream& source) bool apply(std::vector<char>& output, std::istream& source)
@ -168,7 +164,7 @@ namespace {
while (_ptr < pEnd) { while (_ptr < pEnd) {
int op = ((*_ptr >> 6) & 0x3); int op = ((*_ptr >> 6) & 0x3);
if (op >= 3) { if (op >= 3) {
std::cerr << "weird opcode" << endl; SG_LOG(SG_IO, SG_INFO, "SVNDeltaWindow: bad opcode:" << op);
return false; return false;
} }
@ -180,7 +176,7 @@ namespace {
} }
if (length == 0) { if (length == 0) {
std::cerr << "malformed stream, 0 length" << std::endl; SG_LOG(SG_IO, SG_INFO, "SVNDeltaWindow: malformed stream, 0 length" << op);
return false; return false;
} }
@ -233,7 +229,7 @@ class SVNReportParser::SVNReportParserPrivate
public: public:
SVNReportParserPrivate(SVNRepository* repo) : SVNReportParserPrivate(SVNRepository* repo) :
tree(repo), tree(repo),
status(SVNRepository::NO_ERROR), status(SVNRepository::SVN_NO_ERROR),
parserInited(false), parserInited(false),
currentPath(repo->fsBase()) currentPath(repo->fsBase())
{ {
@ -247,7 +243,7 @@ public:
void startElement (const char * name, const char** attributes) void startElement (const char * name, const char** attributes)
{ {
if (status != SVNRepository::NO_ERROR) { if (status != SVNRepository::SVN_NO_ERROR) {
return; return;
} }
@ -365,7 +361,7 @@ public:
void endElement (const char * name) void endElement (const char * name)
{ {
if (status != SVNRepository::NO_ERROR) { if (status != SVNRepository::SVN_NO_ERROR) {
return; return;
} }
@ -373,7 +369,7 @@ public:
tagStack.pop_back(); tagStack.pop_back();
if (!strcmp(name, SVN_TXDELTA_TAG)) { if (!strcmp(name, SVN_TXDELTA_TAG)) {
if (!decodeTextDelta(currentPath)) { if (!decodeTextDelta(currentPath)) {
fail(SVNRepository::ERROR_TXDELTA); fail(SVNRepository::SVN_ERROR_TXDELTA);
} }
} else if (!strcmp(name, SVN_ADD_FILE_TAG)) { } else if (!strcmp(name, SVN_ADD_FILE_TAG)) {
finishFile(currentDir->addChildFile(currentPath.file())); finishFile(currentDir->addChildFile(currentPath.file()));
@ -400,7 +396,7 @@ public:
} else if (!strcmp(name, SVN_DAV_MD5_CHECKSUM)) { } else if (!strcmp(name, SVN_DAV_MD5_CHECKSUM)) {
// validate against (presumably) just written file // validate against (presumably) just written file
if (decodedFileMd5 != md5Sum) { if (decodedFileMd5 != md5Sum) {
fail(SVNRepository::ERROR_CHECKSUM); fail(SVNRepository::SVN_ERROR_CHECKSUM);
} }
} else if (!strcmp(name, SVN_OPEN_DIRECTORY_TAG)) { } else if (!strcmp(name, SVN_OPEN_DIRECTORY_TAG)) {
if (currentDir->parent()) { if (currentDir->parent()) {
@ -425,7 +421,7 @@ public:
void data (const char * s, int length) void data (const char * s, int length)
{ {
if (status != SVNRepository::NO_ERROR) { if (status != SVNRepository::SVN_NO_ERROR) {
return; return;
} }
@ -525,7 +521,7 @@ SVNReportParser::~SVNReportParser()
SVNRepository::ResultCode SVNRepository::ResultCode
SVNReportParser::innerParseXML(const char* data, int size) SVNReportParser::innerParseXML(const char* data, int size)
{ {
if (_d->status != SVNRepository::NO_ERROR) { if (_d->status != SVNRepository::SVN_NO_ERROR) {
return _d->status; return _d->status;
} }
@ -537,7 +533,7 @@ SVNReportParser::innerParseXML(const char* data, int size)
XML_ParserFree(_d->xmlParser); XML_ParserFree(_d->xmlParser);
_d->parserInited = false; _d->parserInited = false;
return SVNRepository::ERROR_XML; return SVNRepository::SVN_ERROR_XML;
} else if (isEnd) { } else if (isEnd) {
XML_ParserFree(_d->xmlParser); XML_ParserFree(_d->xmlParser);
_d->parserInited = false; _d->parserInited = false;
@ -549,7 +545,7 @@ SVNReportParser::innerParseXML(const char* data, int size)
SVNRepository::ResultCode SVNRepository::ResultCode
SVNReportParser::parseXML(const char* data, int size) SVNReportParser::parseXML(const char* data, int size)
{ {
if (_d->status != SVNRepository::NO_ERROR) { if (_d->status != SVNRepository::SVN_NO_ERROR) {
return _d->status; return _d->status;
} }
@ -567,7 +563,7 @@ SVNReportParser::parseXML(const char* data, int size)
SVNRepository::ResultCode SVNReportParser::finishParse() SVNRepository::ResultCode SVNReportParser::finishParse()
{ {
if (_d->status != SVNRepository::NO_ERROR) { if (_d->status != SVNRepository::SVN_NO_ERROR) {
return _d->status; return _d->status;
} }

View File

@ -54,7 +54,7 @@ public:
SVNRepoPrivate(SVNRepository* parent) : SVNRepoPrivate(SVNRepository* parent) :
p(parent), p(parent),
isUpdating(false), isUpdating(false),
status(SVNRepository::NO_ERROR) status(SVNRepository::SVN_NO_ERROR)
{ ; } { ; }
SVNRepository* p; // link back to outer SVNRepository* p; // link back to outer
@ -161,11 +161,11 @@ namespace { // anonmouse
if (responseCode() == 207) { if (responseCode() == 207) {
// fine // fine
} else if (responseCode() == 404) { } else if (responseCode() == 404) {
_repo->propFindFailed(this, SVNRepository::ERROR_NOT_FOUND); _repo->propFindFailed(this, SVNRepository::SVN_ERROR_NOT_FOUND);
} else { } else {
SG_LOG(SG_IO, SG_WARN, "request for:" << url() << SG_LOG(SG_IO, SG_WARN, "request for:" << url() <<
" return code " << responseCode()); " return code " << responseCode());
_repo->propFindFailed(this, SVNRepository::ERROR_SOCKET); _repo->propFindFailed(this, SVNRepository::SVN_ERROR_SOCKET);
} }
} }
@ -261,12 +261,12 @@ protected:
_repo->svnUpdateDone(); _repo->svnUpdateDone();
} }
} else if (responseCode() == 404) { } else if (responseCode() == 404) {
_repo->updateFailed(this, SVNRepository::ERROR_NOT_FOUND); _repo->updateFailed(this, SVNRepository::SVN_ERROR_NOT_FOUND);
_failed = true; _failed = true;
} else { } else {
SG_LOG(SG_IO, SG_WARN, "SVN: request for:" << url() << SG_LOG(SG_IO, SG_WARN, "SVN: request for:" << url() <<
" return code " << responseCode()); " return code " << responseCode());
_repo->updateFailed(this, SVNRepository::ERROR_SOCKET); _repo->updateFailed(this, SVNRepository::SVN_ERROR_SOCKET);
_failed = true; _failed = true;
} }
} }
@ -351,7 +351,7 @@ bool SVNRepository::isBare() const
void SVNRepository::update() void SVNRepository::update()
{ {
_d->status = NO_ERROR; _d->status = SVN_NO_ERROR;
if (_d->targetRevision.empty() || _d->vccUrl.empty()) { if (_d->targetRevision.empty() || _d->vccUrl.empty()) {
_d->isUpdating = true; _d->isUpdating = true;
PropFindRequest* pfr = new PropFindRequest(_d.get()); PropFindRequest* pfr = new PropFindRequest(_d.get());
@ -373,7 +373,7 @@ void SVNRepository::update()
bool SVNRepository::isDoingSync() const bool SVNRepository::isDoingSync() const
{ {
if (_d->status != NO_ERROR) { if (_d->status != SVN_NO_ERROR) {
return false; return false;
} }
@ -403,7 +403,7 @@ void SVNRepoPrivate::propFindComplete(HTTP::Request* req, DAVCollection* c)
void SVNRepoPrivate::propFindFailed(HTTP::Request *req, SVNRepository::ResultCode err) void SVNRepoPrivate::propFindFailed(HTTP::Request *req, SVNRepository::ResultCode err)
{ {
if (err != SVNRepository::ERROR_NOT_FOUND) { if (err != SVNRepository::SVN_ERROR_NOT_FOUND) {
SG_LOG(SG_IO, SG_WARN, "PropFind failed for:" << req->url()); SG_LOG(SG_IO, SG_WARN, "PropFind failed for:" << req->url());
} }

View File

@ -55,13 +55,13 @@ public:
bool isDoingSync() const; bool isDoingSync() const;
enum ResultCode { enum ResultCode {
NO_ERROR = 0, SVN_NO_ERROR = 0,
ERROR_NOT_FOUND, SVN_ERROR_NOT_FOUND,
ERROR_SOCKET, SVN_ERROR_SOCKET,
ERROR_XML, SVN_ERROR_XML,
ERROR_TXDELTA, SVN_ERROR_TXDELTA,
ERROR_IO, SVN_ERROR_IO,
ERROR_CHECKSUM SVN_ERROR_CHECKSUM
}; };
ResultCode failure() const; ResultCode failure() const;

View File

@ -415,10 +415,10 @@ bool SGTerraSync::SvnThread::syncTreeInternal(const char* dir)
_http.update(100); _http.update(100);
} }
if (_repository->failure() == SVNRepository::ERROR_NOT_FOUND) { if (_repository->failure() == SVNRepository::SVN_ERROR_NOT_FOUND) {
// this is fine, but maybe we should use a different return code // this is fine, but maybe we should use a different return code
// in the future to higher layers can distuinguish this case // in the future to higher layers can distuinguish this case
} else if (_repository->failure() != SVNRepository::NO_ERROR) { } else if (_repository->failure() != SVNRepository::SVN_NO_ERROR) {
result = false; result = false;
} else { } else {
SG_LOG(SG_IO, SG_DEBUG, "sync of " << command.str() << " finished (" SG_LOG(SG_IO, SG_DEBUG, "sync of " << command.str() << " finished ("