Refactored UnityPipe into Pipe and UnityConnection into Connection and moved protocol dependent stuff to Connection where it belongs.
This commit is contained in:
Родитель
1f09236765
Коммит
0fe6aeb30b
|
@ -1,5 +1,5 @@
|
|||
#include "Changes.h"
|
||||
#include "UnityPipe.h"
|
||||
#include "Connection.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
@ -50,13 +50,13 @@ void Changelist::SetCommitter(const std::string& committer)
|
|||
m_Committer = committer;
|
||||
}
|
||||
|
||||
//UnityPipe& operator<<(UnityPipe& p, ChangelistRevision revision)
|
||||
//Connection& operator<<(Connection& p, ChangelistRevision revision)
|
||||
//{
|
||||
// p << revision.c_str();
|
||||
// return p;
|
||||
//}
|
||||
|
||||
UnityPipe& operator>>(UnityPipe& p, ChangelistRevision& revision)
|
||||
Connection& operator>>(Connection& p, ChangelistRevision& revision)
|
||||
{
|
||||
string line;
|
||||
p.ReadLine(line);
|
||||
|
@ -64,14 +64,14 @@ UnityPipe& operator>>(UnityPipe& p, ChangelistRevision& revision)
|
|||
return p;
|
||||
}
|
||||
|
||||
UnityPipe& operator<<(UnityPipe& p, const Changelist& changelist)
|
||||
Connection& operator<<(Connection& p, const Changelist& changelist)
|
||||
{
|
||||
p.DataLine(changelist.GetRevision().c_str());
|
||||
p.DataLine(changelist.GetDescription());
|
||||
return p;
|
||||
}
|
||||
|
||||
UnityPipe& operator>>(UnityPipe& p, Changelist& cl)
|
||||
Connection& operator>>(Connection& p, Changelist& cl)
|
||||
{
|
||||
string line;
|
||||
p.ReadLine(line);
|
||||
|
|
|
@ -35,8 +35,8 @@ private:
|
|||
typedef std::vector<Changelist> Changes;
|
||||
typedef std::vector<ChangelistRevision> ChangelistRevisions;
|
||||
|
||||
struct UnityPipe;
|
||||
//UnityPipe& operator<<(UnityPipe& p, ChangelistRevision revision);
|
||||
UnityPipe& operator>>(UnityPipe& p, ChangelistRevision& revision);
|
||||
UnityPipe& operator<<(UnityPipe& p, const Changelist& changelist);
|
||||
UnityPipe& operator>>(UnityPipe& p, Changelist& changelist);
|
||||
struct Connection;
|
||||
//Connection& operator<<(Connection& p, ChangelistRevision revision);
|
||||
Connection& operator>>(Connection& p, ChangelistRevision& revision);
|
||||
Connection& operator<<(Connection& p, const Changelist& changelist);
|
||||
Connection& operator>>(Connection& p, Changelist& changelist);
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
class AddRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
AddRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
AddRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
conn.Pipe() >> assetList;
|
||||
conn >> assetList;
|
||||
}
|
||||
|
||||
VersionedAssetList assetList;
|
||||
|
|
|
@ -3,17 +3,12 @@
|
|||
class BaseRequest
|
||||
{
|
||||
public:
|
||||
BaseRequest(const CommandArgs& args, UnityConnection& conn) : args(args), conn(conn), invalid(false)
|
||||
BaseRequest(const CommandArgs& args, Connection& conn) : args(args), conn(conn), invalid(false)
|
||||
{
|
||||
}
|
||||
|
||||
UnityPipe& Pipe()
|
||||
{
|
||||
return conn.Pipe();
|
||||
}
|
||||
|
||||
const CommandArgs& args;
|
||||
UnityConnection& conn;
|
||||
Connection& conn;
|
||||
bool invalid;
|
||||
};
|
||||
|
||||
|
|
|
@ -7,17 +7,16 @@ template <int>
|
|||
class BaseFileSetRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
BaseFileSetRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
BaseFileSetRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
assets.clear();
|
||||
UnityPipe& upipe = conn.Pipe();
|
||||
upipe >> assets;
|
||||
conn >> assets;
|
||||
|
||||
if (assets.empty())
|
||||
{
|
||||
assets.clear();
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
|
@ -43,20 +42,19 @@ template <class Req>
|
|||
class BaseFileSetResponse : public BaseResponse
|
||||
{
|
||||
public:
|
||||
BaseFileSetResponse(Req& req) : request(req) {}
|
||||
BaseFileSetResponse(Req& req) : request(req), conn(req.conn) {}
|
||||
|
||||
void Write()
|
||||
{
|
||||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
Req& request;
|
||||
Connection& conn;
|
||||
VersionedAssetList assets;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,17 +6,16 @@
|
|||
class ChangeDescriptionRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
ChangeDescriptionRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
ChangeDescriptionRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
UnityPipe& upipe = conn.Pipe();
|
||||
upipe >> revision;
|
||||
conn >> revision;
|
||||
|
||||
if (revision.empty())
|
||||
{
|
||||
VersionedAssetList assets;
|
||||
upipe << assets;
|
||||
upipe.ErrorLine("Cannot get assets for empty revision");
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.ErrorLine("Cannot get assets for empty revision");
|
||||
conn.EndResponse();
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
|
@ -27,18 +26,18 @@ public:
|
|||
class ChangeDescriptionResponse : public BaseResponse
|
||||
{
|
||||
public:
|
||||
ChangeDescriptionResponse(ChangeDescriptionRequest& req) : request(req) {}
|
||||
ChangeDescriptionResponse(ChangeDescriptionRequest& req) : request(req), conn(req.conn) {}
|
||||
|
||||
void Write()
|
||||
{
|
||||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
upipe.DataLine(description);
|
||||
upipe.EndResponse();
|
||||
conn.DataLine(description);
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
ChangeDescriptionRequest& request;
|
||||
Connection& conn;
|
||||
std::string description;
|
||||
};
|
||||
|
|
|
@ -19,10 +19,8 @@ enum ConfigKey
|
|||
class ConfigRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
ConfigRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
ConfigRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
UnityPipe& upipe = conn.Pipe();
|
||||
|
||||
if (args.size() < 2)
|
||||
{
|
||||
std::string msg = "Plugin got invalid config setting :";
|
||||
|
@ -30,8 +28,8 @@ public:
|
|||
msg += " ";
|
||||
msg += *i;
|
||||
}
|
||||
upipe.WarnLine(msg, MAConfig);
|
||||
upipe.EndResponse();
|
||||
conn.WarnLine(msg, MAConfig);
|
||||
conn.EndResponse();
|
||||
invalid = true;
|
||||
return;
|
||||
}
|
||||
|
@ -51,16 +49,16 @@ public:
|
|||
values = std::vector<std::string>(args.begin()+2, args.end());
|
||||
}
|
||||
|
||||
unityplugin::LogLevel GetLogLevel() const
|
||||
LogLevel GetLogLevel() const
|
||||
{
|
||||
std::string val = Values();
|
||||
unityplugin::LogLevel level = unityplugin::LOG_DEBUG;
|
||||
LogLevel level = LOG_DEBUG;
|
||||
if (val == "info")
|
||||
level = unityplugin::LOG_INFO;
|
||||
level = LOG_INFO;
|
||||
else if (val == "notice")
|
||||
level = unityplugin::LOG_NOTICE;
|
||||
level = LOG_NOTICE;
|
||||
else if (val == "fatal")
|
||||
level = unityplugin::LOG_FATAL;
|
||||
level = LOG_FATAL;
|
||||
return level;
|
||||
}
|
||||
|
||||
|
@ -95,7 +93,7 @@ public:
|
|||
};
|
||||
|
||||
ConfigResponse(ConfigRequest& req)
|
||||
: request(req), requiresNetwork(false),
|
||||
: request(req), conn(req.conn), requiresNetwork(false),
|
||||
enablesCheckout(true), enablesLocking(true), enablesRevertUnchanged(true)
|
||||
{
|
||||
}
|
||||
|
@ -113,15 +111,13 @@ public:
|
|||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
|
||||
switch (request.key)
|
||||
{
|
||||
case CK_Versions:
|
||||
{
|
||||
int v = SelectVersion(request.values);
|
||||
upipe.DataLine(v, MAConfig);
|
||||
upipe.Log().Info() << "Selected plugin protocol version " << v << unityplugin::Endl;
|
||||
conn.DataLine(v, MAConfig);
|
||||
conn.Log().Info() << "Selected plugin protocol version " << v << Endl;
|
||||
break;
|
||||
}
|
||||
case CK_Traits:
|
||||
|
@ -133,33 +129,33 @@ public:
|
|||
(enablesLocking ? 1 : 0) +
|
||||
(enablesRevertUnchanged ? 1 : 0);
|
||||
|
||||
upipe.DataLine(count);
|
||||
conn.DataLine(count);
|
||||
|
||||
if (requiresNetwork)
|
||||
upipe.DataLine("requiresNetwork", MAConfig);
|
||||
conn.DataLine("requiresNetwork", MAConfig);
|
||||
if (enablesCheckout)
|
||||
upipe.DataLine("enablesCheckout", MAConfig);
|
||||
conn.DataLine("enablesCheckout", MAConfig);
|
||||
if (enablesLocking)
|
||||
upipe.DataLine("enablesLocking", MAConfig);
|
||||
conn.DataLine("enablesLocking", MAConfig);
|
||||
if (enablesRevertUnchanged)
|
||||
upipe.DataLine("enablesRevertUnchanged", MAConfig);
|
||||
conn.DataLine("enablesRevertUnchanged", MAConfig);
|
||||
|
||||
// The per plugin defined traits
|
||||
upipe.DataLine(traits.size());
|
||||
conn.DataLine(traits.size());
|
||||
|
||||
for (std::vector<PluginTrait>::const_iterator i = traits.begin();
|
||||
i != traits.end(); ++i)
|
||||
{
|
||||
upipe.DataLine(i->id);
|
||||
upipe.DataLine(i->label, MAConfig);
|
||||
upipe.DataLine(i->description, MAConfig);
|
||||
upipe.DataLine(i->defaultValue);
|
||||
upipe.DataLine(i->flags);
|
||||
conn.DataLine(i->id);
|
||||
conn.DataLine(i->label, MAConfig);
|
||||
conn.DataLine(i->description, MAConfig);
|
||||
conn.DataLine(i->defaultValue);
|
||||
conn.DataLine(i->flags);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
upipe.EndResponse();
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
void AddSupportedVersion(int v)
|
||||
|
@ -174,7 +170,8 @@ public:
|
|||
std::vector<PluginTrait> traits;
|
||||
std::set<int> supportedVersions;
|
||||
|
||||
ConfigRequest request;
|
||||
ConfigRequest& request;
|
||||
Connection& conn;
|
||||
private:
|
||||
|
||||
int SelectVersion(const CommandArgs& args)
|
||||
|
|
|
@ -5,19 +5,18 @@
|
|||
class DownloadRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
DownloadRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
DownloadRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
assets.clear();
|
||||
UnityPipe& upipe = conn.Pipe();
|
||||
upipe >> targetDir;
|
||||
upipe >> revisions;
|
||||
upipe >> assets;
|
||||
conn >> targetDir;
|
||||
conn >> revisions;
|
||||
conn >> assets;
|
||||
|
||||
if (assets.empty() || revisions.empty())
|
||||
{
|
||||
assets.clear();
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
|
@ -32,19 +31,18 @@ public:
|
|||
class DownloadResponse : public BaseResponse
|
||||
{
|
||||
public:
|
||||
DownloadResponse(DownloadRequest& req) : request(req) {}
|
||||
DownloadResponse(DownloadRequest& req) : request(req), conn(req.conn) {}
|
||||
|
||||
void Write()
|
||||
{
|
||||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
DownloadRequest& request;
|
||||
Connection& conn;
|
||||
VersionedAssetList assets;
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
class IncomingRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
IncomingRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
IncomingRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -13,7 +13,7 @@ public:
|
|||
class IncomingResponse : public BaseResponse
|
||||
{
|
||||
public:
|
||||
IncomingResponse(IncomingRequest& req) : request(req) {}
|
||||
IncomingResponse(IncomingRequest& req) : request(req), conn(req.conn) {}
|
||||
|
||||
void AddChangeSet(const Changelist& cl)
|
||||
{
|
||||
|
@ -25,12 +25,12 @@ public:
|
|||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
upipe << changeSets;
|
||||
upipe.EndResponse();
|
||||
conn << changeSets;
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
IncomingRequest& request;
|
||||
Connection& conn;
|
||||
Changes changeSets;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,17 +6,16 @@
|
|||
class IncomingAssetsRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
IncomingAssetsRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
IncomingAssetsRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
UnityPipe& upipe = conn.Pipe();
|
||||
upipe >> revision;
|
||||
conn >> revision;
|
||||
|
||||
if (revision.empty())
|
||||
{
|
||||
VersionedAssetList assets;
|
||||
upipe << assets;
|
||||
upipe.ErrorLine("Cannot get assets for empty revision");
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.ErrorLine("Cannot get assets for empty revision");
|
||||
conn.EndResponse();
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
|
@ -27,19 +26,19 @@ public:
|
|||
class IncomingAssetsResponse : public BaseResponse
|
||||
{
|
||||
public:
|
||||
IncomingAssetsResponse(IncomingAssetsRequest& req) : request(req) {}
|
||||
IncomingAssetsResponse(IncomingAssetsRequest& req) : request(req), conn(req.conn) {}
|
||||
|
||||
void Write()
|
||||
{
|
||||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
IncomingAssetsRequest& request;
|
||||
Connection& conn;
|
||||
VersionedAssetList assets;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,18 +6,17 @@
|
|||
class MoveChangelistRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
MoveChangelistRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
MoveChangelistRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
assets.clear();
|
||||
UnityPipe& upipe = conn.Pipe();
|
||||
upipe >> changelist;
|
||||
upipe >> assets;
|
||||
conn >> changelist;
|
||||
conn >> assets;
|
||||
|
||||
if (assets.empty())
|
||||
{
|
||||
assets.clear();
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
|
@ -30,19 +29,18 @@ public:
|
|||
class MoveChangelistResponse : public BaseResponse
|
||||
{
|
||||
public:
|
||||
MoveChangelistResponse(MoveChangelistRequest& req) : request(req) {}
|
||||
MoveChangelistResponse(MoveChangelistRequest& req) : request(req), conn(req.conn) {}
|
||||
|
||||
void Write()
|
||||
{
|
||||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
MoveChangelistRequest& request;
|
||||
Connection& conn;
|
||||
VersionedAssetList assets;
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
class OutgoingRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
OutgoingRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
OutgoingRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -13,7 +13,7 @@ public:
|
|||
class OutgoingResponse : public BaseResponse
|
||||
{
|
||||
public:
|
||||
OutgoingResponse(OutgoingRequest& req) : request(req) {}
|
||||
OutgoingResponse(OutgoingRequest& req) : request(req), conn(req.conn) {}
|
||||
|
||||
void AddChangeSet(const std::string& name, const std::string& revision)
|
||||
{
|
||||
|
@ -28,11 +28,11 @@ public:
|
|||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
upipe << changeSets;
|
||||
upipe.EndResponse();
|
||||
conn << changeSets;
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
OutgoingRequest& request;
|
||||
Connection& conn;
|
||||
Changes changeSets;
|
||||
};
|
||||
|
|
|
@ -6,17 +6,16 @@
|
|||
class OutgoingAssetsRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
OutgoingAssetsRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
OutgoingAssetsRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
UnityPipe& upipe = conn.Pipe();
|
||||
upipe >> revision;
|
||||
conn >> revision;
|
||||
|
||||
if (revision.empty())
|
||||
{
|
||||
VersionedAssetList assets;
|
||||
upipe << assets;
|
||||
upipe.ErrorLine("Cannot get assets for empty revision");
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.ErrorLine("Cannot get assets for empty revision");
|
||||
conn.EndResponse();
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
|
@ -27,18 +26,18 @@ public:
|
|||
class OutgoingAssetsResponse : public BaseResponse
|
||||
{
|
||||
public:
|
||||
OutgoingAssetsResponse(OutgoingAssetsRequest& req) : request(req) {}
|
||||
OutgoingAssetsResponse(OutgoingAssetsRequest& req) : request(req), conn(req.conn) {}
|
||||
|
||||
void Write()
|
||||
{
|
||||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
OutgoingAssetsRequest& request;
|
||||
Connection& conn;
|
||||
VersionedAssetList assets;
|
||||
};
|
||||
|
|
|
@ -5,18 +5,17 @@
|
|||
class SubmitRequest : public BaseRequest
|
||||
{
|
||||
public:
|
||||
SubmitRequest(const CommandArgs& args, UnityConnection& conn) : BaseRequest(args, conn)
|
||||
SubmitRequest(const CommandArgs& args, Connection& conn) : BaseRequest(args, conn)
|
||||
{
|
||||
assets.clear();
|
||||
UnityPipe& upipe = conn.Pipe();
|
||||
upipe >> changelist;
|
||||
upipe >> assets;
|
||||
conn >> changelist;
|
||||
conn >> assets;
|
||||
|
||||
if (assets.empty())
|
||||
{
|
||||
assets.clear();
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
|
@ -29,20 +28,19 @@ public:
|
|||
class SubmitResponse : public BaseResponse
|
||||
{
|
||||
public:
|
||||
SubmitResponse(SubmitRequest& req) : request(req) {}
|
||||
SubmitResponse(SubmitRequest& req) : request(req), conn(req.conn) {}
|
||||
|
||||
void Write()
|
||||
{
|
||||
if (request.invalid)
|
||||
return;
|
||||
|
||||
UnityPipe& upipe = request.conn.Pipe();
|
||||
|
||||
upipe << assets;
|
||||
upipe.EndResponse();
|
||||
conn << assets;
|
||||
conn.EndResponse();
|
||||
}
|
||||
|
||||
SubmitRequest& request;
|
||||
Connection& conn;
|
||||
VersionedAssetList assets;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,218 @@
|
|||
#include "Connection.h"
|
||||
#include "Utility.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const char* DATA_PREFIX = "o";
|
||||
const char* VERBOSE_PREFIX = "v";
|
||||
const char* ERROR_PREFIX = "e";
|
||||
const char* WARNING_PREFIX = "w";
|
||||
const char* INFO_PREFIX = "i";
|
||||
const char* COMMAND_PREFIX = "c";
|
||||
const char* PROGRESS_PREFIX = "p";
|
||||
|
||||
Connection::Connection(const string& logPath)
|
||||
: m_Log(logPath), m_Pipe(NULL) { }
|
||||
|
||||
Connection::~Connection()
|
||||
{
|
||||
delete m_Pipe;
|
||||
m_Pipe = NULL;
|
||||
}
|
||||
|
||||
void Connection::Connect()
|
||||
{
|
||||
m_Pipe = new Pipe();
|
||||
}
|
||||
|
||||
// read a command from stdin
|
||||
UnityCommand Connection::ReadCommand(CommandArgs& args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsConnected())
|
||||
Connect();
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
Log().Notice() << "While reading command: " << e.what() << Endl;
|
||||
return UCOM_Invalid;
|
||||
}
|
||||
|
||||
args.clear();
|
||||
string read;
|
||||
ReadLine(read);
|
||||
|
||||
if (read.empty())
|
||||
{
|
||||
// broken pipe -> error.
|
||||
if (!m_Pipe->IsEOF())
|
||||
{
|
||||
ErrorLine("Read empty command from connection");
|
||||
return UCOM_Invalid;
|
||||
}
|
||||
|
||||
Log().Info() << "End of pipe" << Endl;
|
||||
return UCOM_Shutdown;
|
||||
}
|
||||
|
||||
// Skip non-command lines if present
|
||||
size_t stopCounter = 1000;
|
||||
while (read.substr(0, 2) != "c:" && stopCounter--)
|
||||
{
|
||||
ReadLine(read);
|
||||
}
|
||||
|
||||
if (!stopCounter)
|
||||
{
|
||||
ErrorLine("Too many bogus lines");
|
||||
return UCOM_Invalid;
|
||||
}
|
||||
|
||||
string command = read.substr(2);
|
||||
|
||||
if (Tokenize(args, command) == 0)
|
||||
{
|
||||
ErrorLine(string("invalid formatted - '") + command + "'");
|
||||
return UCOM_Invalid;
|
||||
}
|
||||
return StringToUnityCommand(args[0].c_str());
|
||||
}
|
||||
|
||||
LogStream& Connection::Log()
|
||||
{
|
||||
return m_Log;
|
||||
}
|
||||
|
||||
bool Connection::IsConnected() const
|
||||
{
|
||||
return m_Pipe != NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Pipe& Connection::GetPipe()
|
||||
{
|
||||
return *m_Pipe;
|
||||
}
|
||||
*/
|
||||
|
||||
void Connection::Flush()
|
||||
{
|
||||
m_Pipe->Flush();
|
||||
}
|
||||
|
||||
Connection& Connection::BeginList()
|
||||
{
|
||||
// Start sending list of unknown size
|
||||
DataLine("-1");
|
||||
return *this;
|
||||
}
|
||||
|
||||
Connection& Connection::EndList()
|
||||
{
|
||||
// d is list delimiter
|
||||
WriteLine("d1:end of list", m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
Connection& Connection::EndResponse()
|
||||
{
|
||||
WriteLine("r1:end of response\n", m_Log.Debug());
|
||||
m_Log.Debug() << "\n--------------------------\n";
|
||||
m_Log.Flush();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Connection& Connection::Command(const std::string& cmd, MessageArea ma)
|
||||
{
|
||||
WritePrefixLine(COMMAND_PREFIX, ma, cmd, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
static void DecodeString(string& target)
|
||||
{
|
||||
std::string::size_type len = target.length();
|
||||
std::string::size_type n1 = 0;
|
||||
std::string::size_type n2 = 0;
|
||||
|
||||
while ( n1 < len && (n2 = target.find('\\', n1)) != std::string::npos &&
|
||||
n2+1 < len )
|
||||
{
|
||||
char c = target[n2+1];
|
||||
if ( c == '\\' )
|
||||
{
|
||||
target.replace(n2, 2, "\\");
|
||||
len--;
|
||||
}
|
||||
else if ( c == 'n')
|
||||
{
|
||||
target.replace(n2, 2, "\n");
|
||||
len--;
|
||||
}
|
||||
n1 = n2 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
std::string& Connection::ReadLine(std::string& target)
|
||||
{
|
||||
m_Pipe->ReadLine(target);
|
||||
DecodeString(target);
|
||||
m_Log.Debug() << "UNITY > " << target << Endl;
|
||||
return target;
|
||||
}
|
||||
|
||||
std::string& Connection::PeekLine(std::string& target)
|
||||
{
|
||||
m_Pipe->PeekLine(target);
|
||||
DecodeString(target);
|
||||
return target;
|
||||
}
|
||||
|
||||
// Params: -1 means not specified
|
||||
Connection& Connection::Progress(int pct, time_t timeSoFar, const std::string& message, MessageArea ma)
|
||||
{
|
||||
string msg = IntToString(pct) + " " + IntToString((int)timeSoFar) + " " + message;
|
||||
WritePrefixLine(PROGRESS_PREFIX, ma, msg, m_Log.Notice());
|
||||
return *this;
|
||||
}
|
||||
|
||||
Connection& Connection::operator<<(const std::vector<std::string>& v)
|
||||
{
|
||||
DataLine(v.size());
|
||||
for (std::vector<std::string>::const_iterator i = v.begin(); i != v.end(); ++i)
|
||||
WriteLine(*i, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
Connection& Connection::WritePrefix(const char* prefix, MessageArea ma, LogWriter& log)
|
||||
{
|
||||
Write(prefix, log);
|
||||
Write(ma, log);
|
||||
Write(":", log);
|
||||
}
|
||||
|
||||
|
||||
// Encode newlines in strings
|
||||
Connection& Connection::Write(const std::string& v, LogWriter& log)
|
||||
{
|
||||
std::string tmp = Replace(v, "\\", "\\\\");
|
||||
tmp = Replace(tmp, "\n", "\\n");
|
||||
log << tmp;
|
||||
m_Pipe->Write(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Encode newlines in strings
|
||||
Connection& Connection::Write(const char* v, LogWriter& log)
|
||||
{
|
||||
return Write(std::string(v), log);
|
||||
}
|
||||
|
||||
Connection& Connection::WriteEndl(LogWriter& log)
|
||||
{
|
||||
log << "\n";
|
||||
m_Pipe->Write("\n");
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Log.h"
|
||||
#include "Pipe.h"
|
||||
#include "Command.h"
|
||||
|
||||
enum MessageArea
|
||||
{
|
||||
MAGeneral = 1,
|
||||
MASystem = 2, // Error on local system e.g. cannot create dir
|
||||
MAPlugin = 4, // Error in protocol while communicating with the plugin executable
|
||||
MAConfig = 8, // Error in configuration e.g. config value not set
|
||||
MAConnect = 16, // Error during connect to remote server
|
||||
MAProtocol = 32, // Error in protocol while communicating with server
|
||||
MARemote = 64, // Error on remote server
|
||||
MAInvalid = 128 // Must alway be the last entry
|
||||
};
|
||||
|
||||
extern const char* DATA_PREFIX;
|
||||
extern const char* VERBOSE_PREFIX;
|
||||
extern const char* ERROR_PREFIX;
|
||||
extern const char* WARNING_PREFIX;
|
||||
extern const char* INFO_PREFIX;
|
||||
extern const char* COMMAND_PREFIX;
|
||||
extern const char* PROGRESS_PREFIX;
|
||||
|
||||
class Connection
|
||||
{
|
||||
public:
|
||||
Connection(const std::string& logPath);
|
||||
~Connection();
|
||||
|
||||
// Connect to Unity
|
||||
void Connect();
|
||||
bool IsConnected() const;
|
||||
|
||||
// Read a command from unity
|
||||
UnityCommand ReadCommand(CommandArgs& args);
|
||||
|
||||
// Get the log stream
|
||||
LogStream& Log();
|
||||
|
||||
// Get the raw pipe to Unity.
|
||||
// Make sure IsConnected() is true before using.
|
||||
// Pipe& GetPipe();
|
||||
|
||||
void Flush();
|
||||
|
||||
Connection& BeginList();
|
||||
Connection& EndList();
|
||||
Connection& EndResponse();
|
||||
Connection& Command(const std::string& cmd, MessageArea ma = MAGeneral);
|
||||
|
||||
std::string& ReadLine(std::string& target);
|
||||
std::string& PeekLine(std::string& target);
|
||||
|
||||
template <typename T>
|
||||
Connection& DataLine(const T& msg, MessageArea ma = MAGeneral)
|
||||
{
|
||||
WritePrefixLine(DATA_PREFIX, ma, msg, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Connection& VerboseLine(const T& msg, MessageArea ma = MAGeneral)
|
||||
{
|
||||
WritePrefixLine(VERBOSE_PREFIX, ma, msg, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Connection& ErrorLine(const T& msg, MessageArea ma = MAGeneral)
|
||||
{
|
||||
WritePrefixLine(ERROR_PREFIX, ma, msg, m_Log.Notice());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Connection& WarnLine(const T& msg, MessageArea ma = MAGeneral)
|
||||
{
|
||||
WritePrefixLine(WARNING_PREFIX, ma, msg, m_Log.Notice());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Connection& InfoLine(const T& msg, MessageArea ma = MAGeneral)
|
||||
{
|
||||
WritePrefixLine(INFO_PREFIX, ma, msg, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Params: -1 means not specified
|
||||
Connection& Progress(int pct = -1, time_t timeSoFar = -1, const std::string& message = "", MessageArea ma = MAGeneral);
|
||||
|
||||
Connection& operator<<(const std::vector<std::string>& v);
|
||||
|
||||
private:
|
||||
|
||||
Connection& WritePrefix(const char* prefix, MessageArea ma, LogWriter& log);
|
||||
|
||||
template <typename T>
|
||||
Connection& Write(const T& v, LogWriter& log)
|
||||
{
|
||||
log << v;
|
||||
m_Pipe->Write(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Encode newlines in strings
|
||||
Connection& Write(const std::string& v, LogWriter& log);
|
||||
Connection& Write(const char* v, LogWriter& log);
|
||||
|
||||
Connection& WriteEndl(LogWriter& log);
|
||||
|
||||
template <typename T>
|
||||
Connection& WriteLine(const T& v, LogWriter& log)
|
||||
{
|
||||
Write(v, log);
|
||||
WriteEndl(log);
|
||||
Flush();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Connection& WritePrefixLine(const char* prefix, MessageArea ma, const T& v, LogWriter& log)
|
||||
{
|
||||
WritePrefix(prefix, ma, log);
|
||||
Write(v, log);
|
||||
WriteEndl(log);
|
||||
Flush();
|
||||
return *this;
|
||||
}
|
||||
|
||||
LogStream m_Log;
|
||||
Pipe* m_Pipe;
|
||||
};
|
||||
|
||||
|
||||
// Declare primary template to catch wrong specializations
|
||||
template <typename T>
|
||||
Connection& operator<<(Connection& p, const T& v);
|
||||
|
||||
template <typename T>
|
||||
Connection& operator<<(Connection& p, const std::vector<T>& v)
|
||||
{
|
||||
p.DataLine(v.size());
|
||||
for (typename std::vector<T>::const_iterator i = v.begin(); i != v.end(); ++i)
|
||||
p << *i;
|
||||
return p;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Connection& operator>>(Connection& conn, std::vector<T>& v)
|
||||
{
|
||||
std::string line;
|
||||
conn.ReadLine(line);
|
||||
int count = atoi(line.c_str());
|
||||
T t;
|
||||
if (count >= 0)
|
||||
{
|
||||
while (count--)
|
||||
{
|
||||
conn >> t;
|
||||
v.push_back(t);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Remove
|
||||
// Newline delimited list
|
||||
while (!conn.PeekLine(line).empty())
|
||||
{
|
||||
conn >> t;
|
||||
v.push_back(t);
|
||||
}
|
||||
conn.ReadLine(line);
|
||||
}
|
||||
return conn;
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
#include "UnityConnection.h"
|
||||
#include "Connection.h"
|
||||
#include "Commands/AllReqResp.h"
|
||||
|
||||
// Helper for Dispatch()
|
||||
template <template<class> class CommandTmpl, class Req, class Resp, class Sess>
|
||||
bool RunCommand(UnityConnection& conn, Sess& session, const CommandArgs& args)
|
||||
bool RunCommand(Connection& conn, Sess& session, const CommandArgs& args)
|
||||
{
|
||||
Req req(args, conn);
|
||||
|
||||
|
@ -34,10 +34,10 @@ bool RunCommand(UnityConnection& conn, Sess& session, const CommandArgs& args)
|
|||
* first.
|
||||
*/
|
||||
template <template<class> class CommandTmpl, class Session>
|
||||
bool Dispatch(UnityConnection& conn, Session& session,
|
||||
bool Dispatch(Connection& conn, Session& session,
|
||||
UnityCommand cmd, const CommandArgs& args)
|
||||
{
|
||||
conn.Log().Info() << Join(args, " ") << unityplugin::Endl;
|
||||
conn.Log().Info() << Join(args, " ") << Endl;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "Log.h"
|
||||
|
||||
namespace unityplugin
|
||||
{
|
||||
|
||||
LogWriter::LogWriter(LogStream& stream, bool isOn) : m_Stream(stream), m_On(isOn)
|
||||
{
|
||||
|
@ -105,4 +103,3 @@ LogStream& Endl(LogStream& w)
|
|||
return w;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#pragma once
|
||||
#include <fstream>
|
||||
|
||||
namespace unityplugin
|
||||
{
|
||||
|
||||
// Log levels.
|
||||
// Lower levels are included in highers levels automatically.
|
||||
enum LogLevel
|
||||
|
@ -94,4 +91,3 @@ LogStream& operator<<(LogStream& w, LogStream& (*pf)(LogStream&));
|
|||
LogStream& Flush(LogStream& w);
|
||||
LogStream& Endl(LogStream& w);
|
||||
|
||||
} // end namespace
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
#include "Pipe.h"
|
||||
#include "Utility.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Pipe::Pipe() : m_LineBufferValid(false)
|
||||
{
|
||||
#if defined(_WINDOWS)
|
||||
LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\UnityVCS");
|
||||
|
||||
// All pipe instances are busy, so wait for 2 seconds.
|
||||
if ( ! WaitNamedPipe(lpszPipename, 2000))
|
||||
{
|
||||
string msg = "Could not open pipe: 2 second wait timed out.\n";
|
||||
msg += ErrorCodeToMsg(GetLastError());
|
||||
throw PipeException(msg);
|
||||
}
|
||||
|
||||
m_NamedPipe = CreateFile(
|
||||
lpszPipename, // pipe name
|
||||
GENERIC_READ | // read and write access
|
||||
GENERIC_WRITE,
|
||||
0, // no sharing
|
||||
NULL, // default security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL); // no template file
|
||||
|
||||
// Break if the pipe handle is valid.
|
||||
if (m_NamedPipe == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// Exit if an error other than ERROR_PIPE_BUSY occurs.
|
||||
string msg = "Could not open pipe. GLE=";
|
||||
msg += ErrorCodeToMsg(GetLastError());
|
||||
throw PipeException(msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Pipe::~Pipe()
|
||||
{
|
||||
#if defined(_WINDOWS)
|
||||
if (m_NamedPipe != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
|
||||
CloseHandle(m_NamedPipe);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Pipe::Flush()
|
||||
{
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#else
|
||||
cout << flush;
|
||||
#endif
|
||||
}
|
||||
|
||||
Pipe& Pipe::Write(const string& str)
|
||||
{
|
||||
#if defined(_WINDOWS)
|
||||
stringstream ss;
|
||||
ss << v;
|
||||
string str = ss.str();
|
||||
const CHAR* buf = str.c_str();
|
||||
size_t toWrite = str.length();
|
||||
DWORD written;
|
||||
BOOL success = WriteFile(m_NamedPipe, // pipe handle
|
||||
buf, // message
|
||||
toWrite, // message length
|
||||
&written, // bytes written
|
||||
NULL); // not overlapped
|
||||
|
||||
if (!success)
|
||||
{
|
||||
string msg = "WriteFile to pipe failed. GLE=";
|
||||
msg += ErrorCodeToMsg(GetLastError());
|
||||
throw PipeException(msg);
|
||||
}
|
||||
|
||||
#else
|
||||
cout << str;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
string& Pipe::ReadLine(string& target)
|
||||
{
|
||||
if (m_LineBufferValid)
|
||||
{
|
||||
target.swap(m_LineBuffer);
|
||||
m_LineBufferValid = false;
|
||||
return target;
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
|
||||
BOOL success;
|
||||
DWORD bytesRead;
|
||||
const size_t BUFSIZE = 4096 * 4;
|
||||
static CHAR buffer[BUFSIZE];
|
||||
|
||||
// Read until a newline appears in the m_Buffer
|
||||
while (true)
|
||||
{
|
||||
// First check if we have already buffered lines up for grabs
|
||||
string::size_type i = m_Buffer.find("\n");
|
||||
if (i != string::npos)
|
||||
{
|
||||
success = true;
|
||||
target = m_Buffer.substr(0,i);
|
||||
++i; // Eat \n
|
||||
if (i >= m_Buffer.length())
|
||||
m_Buffer.clear();
|
||||
else
|
||||
m_Buffer = m_Buffer.substr(i);
|
||||
break; // success
|
||||
}
|
||||
|
||||
// Read from the pipe.
|
||||
success = ReadFile(m_NamedPipe, // pipe handle
|
||||
buffer, // buffer to receive reply
|
||||
BUFSIZE * sizeof(CHAR), // size of buffer
|
||||
&bytesRead, // number of bytes read
|
||||
NULL); // not overlapped
|
||||
|
||||
if ( !success && GetLastError() != ERROR_MORE_DATA )
|
||||
break; // error
|
||||
|
||||
// Put data to the buffer
|
||||
buffer[bytesRead] = 0x0; // terminate the read string
|
||||
m_Buffer += (char*)buffer;
|
||||
};
|
||||
|
||||
if (!success)
|
||||
{
|
||||
string msg = "Readfile from pipe failed. GLE=";
|
||||
msg += ErrorCodeToMsg(GetLastError());
|
||||
throw PipeException(msg);
|
||||
}
|
||||
#else
|
||||
getline(cin, target);
|
||||
#endif
|
||||
return target;
|
||||
}
|
||||
|
||||
string& Pipe::PeekLine(string& dest)
|
||||
{
|
||||
ReadLine(m_LineBuffer);
|
||||
dest = m_LineBuffer;
|
||||
m_LineBufferValid = true;
|
||||
return dest;
|
||||
}
|
||||
|
||||
bool Pipe::IsEOF() const
|
||||
{
|
||||
#if defined(_WINDOWS)
|
||||
return false; // TODO: Implement
|
||||
#else
|
||||
return cin.eof();
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
#include "Utility.h"
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
#include <sstream>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
class PipeException : public std::exception
|
||||
{
|
||||
public:
|
||||
PipeException(const std::string& about) : m_What(about) {}
|
||||
~PipeException() throw() {}
|
||||
virtual const char* what() const throw() { return m_What.c_str(); }
|
||||
private:
|
||||
std::string m_What;
|
||||
};
|
||||
|
||||
// Pipe that uses unix pipes on mac and linux. NamedPipes on windows
|
||||
struct Pipe {
|
||||
public:
|
||||
Pipe();
|
||||
~Pipe();
|
||||
|
||||
void Flush();
|
||||
|
||||
template <typename T>
|
||||
Pipe& Write(const T& v)
|
||||
{
|
||||
#if defined(_WINDOWS)
|
||||
std::stringstream ss;
|
||||
ss << v;
|
||||
std::string str = ss.str();
|
||||
Write(ss.str());
|
||||
#else
|
||||
std::cout << v;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
Pipe& Write(const std::string& str);
|
||||
std::string& ReadLine(std::string& target);
|
||||
std::string& PeekLine(std::string& dest);
|
||||
bool IsEOF() const;
|
||||
|
||||
private:
|
||||
bool m_LineBufferValid;
|
||||
std::string m_LineBuffer;
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
HANDLE m_NamedPipe;
|
||||
std::string m_Buffer;
|
||||
#endif
|
||||
};
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
#include "UnityConnection.h"
|
||||
#include "Utility.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace unityplugin;
|
||||
|
||||
UnityConnection::UnityConnection(const string& logPath)
|
||||
: m_Log(logPath), m_UnityPipe(NULL) { }
|
||||
|
||||
UnityConnection::~UnityConnection()
|
||||
{
|
||||
delete m_UnityPipe;
|
||||
m_UnityPipe = NULL;
|
||||
}
|
||||
|
||||
UnityPipe* UnityConnection::Connect()
|
||||
{
|
||||
m_UnityPipe = new UnityPipe(m_Log);
|
||||
return m_UnityPipe;
|
||||
}
|
||||
|
||||
// read a command from stdin
|
||||
UnityCommand UnityConnection::ReadCommand(CommandArgs& args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsConnected())
|
||||
Connect();
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
Log().Notice() << "While reading command: " << e.what() << Endl;
|
||||
return UCOM_Invalid;
|
||||
}
|
||||
|
||||
args.clear();
|
||||
string read;
|
||||
Pipe().ReadLine(read);
|
||||
|
||||
if (read.empty())
|
||||
{
|
||||
// broken pipe -> error.
|
||||
if (!Pipe().IsEOF())
|
||||
{
|
||||
Pipe().ErrorLine("Read empty command from connection");
|
||||
return UCOM_Invalid;
|
||||
}
|
||||
|
||||
Log().Info() << "End of pipe" << Endl;
|
||||
return UCOM_Shutdown;
|
||||
}
|
||||
|
||||
// Skip non-command lines if present
|
||||
size_t stopCounter = 1000;
|
||||
while (read.substr(0, 2) != "c:" && stopCounter--)
|
||||
{
|
||||
Pipe().ReadLine(read);
|
||||
}
|
||||
|
||||
if (!stopCounter)
|
||||
{
|
||||
Pipe().ErrorLine("Too many bogus lines");
|
||||
return UCOM_Invalid;
|
||||
}
|
||||
|
||||
string command = read.substr(2);
|
||||
|
||||
if (Tokenize(args, command) == 0)
|
||||
{
|
||||
Pipe().ErrorLine(string("invalid formatted - '") + command + "'");
|
||||
return UCOM_Invalid;
|
||||
}
|
||||
return StringToUnityCommand(args[0].c_str());
|
||||
}
|
||||
|
||||
unityplugin::LogStream& UnityConnection::Log()
|
||||
{
|
||||
return m_Log;
|
||||
}
|
||||
|
||||
bool UnityConnection::IsConnected() const
|
||||
{
|
||||
return m_UnityPipe != NULL;
|
||||
}
|
||||
|
||||
UnityPipe& UnityConnection::Pipe()
|
||||
{
|
||||
return *m_UnityPipe;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "UnityPipe.h"
|
||||
#include "Command.h"
|
||||
|
||||
class UnityConnection
|
||||
{
|
||||
public:
|
||||
UnityConnection(const std::string& logPath);
|
||||
~UnityConnection();
|
||||
|
||||
// Connect to Unity
|
||||
UnityPipe* Connect();
|
||||
bool IsConnected() const;
|
||||
|
||||
// Read a command from unity
|
||||
UnityCommand ReadCommand(CommandArgs& args);
|
||||
|
||||
// Get the log stream
|
||||
unityplugin::LogStream& Log();
|
||||
|
||||
// Get the raw pipe to Unity.
|
||||
// Make sure IsConnected() is true before using.
|
||||
UnityPipe& Pipe();
|
||||
|
||||
private:
|
||||
unityplugin::LogStream m_Log;
|
||||
UnityPipe* m_UnityPipe;
|
||||
};
|
|
@ -1,506 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
#include "Utility.h"
|
||||
#include "Log.h"
|
||||
|
||||
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
#include <sstream>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
enum MessageArea
|
||||
{
|
||||
MAGeneral = 1,
|
||||
MASystem = 2, // Error on local system e.g. cannot create dir
|
||||
MAPlugin = 4, // Error in protocol while communicating with the plugin executable
|
||||
MAConfig = 8, // Error in configuration e.g. config value not set
|
||||
MAConnect = 16, // Error during connect to remote server
|
||||
MAProtocol = 32, // Error in protocol while communicating with server
|
||||
MARemote = 64, // Error on remote server
|
||||
MAInvalid = 128 // Must alway be the last entry
|
||||
};
|
||||
|
||||
class UnityPipeException : public std::exception
|
||||
{
|
||||
public:
|
||||
UnityPipeException(const std::string& about) : m_What(about) {}
|
||||
~UnityPipeException() throw() {}
|
||||
virtual const char* what() const throw() { return m_What.c_str(); }
|
||||
private:
|
||||
std::string m_What;
|
||||
};
|
||||
|
||||
|
||||
// Convenience pipe that writes to both log file and
|
||||
// stdout pipe (ie. the unity process)
|
||||
struct UnityPipe {
|
||||
public:
|
||||
UnityPipe(unityplugin::LogStream& log) : m_Log(log), m_LineBufferValid(false)
|
||||
{
|
||||
#if defined(_WINDOWS)
|
||||
LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\UnityVCS");
|
||||
|
||||
// All pipe instances are busy, so wait for 2 seconds.
|
||||
if ( ! WaitNamedPipe(lpszPipename, 2000))
|
||||
{
|
||||
std::string msg = "Could not open pipe: 2 second wait timed out.\n";
|
||||
msg += ErrorCodeToMsg(GetLastError());
|
||||
throw UnityPipeException(msg);
|
||||
}
|
||||
|
||||
m_NamedPipe = CreateFile(
|
||||
lpszPipename, // pipe name
|
||||
GENERIC_READ | // read and write access
|
||||
GENERIC_WRITE,
|
||||
0, // no sharing
|
||||
NULL, // default security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL); // no template file
|
||||
|
||||
// Break if the pipe handle is valid.
|
||||
if (m_NamedPipe == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// Exit if an error other than ERROR_PIPE_BUSY occurs.
|
||||
std::string msg = "Could not open pipe. GLE=";
|
||||
msg += ErrorCodeToMsg(GetLastError());
|
||||
throw UnityPipeException(msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
~UnityPipe()
|
||||
{
|
||||
#if defined(_WINDOWS)
|
||||
if (m_NamedPipe != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
|
||||
CloseHandle(m_NamedPipe);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
UnityPipe& __Write(const T& v, unityplugin::LogWriter& log)
|
||||
{
|
||||
log << v;
|
||||
#if defined(_WINDOWS)
|
||||
std::stringstream ss;
|
||||
ss << v;
|
||||
std::string str = ss.str();
|
||||
const CHAR* buf = str.c_str();
|
||||
size_t toWrite = str.length();
|
||||
DWORD written;
|
||||
BOOL success = WriteFile(m_NamedPipe, // pipe handle
|
||||
buf, // message
|
||||
toWrite, // message length
|
||||
&written, // bytes written
|
||||
NULL); // not overlapped
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Log().Fatal() << TEXT("WriteFile to pipe failed. GLE=") << ErrorCodeToMsg(GetLastError()) << unityplugin::Endl;
|
||||
exit(-1);
|
||||
}
|
||||
#else
|
||||
std::cout << v;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
UnityPipe& Write(const T& v, unityplugin::LogWriter& log)
|
||||
{
|
||||
return __Write(v, log);
|
||||
}
|
||||
|
||||
UnityPipe& Write(const std::string& v, unityplugin::LogWriter& log)
|
||||
{
|
||||
std::string tmp = Replace(v, "\\", "\\\\");
|
||||
tmp = Replace(tmp, "\n", "\\n");
|
||||
__Write(tmp, log);
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& Write(const char* v, unityplugin::LogWriter& log)
|
||||
{
|
||||
return Write(std::string(v), log);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
UnityPipe& WriteLine(const T& v, unityplugin::LogWriter& log)
|
||||
{
|
||||
Write(v, log);
|
||||
__Write("\n", log);
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string& ReadLine(std::string& target)
|
||||
{
|
||||
if (m_LineBufferValid)
|
||||
{
|
||||
target.swap(m_LineBuffer);
|
||||
m_LineBufferValid = false;
|
||||
return target;
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
|
||||
BOOL success;
|
||||
DWORD bytesRead;
|
||||
const size_t BUFSIZE = 4096 * 4;
|
||||
static CHAR buffer[BUFSIZE];
|
||||
|
||||
// Read until a newline appears in the m_Buffer
|
||||
while (true)
|
||||
{
|
||||
// First check if we have already buffered lines up for grabs
|
||||
std::string::size_type i = m_Buffer.find("\n");
|
||||
if (i != std::string::npos)
|
||||
{
|
||||
success = true;
|
||||
target = m_Buffer.substr(0,i);
|
||||
++i; // Eat \n
|
||||
if (i >= m_Buffer.length())
|
||||
m_Buffer.clear();
|
||||
else
|
||||
m_Buffer = m_Buffer.substr(i);
|
||||
break; // success
|
||||
}
|
||||
|
||||
// Read from the pipe.
|
||||
success = ReadFile(m_NamedPipe, // pipe handle
|
||||
buffer, // buffer to receive reply
|
||||
BUFSIZE * sizeof(CHAR), // size of buffer
|
||||
&bytesRead, // number of bytes read
|
||||
NULL); // not overlapped
|
||||
|
||||
if ( !success && GetLastError() != ERROR_MORE_DATA )
|
||||
break; // error
|
||||
|
||||
// Put data to the buffer
|
||||
buffer[bytesRead] = 0x0; // terminate the read string
|
||||
m_Buffer += (char*)buffer;
|
||||
};
|
||||
|
||||
if (!success)
|
||||
{
|
||||
|
||||
m_Log.Fatal() << TEXT("ReadFile from pipe failed. GLE=%d\n") << ErrorCodeToMsg(GetLastError()) << unityplugin::Endl;
|
||||
exit(-1);
|
||||
}
|
||||
#else
|
||||
std::getline(std::cin, target);
|
||||
#endif
|
||||
std::string::size_type len = target.length();
|
||||
std::string::size_type n1 = 0;
|
||||
std::string::size_type n2 = 0;
|
||||
|
||||
while ( n1 < len && (n2 = target.find('\\', n1)) != std::string::npos &&
|
||||
n2+1 < len )
|
||||
{
|
||||
char c = target[n2+1];
|
||||
if ( c == '\\' )
|
||||
{
|
||||
target.replace(n2, 2, "\\");
|
||||
len--;
|
||||
}
|
||||
else if ( c == 'n')
|
||||
{
|
||||
target.replace(n2, 2, "\n");
|
||||
len--;
|
||||
}
|
||||
n1 = n2 + 1;
|
||||
}
|
||||
|
||||
m_Log.Debug() << "UNITY -> " << target << unityplugin::Endl;
|
||||
return target;
|
||||
}
|
||||
|
||||
std::string& PeekLine(std::string& dest)
|
||||
{
|
||||
ReadLine(m_LineBuffer);
|
||||
dest = m_LineBuffer;
|
||||
m_LineBufferValid = true;
|
||||
return dest;
|
||||
}
|
||||
|
||||
bool IsEOF() const
|
||||
{
|
||||
#if defined(_WINDOWS)
|
||||
return false; // TODO: Implement
|
||||
#else
|
||||
return std::cin.eof();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
unityplugin::LogStream& Log()
|
||||
{
|
||||
return m_Log;
|
||||
}
|
||||
|
||||
UnityPipe& BeginList()
|
||||
{
|
||||
// Start sending list of unknown size
|
||||
DataLine("-1");
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& EndList()
|
||||
{
|
||||
// d is list delimiter
|
||||
__Write("d1:end of list\n", m_Log.Debug());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& EndResponse()
|
||||
{
|
||||
__Write("r1:end of response\n", m_Log.Debug());
|
||||
m_Log.Debug() << "\n--------------------------\n" << unityplugin::Flush;
|
||||
#if !defined(_WINDOWS)
|
||||
std::cout << std::flush;
|
||||
#else
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& Command(const std::string& cmd, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Write("c", m_Log.Debug());
|
||||
Write(ma, m_Log.Debug());
|
||||
Write(":", m_Log.Debug());
|
||||
if (!cmd.empty())
|
||||
Write(cmd, m_Log.Debug());
|
||||
__Write("\n", m_Log.Debug());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& Data(const std::string& msg = "", MessageArea ma = MAGeneral)
|
||||
{
|
||||
Write("o", m_Log.Debug());
|
||||
Write(ma, m_Log.Debug());
|
||||
Write(":", m_Log.Debug());
|
||||
if (!msg.empty())
|
||||
Write(msg, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
UnityPipe& Data(const T& msg, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Write("o", m_Log.Debug());
|
||||
Write(ma, m_Log.Debug());
|
||||
Write(":", m_Log.Debug());
|
||||
Write(msg, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& DataLine(const std::string& msg = "", MessageArea ma = MAGeneral)
|
||||
{
|
||||
Data(msg, ma); __Write("\n", m_Log.Debug());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
UnityPipe& DataLine(const T& msg, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Data(msg, ma); __Write("\n", m_Log.Debug());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
UnityPipe& Verbose(const std::string& msg = "", MessageArea ma = MAGeneral)
|
||||
{
|
||||
Write("v", m_Log.Debug());
|
||||
Write(ma, m_Log.Debug());
|
||||
Write(":", m_Log.Debug());
|
||||
if (!msg.empty())
|
||||
Write(msg, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
UnityPipe& Verbose(const T& msg, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Write("v", m_Log.Debug());
|
||||
Write(ma, m_Log.Debug());
|
||||
Write(":", m_Log.Debug());
|
||||
Write(msg, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& VerboseLine(const std::string& msg = "", MessageArea ma = MAGeneral)
|
||||
{
|
||||
Verbose(msg, ma); __Write("\n", m_Log.Debug());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
UnityPipe& VerboseLine(const T& msg, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Verbose(msg, ma); __Write("\n", m_Log.Debug());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& Error(const std::string& message, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Write("e", m_Log.Notice());
|
||||
Write(ma, m_Log.Notice());
|
||||
Write(":", m_Log.Notice());
|
||||
Write(message, m_Log.Notice());
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& ErrorLine(const std::string& message, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Error(message, ma); __Write("\n", m_Log.Notice());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& Warn(const std::string& message, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Write("w", m_Log.Notice());
|
||||
Write(ma, m_Log.Notice());
|
||||
Write(":", m_Log.Notice());
|
||||
Write(message, m_Log.Notice());
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& WarnLine(const std::string& message, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Warn(message, ma); __Write("\n", m_Log.Notice());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& Info(const std::string& message, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Write("i", m_Log.Debug());
|
||||
Write(ma, m_Log.Debug());
|
||||
Write(":", m_Log.Debug());
|
||||
Write(message, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& InfoLine(const std::string& message, MessageArea ma = MAGeneral)
|
||||
{
|
||||
Info(message, ma); __Write("\n", m_Log.Debug());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Params: -1 means not specified
|
||||
UnityPipe& Progress(int pct = -1, time_t timeSoFar = -1, const std::string& message = "", MessageArea ma = MAGeneral)
|
||||
{
|
||||
Write("p", m_Log.Notice());
|
||||
Write(ma, m_Log.Notice());
|
||||
Write(":", m_Log.Notice());
|
||||
Write(IntToString(pct) + " " + IntToString((int)timeSoFar) + " " + message, m_Log.Notice());
|
||||
__Write("\n", m_Log.Notice());
|
||||
#if defined(_WINDOWS)
|
||||
FlushFileBuffers(m_NamedPipe);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnityPipe& operator<<(const std::vector<std::string>& v)
|
||||
{
|
||||
DataLine(v.size());
|
||||
for (std::vector<std::string>::const_iterator i = v.begin(); i != v.end(); ++i)
|
||||
WriteLine(*i, m_Log.Debug());
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
unityplugin::LogStream& m_Log;
|
||||
bool m_LineBufferValid;
|
||||
std::string m_LineBuffer;
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
HANDLE m_NamedPipe;
|
||||
std::string m_Buffer;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
// Declare primary template to catch wrong specializations
|
||||
template <typename T>
|
||||
UnityPipe& operator<<(UnityPipe& p, const T& v);
|
||||
|
||||
template <typename T>
|
||||
UnityPipe& operator<<(UnityPipe& p, const std::vector<T>& v)
|
||||
{
|
||||
p.DataLine(v.size());
|
||||
for (typename std::vector<T>::const_iterator i = v.begin(); i != v.end(); ++i)
|
||||
p << *i;
|
||||
return p;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
UnityPipe& operator>>(UnityPipe& pipe, std::vector<T>& v)
|
||||
{
|
||||
std::string line;
|
||||
pipe.ReadLine(line);
|
||||
int count = atoi(line.c_str());
|
||||
T t;
|
||||
if (count >= 0)
|
||||
{
|
||||
while (count--)
|
||||
{
|
||||
pipe >> t;
|
||||
v.push_back(t);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Remove
|
||||
// Newline delimited list
|
||||
while (!pipe.PeekLine(line).empty())
|
||||
{
|
||||
pipe >> t;
|
||||
v.push_back(t);
|
||||
}
|
||||
pipe.ReadLine(line);
|
||||
}
|
||||
return pipe;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#include "VersionedAsset.h"
|
||||
#include "UnityPipe.h"
|
||||
#include "Connection.h"
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
|
@ -105,14 +105,14 @@ vector<string> Paths(const VersionedAssetList& assets)
|
|||
return result;
|
||||
}
|
||||
|
||||
UnityPipe& operator<<(UnityPipe& p, const VersionedAsset& asset)
|
||||
Connection& operator<<(Connection& p, const VersionedAsset& asset)
|
||||
{
|
||||
p.DataLine(asset.GetPath());
|
||||
p.DataLine(asset.GetState());
|
||||
return p;
|
||||
}
|
||||
|
||||
UnityPipe& operator>>(UnityPipe& p, VersionedAsset& v)
|
||||
Connection& operator>>(Connection& p, VersionedAsset& v)
|
||||
{
|
||||
string line;
|
||||
p.ReadLine(line);
|
||||
|
|
|
@ -64,6 +64,6 @@ typedef std::set<VersionedAsset> VersionedAssetSet;
|
|||
|
||||
std::vector<std::string> Paths(const VersionedAssetList& assets);
|
||||
|
||||
struct UnityPipe;
|
||||
UnityPipe& operator<<(UnityPipe& p, const VersionedAsset& v);
|
||||
UnityPipe& operator>>(UnityPipe& p, VersionedAsset& v);
|
||||
struct Connection;
|
||||
Connection& operator<<(Connection& p, const VersionedAsset& v);
|
||||
Connection& operator>>(Connection& p, VersionedAsset& v);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
COMMON_SRCS = ./Common/Changes.cpp \
|
||||
./Common/CommandLine.cpp \
|
||||
./Common/FileSystem.cpp \
|
||||
./Common/Pipe.cpp \
|
||||
./Common/Utility.cpp \
|
||||
./Common/VersionedAsset.cpp \
|
||||
./Common/Status.cpp \
|
||||
./Common/UnityConnection.cpp \
|
||||
./Common/Connection.cpp \
|
||||
./Common/Command.cpp \
|
||||
./Common/Log.cpp \
|
||||
./Common/POpen.cpp
|
||||
|
@ -12,11 +13,11 @@ COMMON_SRCS = ./Common/Changes.cpp \
|
|||
COMMON_INCLS = ./Common/Changes.h \
|
||||
./Common/CommandLine.h \
|
||||
./Common/FileSystem.h \
|
||||
./Common/UnityPipe.h \
|
||||
./Common/Pipe.h \
|
||||
./Common/Utility.h \
|
||||
./Common/VersionedAsset.h \
|
||||
./Common/Status.h \
|
||||
./Common/UnityConnection.h \
|
||||
./Common/Connection.h \
|
||||
./Common/Command.h \
|
||||
./Common/Dispatch.h \
|
||||
./Common/Log.h \
|
||||
|
|
|
@ -12,19 +12,19 @@ public:
|
|||
virtual bool Run(P4Task& task, const CommandArgs& args)
|
||||
{
|
||||
ClearStatus();
|
||||
Pipe().Log().Info() << "ChangeDescriptionCommand::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << "ChangeDescriptionCommand::Run()" << Endl;
|
||||
|
||||
ChangelistRevision cl;
|
||||
Pipe() >> cl;
|
||||
Conn() >> cl;
|
||||
|
||||
const string cmd = string("change -o ") + (cl == kDefaultListRevision ? string("") : cl);
|
||||
|
||||
task.CommandRun(cmd, this);
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ public:
|
|||
void OutputInfo( char level, const char *data )
|
||||
{
|
||||
string result;
|
||||
Pipe().VerboseLine(data);
|
||||
Conn().VerboseLine(data);
|
||||
ReadDescription(data, result);
|
||||
if (result == "<enter description here>\n\n")
|
||||
result.clear();
|
||||
Pipe().DataLine(result);
|
||||
Conn().DataLine(result);
|
||||
}
|
||||
|
||||
int ReadDescription(const char *data, string& result)
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
virtual string SetupCommand(const CommandArgs& args)
|
||||
{
|
||||
ChangelistRevision cr;
|
||||
Pipe() >> cr;
|
||||
Conn() >> cr;
|
||||
string cmd("reopen -c ");
|
||||
return cmd += (cr == kDefaultListRevision ? string("default") : cr);
|
||||
}
|
||||
|
|
|
@ -16,23 +16,23 @@ public:
|
|||
P4Task::SetOnline(true);
|
||||
|
||||
ClearStatus();
|
||||
Pipe().Log().Info() << "ChangeStatusCommand::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << "ChangeStatusCommand::Run()" << Endl;
|
||||
|
||||
ChangelistRevision cl;
|
||||
Pipe() >> cl;
|
||||
Conn() >> cl;
|
||||
|
||||
string cmd = "fstat -T \"depotFile,clientFile,action,ourLock,unresolved,headAction,otherOpen,otherLock,headRev,haveRev\" -W -e ";
|
||||
cmd += (cl == kDefaultListRevision ? string("default") : cl) + " //...";
|
||||
|
||||
// We're sending along an asset list with an unknown size.
|
||||
Pipe().BeginList();
|
||||
Conn().BeginList();
|
||||
|
||||
task.CommandRun(cmd, this);
|
||||
|
||||
// The OutputState and other callbacks will now output to stdout.´
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndList();
|
||||
Pipe() << GetStatus();
|
||||
Conn().EndList();
|
||||
Conn() << GetStatus();
|
||||
|
||||
if (P4Task::IsOnline() && !wasOnline)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
P4Task::NotifyOnline();
|
||||
}
|
||||
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@ public:
|
|||
virtual bool Run(P4Task& task, const CommandArgs& args)
|
||||
{
|
||||
ClearStatus();
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
const string cmd = string("changes -s pending -u ") + task.GetP4User() + " -c " + task.GetP4Client();
|
||||
|
||||
Pipe().BeginList();
|
||||
Conn().BeginList();
|
||||
|
||||
// The default list is always there
|
||||
Changelist defaultItem;
|
||||
|
@ -26,15 +26,15 @@ public:
|
|||
defaultItem.SetDescription(kDefaultList);
|
||||
defaultItem.SetRevision(kDefaultListRevision);
|
||||
|
||||
Pipe() << defaultItem;
|
||||
Conn() << defaultItem;
|
||||
|
||||
task.CommandRun(cmd, this);
|
||||
Pipe().EndList();
|
||||
Pipe() << GetStatus();
|
||||
Conn().EndList();
|
||||
Conn() << GetStatus();
|
||||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ public:
|
|||
string d(data);
|
||||
const size_t minLength = 8; // "Change x".length()
|
||||
|
||||
Pipe().VerboseLine(d);
|
||||
Conn().VerboseLine(d);
|
||||
|
||||
if (d.length() <= minLength)
|
||||
{
|
||||
Pipe().WarnLine(string("p4 changelist too short: ") + d);
|
||||
Conn().WarnLine(string("p4 changelist too short: ") + d);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -57,14 +57,14 @@ public:
|
|||
string::size_type i = d.find(' ', 8);
|
||||
if (i == string::npos)
|
||||
{
|
||||
Pipe().WarnLine(string("p4 couldn't locate revision: ") + d);
|
||||
Conn().WarnLine(string("p4 couldn't locate revision: ") + d);
|
||||
return;
|
||||
}
|
||||
|
||||
Changelist item;
|
||||
item.SetDescription(d.substr(i));
|
||||
item.SetRevision(d.substr(minLength-1, i - (minLength-1)));
|
||||
Pipe() << item;
|
||||
Conn() << item;
|
||||
}
|
||||
|
||||
} cChanges("changes");
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
UnityPipe& SendToPipe(UnityPipe& p, const VCSStatus& st, MessageArea ma, bool safeSend)
|
||||
Connection& SendToConnection(Connection& p, const VCSStatus& st, MessageArea ma, bool safeSend)
|
||||
{
|
||||
// Convertion of p4 errors to unity vcs errors
|
||||
for (VCSStatus::const_iterator i = st.begin(); i != st.end(); ++i)
|
||||
|
@ -44,9 +44,9 @@ UnityPipe& SendToPipe(UnityPipe& p, const VCSStatus& st, MessageArea ma, bool sa
|
|||
return p;
|
||||
}
|
||||
|
||||
UnityPipe& operator<<(UnityPipe& p, const VCSStatus& st)
|
||||
Connection& operator<<(Connection& p, const VCSStatus& st)
|
||||
{
|
||||
return SendToPipe(p, st, MAGeneral, false);
|
||||
return SendToConnection(p, st, MAGeneral, false);
|
||||
}
|
||||
|
||||
// Global map of all commands registered at initialization time
|
||||
|
@ -61,7 +61,7 @@ P4Command* LookupCommand(const string& name)
|
|||
return i->second;
|
||||
}
|
||||
|
||||
UnityPipe* P4Command::s_UnityPipe = NULL;
|
||||
Connection* P4Command::s_Conn = NULL;
|
||||
|
||||
P4Command::P4Command(const char* name) : m_AllowConnect(true)
|
||||
{
|
||||
|
@ -116,27 +116,27 @@ bool P4Command::ConnectAllowed()
|
|||
// Default handler of P4
|
||||
void P4Command::OutputStat( StrDict *varList )
|
||||
{
|
||||
Pipe().Log().Info() << "Default ClientUser OutputState()\n";
|
||||
Conn().Log().Info() << "Default ClientUser OutputState()\n";
|
||||
}
|
||||
|
||||
|
||||
// Default handler of P4
|
||||
void P4Command::InputData( StrBuf *buf, Error *err )
|
||||
{
|
||||
Pipe().Log().Info() << "Default ClientUser InputData()\n";
|
||||
Conn().Log().Info() << "Default ClientUser InputData()\n";
|
||||
}
|
||||
|
||||
void P4Command::Prompt( const StrPtr &msg, StrBuf &buf, int noEcho ,Error *e )
|
||||
{
|
||||
Pipe().VerboseLine("Prompting...");
|
||||
Pipe().Log().Info() << "Default ClientUser Prompt(" << msg.Text() << ")\n";
|
||||
Conn().VerboseLine("Prompting...");
|
||||
Conn().Log().Info() << "Default ClientUser Prompt(" << msg.Text() << ")\n";
|
||||
}
|
||||
|
||||
|
||||
// Default handler of P4
|
||||
void P4Command::Finished()
|
||||
{
|
||||
// Pipe().Log().Info() << "Default ClientUser Finished()\n";
|
||||
// Conn().Log().Info() << "Default ClientUser Finished()\n";
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,8 +158,8 @@ void P4Command::HandleError( Error *err )
|
|||
// Default handler of perforce error calbacks
|
||||
void P4Command::OutputError( const char *errBuf )
|
||||
{
|
||||
Pipe().WarnLine(errBuf);
|
||||
Pipe().Log().Debug() << "error: " << errBuf << unityplugin::Endl;
|
||||
Conn().WarnLine(errBuf);
|
||||
Conn().Log().Debug() << "error: " << errBuf << Endl;
|
||||
}
|
||||
|
||||
static bool ErrorStringMatch(Error *err, const char* msg)
|
||||
|
@ -198,12 +198,12 @@ bool P4Command::HandleOnlineStatusOnError(Error *err)
|
|||
|
||||
else
|
||||
{
|
||||
Pipe().Log().Notice() << "Unhandled status error -> " << value << unityplugin::Endl;
|
||||
Conn().Log().Notice() << "Unhandled status error -> " << value << Endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
Pipe().InfoLine(value);
|
||||
Pipe().Log().Notice() << value << unityplugin::Endl;
|
||||
Conn().InfoLine(value);
|
||||
Conn().Log().Notice() << value << Endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -212,29 +212,29 @@ bool P4Command::HandleOnlineStatusOnError(Error *err)
|
|||
|
||||
void P4Command::ErrorPause( char* errBuf, Error* e)
|
||||
{
|
||||
Pipe().Log().Notice() << "Error: Default ClientUser ErrorPause()\n";
|
||||
Conn().Log().Notice() << "Error: Default ClientUser ErrorPause()\n";
|
||||
}
|
||||
|
||||
|
||||
void P4Command::OutputText( const char *data, int length)
|
||||
{
|
||||
Pipe().Log().Info() << "Error: Default ClientUser OutputText\n";
|
||||
Conn().Log().Info() << "Error: Default ClientUser OutputText\n";
|
||||
}
|
||||
|
||||
|
||||
void P4Command::OutputBinary( const char *data, int length)
|
||||
{
|
||||
Pipe().Log().Info() << "Error: Default ClientUser OutputBinary\n";
|
||||
Conn().Log().Info() << "Error: Default ClientUser OutputBinary\n";
|
||||
}
|
||||
|
||||
|
||||
// Default handle of perforce info callbacks. Called by the default P4Command::Message() handler.
|
||||
void P4Command::OutputInfo( char level, const char *data )
|
||||
{
|
||||
Pipe().Log().Info() << "level " << (int) level << ": " << data << unityplugin::Endl;
|
||||
Conn().Log().Info() << "level " << (int) level << ": " << data << Endl;
|
||||
std::stringstream ss;
|
||||
ss << data << " (level " << (int) level << ")";
|
||||
Pipe().InfoLine(ss.str());
|
||||
Conn().InfoLine(ss.str());
|
||||
}
|
||||
|
||||
void P4Command::RunAndSendStatus(P4Task& task, const VersionedAssetList& assetList)
|
||||
|
@ -242,13 +242,13 @@ void P4Command::RunAndSendStatus(P4Task& task, const VersionedAssetList& assetLi
|
|||
P4StatusCommand* c = dynamic_cast<P4StatusCommand*>(LookupCommand("status"));
|
||||
if (!c)
|
||||
{
|
||||
Pipe().ErrorLine("Cannot locate status command");
|
||||
Conn().ErrorLine("Cannot locate status command");
|
||||
return; // Returning this is just to keep things running.
|
||||
}
|
||||
|
||||
bool recursive = false;
|
||||
c->RunAndSend(task, assetList, recursive);
|
||||
Pipe() << c->GetStatus();
|
||||
Conn() << c->GetStatus();
|
||||
}
|
||||
|
||||
const char * kDelim = "_XUDELIMX_"; // magic delimiter
|
||||
|
@ -315,7 +315,7 @@ const std::vector<P4Command::Mapping>& P4Command::GetMappings(P4Task& task, cons
|
|||
string localPaths = ResolvePaths(assets, kPathWild | kPathSkipFolders, "", kDelim);
|
||||
|
||||
task.CommandRun("where " + localPaths, &cWhere);
|
||||
Pipe() << cWhere.GetStatus();
|
||||
Conn() << cWhere.GetStatus();
|
||||
|
||||
if (cWhere.HasErrors())
|
||||
{
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include "UnityPipe.h"
|
||||
#include "Connection.h"
|
||||
#include "P4Task.h"
|
||||
#include "VersionedAsset.h"
|
||||
|
||||
typedef std::vector<std::string> CommandArgs;
|
||||
UnityPipe& operator<<(UnityPipe& p, const VCSStatus& v);
|
||||
UnityPipe& SendToPipe(UnityPipe& p, const VCSStatus& st, MessageArea ma, bool safeSend = true);
|
||||
Connection& operator<<(Connection& p, const VCSStatus& v);
|
||||
Connection& SendToConnection(Connection& p, const VCSStatus& st, MessageArea ma, bool safeSend = true);
|
||||
|
||||
/*
|
||||
* Base class for all commands that unity can issue and is supported
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
void Prompt( const StrPtr &msg, StrBuf &buf, int noEcho ,Error *e );
|
||||
void Finished();
|
||||
|
||||
static UnityPipe& Pipe() { return *s_UnityPipe; }
|
||||
static Connection& Conn() { return *s_Conn; }
|
||||
|
||||
protected:
|
||||
P4Command(const char* name);
|
||||
|
@ -64,7 +64,7 @@ protected:
|
|||
static bool MapToLocal(P4Task& task, VersionedAssetList& assets);
|
||||
|
||||
friend class P4Task;
|
||||
static UnityPipe* s_UnityPipe;
|
||||
static Connection* s_Conn;
|
||||
private:
|
||||
VCSStatus m_Status;
|
||||
};
|
||||
|
|
|
@ -20,8 +20,8 @@ public:
|
|||
msg += " ";
|
||||
msg += *i;
|
||||
}
|
||||
Pipe().WarnLine(msg, MAConfig);
|
||||
Pipe().EndResponse();
|
||||
Conn().WarnLine(msg, MAConfig);
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
if (key == "vcPerforcePassword")
|
||||
logValue = "*";
|
||||
|
||||
Pipe().Log().Info() << "Got config " << key << " = '" << logValue << "'" << unityplugin::Endl;
|
||||
Conn().Log().Info() << "Got config " << key << " = '" << logValue << "'" << Endl;
|
||||
|
||||
// This command actually handles several commands all
|
||||
// concerning connecting to the perforce server
|
||||
|
@ -56,19 +56,19 @@ public:
|
|||
assetPath += " ";
|
||||
}
|
||||
task.SetAssetsPath(TrimEnd(assetPath));
|
||||
Pipe().Log().Info() << "Set assetPath to" << assetPath << unityplugin::Endl;
|
||||
Conn().Log().Info() << "Set assetPath to" << assetPath << Endl;
|
||||
}
|
||||
else if (key == "vcSharedLogLevel")
|
||||
{
|
||||
Pipe().Log().Info() << "Set log level to " << value << unityplugin::Endl;
|
||||
unityplugin::LogLevel level = unityplugin::LOG_DEBUG;
|
||||
Conn().Log().Info() << "Set log level to " << value << Endl;
|
||||
LogLevel level = LOG_DEBUG;
|
||||
if (value == "info")
|
||||
level = unityplugin::LOG_INFO;
|
||||
level = LOG_INFO;
|
||||
else if (value == "notice")
|
||||
level = unityplugin::LOG_NOTICE;
|
||||
level = LOG_NOTICE;
|
||||
else if (value == "fatal")
|
||||
level = unityplugin::LOG_FATAL;
|
||||
Pipe().Log().SetLogLevel(level);
|
||||
level = LOG_FATAL;
|
||||
Conn().Log().SetLogLevel(level);
|
||||
}
|
||||
else if (key == "vcPerforcePassword")
|
||||
{
|
||||
|
@ -88,71 +88,71 @@ public:
|
|||
else if (key == "pluginVersions")
|
||||
{
|
||||
int sel = SelectVersion(args);
|
||||
Pipe().DataLine(sel, MAConfig);
|
||||
Pipe().Log().Info() << "Selected plugin protocol version " << sel << unityplugin::Endl;
|
||||
Conn().DataLine(sel, MAConfig);
|
||||
Conn().Log().Info() << "Selected plugin protocol version " << sel << Endl;
|
||||
}
|
||||
else if (key == "pluginTraits")
|
||||
{
|
||||
// We have 4 flags set
|
||||
Pipe().DataLine("6");
|
||||
Pipe().DataLine("requiresNetwork", MAConfig);
|
||||
Pipe().DataLine("enablesCheckout", MAConfig);
|
||||
Pipe().DataLine("enablesLocking", MAConfig);
|
||||
Pipe().DataLine("enablesRevertUnchanged", MAConfig);
|
||||
Pipe().DataLine("enablesChangelists", MAConfig);
|
||||
Pipe().DataLine("enablesGetLatestOnChangeSetSubset", MAConfig);
|
||||
Conn().DataLine("6");
|
||||
Conn().DataLine("requiresNetwork", MAConfig);
|
||||
Conn().DataLine("enablesCheckout", MAConfig);
|
||||
Conn().DataLine("enablesLocking", MAConfig);
|
||||
Conn().DataLine("enablesRevertUnchanged", MAConfig);
|
||||
Conn().DataLine("enablesChangelists", MAConfig);
|
||||
Conn().DataLine("enablesGetLatestOnChangeSetSubset", MAConfig);
|
||||
|
||||
// We provide 4 configuration fields for the GUI to display
|
||||
Pipe().DataLine("4");
|
||||
Pipe().DataLine("vcPerforceUsername"); // key
|
||||
Pipe().DataLine("Username", MAConfig); // label
|
||||
Pipe().DataLine("The perforce user name", MAConfig); // description
|
||||
Pipe().DataLine(""); // default
|
||||
Pipe().DataLine("1"); // 1 == required field, 2 == password field
|
||||
Conn().DataLine("4");
|
||||
Conn().DataLine("vcPerforceUsername"); // key
|
||||
Conn().DataLine("Username", MAConfig); // label
|
||||
Conn().DataLine("The perforce user name", MAConfig); // description
|
||||
Conn().DataLine(""); // default
|
||||
Conn().DataLine("1"); // 1 == required field, 2 == password field
|
||||
|
||||
Pipe().DataLine("vcPerforcePassword");
|
||||
Pipe().DataLine("Password", MAConfig);
|
||||
Pipe().DataLine("The perforce password", MAConfig);
|
||||
Pipe().DataLine("");
|
||||
Pipe().DataLine("2"); // password field
|
||||
Conn().DataLine("vcPerforcePassword");
|
||||
Conn().DataLine("Password", MAConfig);
|
||||
Conn().DataLine("The perforce password", MAConfig);
|
||||
Conn().DataLine("");
|
||||
Conn().DataLine("2"); // password field
|
||||
|
||||
Pipe().DataLine("vcPerforceWorkspace");
|
||||
Pipe().DataLine("Workspace", MAConfig);
|
||||
Pipe().DataLine("The perforce workspace/client", MAConfig);
|
||||
Pipe().DataLine("");
|
||||
Pipe().DataLine("1"); // required field
|
||||
Conn().DataLine("vcPerforceWorkspace");
|
||||
Conn().DataLine("Workspace", MAConfig);
|
||||
Conn().DataLine("The perforce workspace/client", MAConfig);
|
||||
Conn().DataLine("");
|
||||
Conn().DataLine("1"); // required field
|
||||
|
||||
Pipe().DataLine("vcPerforceServer");
|
||||
Pipe().DataLine("Server", MAConfig);
|
||||
Pipe().DataLine("The perforce server using format: hostname:port. Port hostname defaults to 'perforce' and port defaults to 1666", MAConfig);
|
||||
Pipe().DataLine("perforce");
|
||||
Pipe().DataLine("0"); //
|
||||
Conn().DataLine("vcPerforceServer");
|
||||
Conn().DataLine("Server", MAConfig);
|
||||
Conn().DataLine("The perforce server using format: hostname:port. Port hostname defaults to 'perforce' and port defaults to 1666", MAConfig);
|
||||
Conn().DataLine("perforce");
|
||||
Conn().DataLine("0"); //
|
||||
|
||||
// We have 11 custom overlay icons
|
||||
Pipe().DataLine("overlays");
|
||||
Pipe().DataLine("11");
|
||||
Pipe().DataLine(IntToString(kLocal)); // for this state
|
||||
Pipe().DataLine("default"); // use this path. "default" and "blank" paths can be used when you have not custom overlays.
|
||||
Pipe().DataLine(IntToString(kOutOfSync));
|
||||
Pipe().DataLine("default");
|
||||
Pipe().DataLine(IntToString(kCheckedOutLocal));
|
||||
Pipe().DataLine("default");
|
||||
Pipe().DataLine(IntToString(kCheckedOutRemote));
|
||||
Pipe().DataLine("default");
|
||||
Pipe().DataLine(IntToString(kDeletedLocal));
|
||||
Pipe().DataLine("default");
|
||||
Pipe().DataLine(IntToString(kDeletedRemote));
|
||||
Pipe().DataLine("default");
|
||||
Pipe().DataLine(IntToString(kAddedLocal));
|
||||
Pipe().DataLine("default");
|
||||
Pipe().DataLine(IntToString(kAddedRemote));
|
||||
Pipe().DataLine("default");
|
||||
Pipe().DataLine(IntToString(kConflicted));
|
||||
Pipe().DataLine("default");
|
||||
Pipe().DataLine(IntToString(kLockedLocal));
|
||||
Pipe().DataLine("default");
|
||||
Pipe().DataLine(IntToString(kLockedRemote));
|
||||
Pipe().DataLine("default");
|
||||
Conn().DataLine("overlays");
|
||||
Conn().DataLine("11");
|
||||
Conn().DataLine(IntToString(kLocal)); // for this state
|
||||
Conn().DataLine("default"); // use this path. "default" and "blank" paths can be used when you have not custom overlays.
|
||||
Conn().DataLine(IntToString(kOutOfSync));
|
||||
Conn().DataLine("default");
|
||||
Conn().DataLine(IntToString(kCheckedOutLocal));
|
||||
Conn().DataLine("default");
|
||||
Conn().DataLine(IntToString(kCheckedOutRemote));
|
||||
Conn().DataLine("default");
|
||||
Conn().DataLine(IntToString(kDeletedLocal));
|
||||
Conn().DataLine("default");
|
||||
Conn().DataLine(IntToString(kDeletedRemote));
|
||||
Conn().DataLine("default");
|
||||
Conn().DataLine(IntToString(kAddedLocal));
|
||||
Conn().DataLine("default");
|
||||
Conn().DataLine(IntToString(kAddedRemote));
|
||||
Conn().DataLine("default");
|
||||
Conn().DataLine(IntToString(kConflicted));
|
||||
Conn().DataLine("default");
|
||||
Conn().DataLine(IntToString(kLockedLocal));
|
||||
Conn().DataLine("default");
|
||||
Conn().DataLine(IntToString(kLockedRemote));
|
||||
Conn().DataLine("default");
|
||||
}
|
||||
else if (key == "end")
|
||||
{
|
||||
|
@ -162,9 +162,9 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
Pipe().WarnLine(ToString("Unknown config field set on version control plugin: ", key), MAConfig);
|
||||
Conn().WarnLine(ToString("Unknown config field set on version control plugin: ", key), MAConfig);
|
||||
}
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,19 +11,19 @@ public:
|
|||
virtual bool Run(P4Task& task, const CommandArgs& args)
|
||||
{
|
||||
ClearStatus();
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
std::string errorMessage;
|
||||
|
||||
const string cmd = "change -d";
|
||||
|
||||
ChangelistRevisions changes;
|
||||
Pipe() >> changes;
|
||||
Conn() >> changes;
|
||||
|
||||
if (changes.empty())
|
||||
{
|
||||
|
||||
Pipe().WarnLine("Changes to delete is empty");
|
||||
Pipe().EndResponse();
|
||||
Conn().WarnLine("Changes to delete is empty");
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -39,13 +39,13 @@ public:
|
|||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
// @TODO: send changed assets
|
||||
VersionedAssetList dummy;
|
||||
Pipe() << dummy;
|
||||
Conn() << dummy;
|
||||
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
if (level != 48)
|
||||
P4Command::OutputInfo(level, data);
|
||||
|
||||
Pipe().VerboseLine(msg);
|
||||
Conn().VerboseLine(msg);
|
||||
|
||||
if (msgLen > (kDelim1Len + kDelim2Len + 12) && msg.find(" - merging ") != string::npos) // 12 being the smallest possible path repr.
|
||||
HandleMergableAsset(msg);
|
||||
|
@ -129,30 +129,30 @@ public:
|
|||
bool Run(P4Task& task, const CommandArgs& args)
|
||||
{
|
||||
ClearStatus();
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
|
||||
string baseCmd = "print -q -o ";
|
||||
string targetDir;
|
||||
Pipe().ReadLine(targetDir);
|
||||
Conn().ReadLine(targetDir);
|
||||
|
||||
vector<string> versions;
|
||||
// The wanted versions to download. e.g. you can download both head, base of a file at the same time
|
||||
Pipe() >> versions;
|
||||
Conn() >> versions;
|
||||
|
||||
VersionedAssetList assetList;
|
||||
Pipe() >> assetList;
|
||||
Conn() >> assetList;
|
||||
vector<string> paths;
|
||||
ResolvePaths(paths, assetList, kPathWild | kPathSkipFolders);
|
||||
|
||||
Pipe().Log().Debug() << "Paths resolved" << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Paths resolved" << Endl;
|
||||
|
||||
Pipe().BeginList();
|
||||
Conn().BeginList();
|
||||
|
||||
if (paths.empty())
|
||||
{
|
||||
Pipe().EndList();
|
||||
Pipe().WarnLine("No paths in fileset perforce command", MARemote);
|
||||
Pipe().EndResponse();
|
||||
Conn().EndList();
|
||||
Conn().WarnLine("No paths in fileset perforce command", MARemote);
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -173,13 +173,13 @@ public:
|
|||
tmpFile += "head";
|
||||
string fileCmd = cmd + "\"" + tmpFile + "\" \"" + *i + "#head\"";
|
||||
|
||||
Pipe().Log().Info() << fileCmd << unityplugin::Endl;
|
||||
Conn().Log().Info() << fileCmd << Endl;
|
||||
if (!task.CommandRun(fileCmd, this))
|
||||
break;
|
||||
|
||||
VersionedAsset asset;
|
||||
asset.SetPath(tmpFile);
|
||||
Pipe() << asset;
|
||||
Conn() << asset;
|
||||
|
||||
}
|
||||
else if (*j == "mineAndConflictingAndBase")
|
||||
|
@ -193,9 +193,9 @@ public:
|
|||
cConflictInfo.conflicts.clear();
|
||||
string localPaths = ResolvePaths(assetList, kPathWild | kPathSkipFolders);
|
||||
string rcmd = "resolve -o -n " + localPaths;
|
||||
Pipe().Log().Info() << rcmd << unityplugin::Endl;
|
||||
Conn().Log().Info() << rcmd << Endl;
|
||||
task.CommandRun(rcmd, &cConflictInfo);
|
||||
Pipe() << cConflictInfo.GetStatus();
|
||||
Conn() << cConflictInfo.GetStatus();
|
||||
|
||||
if (cConflictInfo.HasErrors())
|
||||
{
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
string msg = cConflictInfo.GetStatusMessage();
|
||||
if (!StartsWith(msg, "No file(s) to resolve"))
|
||||
{
|
||||
Pipe() << cConflictInfo.GetStatus();
|
||||
Conn() << cConflictInfo.GetStatus();
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -214,19 +214,19 @@ public:
|
|||
|
||||
// Location of "mine" version of file. In Perforce this is always
|
||||
// the original location of the file.
|
||||
Pipe() << assetList[idx];
|
||||
Conn() << assetList[idx];
|
||||
|
||||
VersionedAsset asset;
|
||||
if (ci != cConflictInfo.conflicts.end())
|
||||
{
|
||||
string conflictFile = tmpFile + "conflicting";
|
||||
string conflictCmd = cmd + "\"" + conflictFile + "\" \"" + ci->second.conflict + "\"";
|
||||
Pipe().Log().Info() << conflictCmd << unityplugin::Endl;
|
||||
Conn().Log().Info() << conflictCmd << Endl;
|
||||
if (!task.CommandRun(conflictCmd, this))
|
||||
break;
|
||||
|
||||
asset.SetPath(conflictFile);
|
||||
Pipe() << asset;
|
||||
Conn() << asset;
|
||||
|
||||
string baseFile = "";
|
||||
|
||||
|
@ -235,7 +235,7 @@ public:
|
|||
{
|
||||
baseFile = tmpFile + "base";
|
||||
string baseCmd = cmd + "\"" + baseFile + "\" \"" + ci->second.base + "\"";
|
||||
Pipe().Log().Info() << baseCmd << unityplugin::Endl;
|
||||
Conn().Log().Info() << baseCmd << Endl;
|
||||
if (!task.CommandRun(baseCmd, this))
|
||||
break;
|
||||
}
|
||||
|
@ -244,13 +244,13 @@ public:
|
|||
asset.SetState(kMissing);
|
||||
}
|
||||
asset.SetPath(baseFile);
|
||||
Pipe() << asset;
|
||||
Conn() << asset;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no conflict info for this file
|
||||
asset.SetState(kMissing);
|
||||
Pipe() << asset << asset;
|
||||
Conn() << asset << asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,9 +258,9 @@ public:
|
|||
error:
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndList();
|
||||
Pipe() << GetStatus();
|
||||
Pipe().EndResponse();
|
||||
Conn().EndList();
|
||||
Conn() << GetStatus();
|
||||
Conn().EndResponse();
|
||||
|
||||
cConflictInfo.conflicts.clear();
|
||||
|
||||
|
|
|
@ -13,29 +13,29 @@ public:
|
|||
{
|
||||
ClearStatus();
|
||||
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
|
||||
string cmd = SetupCommand(args);
|
||||
if (cmd.empty())
|
||||
{
|
||||
Pipe().BeginList();
|
||||
Pipe().EndList();
|
||||
Pipe().EndResponse();
|
||||
Conn().BeginList();
|
||||
Conn().EndList();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
VersionedAssetList assetList;
|
||||
Pipe() >> assetList;
|
||||
Conn() >> assetList;
|
||||
string paths = ResolvePaths(assetList, kPathWild | kPathSkipFolders);
|
||||
|
||||
Pipe().Log().Debug() << "Paths resolved are: " << paths << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Paths resolved are: " << paths << Endl;
|
||||
|
||||
if (paths.empty())
|
||||
{
|
||||
Pipe().BeginList();
|
||||
Pipe().WarnLine("No paths for filemode command", MARemote);
|
||||
Pipe().EndList();
|
||||
Pipe().EndResponse();
|
||||
Conn().BeginList();
|
||||
Conn().WarnLine("No paths for filemode command", MARemote);
|
||||
Conn().EndList();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,13 @@ public:
|
|||
task.CommandRun(cmd, this);
|
||||
|
||||
assetList.clear();
|
||||
Pipe() << assetList;
|
||||
Conn() << assetList;
|
||||
assetList.clear();
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
{
|
||||
if (args.size() < 3)
|
||||
{
|
||||
Pipe().WarnLine("Too few arguments for filemode command");
|
||||
Conn().WarnLine("Too few arguments for filemode command");
|
||||
return ""; // no command
|
||||
}
|
||||
|
||||
|
@ -77,12 +77,12 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
Pipe().WarnLine(string("Unknown filemode flag ") + mode);
|
||||
Conn().WarnLine(string("Unknown filemode flag ") + mode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Pipe().WarnLine(string("Unknown filemode method ") + method);
|
||||
Conn().WarnLine(string("Unknown filemode method ") + method);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -12,27 +12,27 @@ P4FileSetBaseCommand::P4FileSetBaseCommand(const char* name, const char* cmdstr)
|
|||
bool P4FileSetBaseCommand::Run(P4Task& task, const CommandArgs& args)
|
||||
{
|
||||
ClearStatus();
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
|
||||
string cmd = SetupCommand(args);
|
||||
|
||||
VersionedAssetList assetList;
|
||||
Pipe() >> assetList;
|
||||
Conn() >> assetList;
|
||||
string paths = ResolvePaths(assetList, GetResolvePathFlags());
|
||||
|
||||
Pipe().Log().Debug() << "Paths resolved are: " << paths << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Paths resolved are: " << paths << Endl;
|
||||
|
||||
if (paths.empty())
|
||||
{
|
||||
Pipe().WarnLine("No paths in fileset perforce command", MARemote);
|
||||
Pipe().EndResponse();
|
||||
Conn().WarnLine("No paths in fileset perforce command", MARemote);
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
cmd += " " + paths;
|
||||
|
||||
task.CommandRun(cmd, this);
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
// Stat the files to get the most recent state.
|
||||
// This could probably be optimized by reading the output of the specific
|
||||
|
@ -41,7 +41,7 @@ bool P4FileSetBaseCommand::Run(P4Task& task, const CommandArgs& args)
|
|||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,27 +13,27 @@ public:
|
|||
{
|
||||
incomingAssetList.clear();
|
||||
ClearStatus();
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
|
||||
string cmd = "sync";
|
||||
|
||||
VersionedAssetList assetList;
|
||||
Pipe() >> assetList;
|
||||
Conn() >> assetList;
|
||||
string paths = ResolvePaths(assetList, kPathWild | kPathRecursive);
|
||||
|
||||
Pipe().Log().Debug() << "Paths resolved are: " << paths << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Paths resolved are: " << paths << Endl;
|
||||
|
||||
if (paths.empty())
|
||||
{
|
||||
Pipe().WarnLine("No paths in getlatest perforce command", MARemote);
|
||||
Pipe().EndResponse();
|
||||
Conn().WarnLine("No paths in getlatest perforce command", MARemote);
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
cmd += " " + paths;
|
||||
|
||||
task.CommandRun(cmd, this);
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
// Stat the files to get the most recent state.
|
||||
// This could probably be optimized by reading the output of the command better
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
Pipe().VerboseLine(data);
|
||||
Conn().VerboseLine(data);
|
||||
|
||||
// format e.g.:
|
||||
// //depot/P4Test/Assets/Lars.meta#2 - updating /Users/foobar/UnityProjects/PerforceTest/P4Test/Assets/Lars.meta
|
||||
|
|
|
@ -16,19 +16,19 @@ public:
|
|||
m_Result.clear();
|
||||
|
||||
ChangelistRevision cl;
|
||||
Pipe() >> cl;
|
||||
Conn() >> cl;
|
||||
|
||||
vector<string> toks;
|
||||
if (Tokenize(toks, m_ProjectPath, "/") == 0)
|
||||
{
|
||||
Pipe().BeginList();
|
||||
Pipe().WarnLine(string("Project path invalid - ") + m_ProjectPath);
|
||||
Pipe().EndList();
|
||||
Pipe().EndResponse();
|
||||
Conn().BeginList();
|
||||
Conn().WarnLine(string("Project path invalid - ") + m_ProjectPath);
|
||||
Conn().EndList();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
Pipe().Log().Debug() << "Project path is " << m_ProjectPath << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Project path is " << m_ProjectPath << Endl;
|
||||
|
||||
string rev = cl == kDefaultListRevision ? string("default") : cl;
|
||||
const std::string cmd = string("describe -s ") + rev;
|
||||
|
@ -38,25 +38,25 @@ public:
|
|||
if (!MapToLocal(task, m_Result))
|
||||
{
|
||||
// Abort since there was an error mapping files to depot path
|
||||
Pipe().BeginList();
|
||||
Pipe().WarnLine("Files couldn't be mapped in perforce view");
|
||||
Pipe().EndList();
|
||||
Pipe().EndResponse();
|
||||
Conn().BeginList();
|
||||
Conn().WarnLine("Files couldn't be mapped in perforce view");
|
||||
Conn().EndList();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
Pipe() << m_Result;
|
||||
Conn() << m_Result;
|
||||
m_Result.clear();
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OutputText( const char *data, int length)
|
||||
{
|
||||
Pipe().Log().Debug() << "OutputText()" << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "OutputText()" << Endl;
|
||||
}
|
||||
|
||||
// Called once per asset
|
||||
|
@ -68,14 +68,14 @@ public:
|
|||
// to get the filesystem path we remove the append this
|
||||
// to the Root path.
|
||||
|
||||
Pipe().Log().Info() << "OutputInfo: " << data << unityplugin::Endl;
|
||||
Conn().Log().Info() << "OutputInfo: " << data << Endl;
|
||||
|
||||
string d(data);
|
||||
Pipe().VerboseLine(d);
|
||||
Conn().VerboseLine(d);
|
||||
string::size_type i = d.rfind(" ");
|
||||
if (i == string::npos || i < 2 || i+1 >= d.length()) // 2 == "//".length()
|
||||
{
|
||||
Pipe().WarnLine(string("Invalid change asset - ") + d);
|
||||
Conn().WarnLine(string("Invalid change asset - ") + d);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,22 +28,22 @@ public:
|
|||
ClearStatus();
|
||||
m_Changelists.clear();
|
||||
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
|
||||
// const std::string cmd = string("fstat -T \"depotFile headChange haveRev headRev headAction action\" //depot/...");
|
||||
string rootPathWildcard = TrimEnd(TrimEnd(task.GetAssetsPath(), '/'), '\\') + "/...";
|
||||
const std::string cmd = string("fstat -T \"depotFile headChange haveRev headRev headAction action\" \"") + rootPathWildcard + "\"";
|
||||
|
||||
Pipe().BeginList();
|
||||
Conn().BeginList();
|
||||
|
||||
if (!task.CommandRun(cmd, this))
|
||||
{
|
||||
// The OutputStat and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
m_Changelists.clear();
|
||||
Pipe().EndList();
|
||||
Pipe() << GetStatus();
|
||||
Pipe().EndResponse();
|
||||
Conn().EndList();
|
||||
Conn() << GetStatus();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
{
|
||||
ss.str("");
|
||||
ss << "changes -l -s submitted \"@" << *i << ",@" << *i << "\"";
|
||||
Pipe().Log().Info() << " " << ss.str() << unityplugin::Endl;
|
||||
Conn().Log().Info() << " " << ss.str() << Endl;
|
||||
|
||||
if (!task.CommandRun(ss.str(), this))
|
||||
{
|
||||
|
@ -67,9 +67,9 @@ public:
|
|||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndList();
|
||||
Pipe() << GetStatus();
|
||||
Pipe().EndResponse();
|
||||
Conn().EndList();
|
||||
Conn() << GetStatus();
|
||||
Conn().EndResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
// Called once per file for status commands
|
||||
void OutputStat( StrDict *varList )
|
||||
{
|
||||
//Pipe().Log().Info() << "Output list stat" << endl;
|
||||
//Conn().Log().Info() << "Output list stat" << endl;
|
||||
|
||||
int i;
|
||||
StrRef var, val;
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
string value(val.Text());
|
||||
verboseLine += key + ":" + value + ", ";
|
||||
|
||||
//Pipe().Log().Debug() << " " << key << " # " << value << endl;
|
||||
//Conn().Log().Debug() << " " << key << " # " << value << endl;
|
||||
|
||||
if (key == "depotFile")
|
||||
depotFile = string(val.Text());
|
||||
|
@ -127,10 +127,10 @@ public:
|
|||
else if (key == "haveRev")
|
||||
haveRev = atoi(val.Text());
|
||||
else
|
||||
Pipe().Log().Notice() << "Warning: skipping unknown stat variable: " << key << " : " << val.Text() << unityplugin::Endl;
|
||||
Conn().Log().Notice() << "Warning: skipping unknown stat variable: " << key << " : " << val.Text() << Endl;
|
||||
}
|
||||
|
||||
Pipe().VerboseLine(verboseLine);
|
||||
Conn().VerboseLine(verboseLine);
|
||||
|
||||
if (headChange == -1 && added)
|
||||
return; // don't think about files added locally
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
|
||||
if (depotFile.empty() || headChange == -1 || headRev == -1)
|
||||
{
|
||||
Pipe().WarnLine(string("invalid p4 stat result: ") + (depotFile.empty() ? string("no depotFile") : depotFile));
|
||||
Conn().WarnLine(string("invalid p4 stat result: ") + (depotFile.empty() ? string("no depotFile") : depotFile));
|
||||
}
|
||||
else if (haveRev != headRev && !syncedDelete)
|
||||
{
|
||||
|
@ -153,13 +153,13 @@ public:
|
|||
void OutputInfo( char level, const char *data )
|
||||
{
|
||||
string d(data);
|
||||
Pipe().VerboseLine(d);
|
||||
Conn().VerboseLine(d);
|
||||
|
||||
const size_t minLength = 8; // "Change x".length()
|
||||
|
||||
if (d.length() <= minLength)
|
||||
{
|
||||
Pipe().WarnLine(string("p4 changelist too short: ") + d);
|
||||
Conn().WarnLine(string("p4 changelist too short: ") + d);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ public:
|
|||
string::size_type i = d.find(' ', 8);
|
||||
if (i == string::npos)
|
||||
{
|
||||
Pipe().WarnLine(string("p4 couldn't locate revision: ") + d);
|
||||
Conn().WarnLine(string("p4 couldn't locate revision: ") + d);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
Changelist item;
|
||||
item.SetDescription(d.substr(i+1));
|
||||
item.SetRevision(d.substr(minLength-1, i - (minLength-1)));
|
||||
Pipe() << item;
|
||||
Conn() << item;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
|
||||
if (d.find("already locked by") != string::npos)
|
||||
{
|
||||
Pipe().WarnLine(data, MARemote);
|
||||
Conn().WarnLine(data, MARemote);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
{
|
||||
if (!task.IsConnected()) // Cannot login without being connected
|
||||
{
|
||||
Pipe().Log().Info() << "Cannot login when not connected" << unityplugin::Endl;
|
||||
Conn().Log().Info() << "Cannot login when not connected" << Endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,13 @@ public:
|
|||
if (!task.CommandRun(cmd, this) && !m_CheckingForLoggedIn)
|
||||
{
|
||||
string errorMessage = GetStatusMessage();
|
||||
Pipe().Log().Notice() << "ERROR: " << errorMessage << unityplugin::Endl;
|
||||
Conn().Log().Notice() << "ERROR: " << errorMessage << Endl;
|
||||
}
|
||||
|
||||
if (m_CheckingForLoggedIn)
|
||||
Pipe().Log().Debug() << "Is logged in: " << (m_LoggedIn ? "yes" : "no") << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Is logged in: " << (m_LoggedIn ? "yes" : "no") << Endl;
|
||||
else
|
||||
Pipe().Log().Info() << "Login " << (m_LoggedIn ? "succeeded" : "failed") << unityplugin::Endl;
|
||||
Conn().Log().Info() << "Login " << (m_LoggedIn ? "succeeded" : "failed") << Endl;
|
||||
|
||||
m_CheckingForLoggedIn = false;
|
||||
return m_LoggedIn;
|
||||
|
@ -42,8 +42,8 @@ public:
|
|||
void OutputInfo( char level, const char *data )
|
||||
{
|
||||
string d(data);
|
||||
Pipe().Log().Debug() << "OutputInfo: " << d << unityplugin::Endl;
|
||||
Pipe().VerboseLine(d);
|
||||
Conn().Log().Debug() << "OutputInfo: " << d << Endl;
|
||||
Conn().VerboseLine(d);
|
||||
|
||||
m_LoggedIn = d == "'login' not necessary, no password set for this user.";
|
||||
if (m_LoggedIn)
|
||||
|
@ -90,10 +90,10 @@ public:
|
|||
// Entering password
|
||||
void Prompt( const StrPtr &msg, StrBuf &buf, int noEcho ,Error *e )
|
||||
{
|
||||
Pipe().Log().Info() << "Prompted for password by server" << unityplugin::Endl;
|
||||
Pipe().Log().Debug() << "Prompt: " << msg.Text() << unityplugin::Endl;
|
||||
Conn().Log().Info() << "Prompted for password by server" << Endl;
|
||||
Conn().Log().Debug() << "Prompt: " << msg.Text() << Endl;
|
||||
buf.Set(m_Password.c_str());
|
||||
Pipe().VerboseLine("Prompted for password");
|
||||
Conn().VerboseLine("Prompted for password");
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
{
|
||||
if (!task.IsConnected()) // Cannot logout without being connected
|
||||
{
|
||||
Pipe().Log().Info() << "Cannot logout when not connected" << unityplugin::Endl;
|
||||
Conn().Log().Info() << "Cannot logout when not connected" << Endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public:
|
|||
if (!task.CommandRun("logout", this))
|
||||
{
|
||||
string errorMessage = GetStatusMessage();
|
||||
Pipe().Log().Notice() << errorMessage << unityplugin::Endl;
|
||||
Conn().Log().Notice() << errorMessage << Endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -12,24 +12,24 @@ public:
|
|||
virtual bool Run(P4Task& task, const CommandArgs& args)
|
||||
{
|
||||
ClearStatus();
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
|
||||
bool noLocalFileMove = args.size() > 1 && args[1] == "noLocalFileMove";
|
||||
|
||||
VersionedAssetList assetList;
|
||||
Pipe() >> assetList;
|
||||
Conn() >> assetList;
|
||||
|
||||
if ( assetList.empty() )
|
||||
{
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Process two assets at a time ie. src,dest
|
||||
if ( assetList.size() % 2 )
|
||||
{
|
||||
Pipe().WarnLine("uneven number of assets during move", MASystem);
|
||||
Pipe().EndResponse();
|
||||
Conn().WarnLine("uneven number of assets during move", MASystem);
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
string paths = ResolvePaths(b, e, kPathWild | kPathRecursive);
|
||||
|
||||
Pipe().Log().Debug() << "Ensure editable source " << paths << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Ensure editable source " << paths << Endl;
|
||||
|
||||
string err;
|
||||
bool editable = (src.GetState() & (kCheckedOutLocal | kAddedLocal | kLockedLocal)) != 0;
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
if (!editable)
|
||||
{
|
||||
string srcPath = ResolvePaths(b, b+1, kPathWild | kPathRecursive);
|
||||
Pipe().Log().Info() << "edit " << srcPath << unityplugin::Endl;
|
||||
Conn().Log().Info() << "edit " << srcPath << Endl;
|
||||
if (!task.CommandRun("edit " + srcPath, this))
|
||||
{
|
||||
break;
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
string paths = ResolvePaths(b, e, kPathWild | kPathRecursive);
|
||||
|
||||
Pipe().Log().Info() << "move " << noLocalFileMoveFlag << paths << unityplugin::Endl;
|
||||
Conn().Log().Info() << "move " << noLocalFileMoveFlag << paths << Endl;
|
||||
if (!task.CommandRun("move " + noLocalFileMoveFlag + paths, this))
|
||||
{
|
||||
break;
|
||||
|
@ -95,7 +95,7 @@ public:
|
|||
errorMessage += src.GetPath();
|
||||
errorMessage += " to ";
|
||||
errorMessage += dest.GetPath();
|
||||
Pipe().WarnLine(errorMessage);
|
||||
Conn().WarnLine(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,11 +110,11 @@ public:
|
|||
}
|
||||
|
||||
// We just wrap up the communication here.
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
RunAndSendStatus(task, targetAssetList);
|
||||
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ public:
|
|||
P4QueryConfigParametersCommand(const char* name) : P4Command(name) {}
|
||||
virtual bool Run(P4Task& task, const CommandArgs& args)
|
||||
{
|
||||
Pipe().DataLine("text username");
|
||||
Pipe().DataLine("text password");
|
||||
Pipe().DataLine("hostAndPort server localhost 1666");
|
||||
Pipe().DataLine("text workspace");
|
||||
Pipe().DataLine("");
|
||||
Conn().DataLine("text username");
|
||||
Conn().DataLine("text password");
|
||||
Conn().DataLine("hostAndPort server localhost 1666");
|
||||
Conn().DataLine("text workspace");
|
||||
Conn().DataLine("");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ public:
|
|||
virtual bool Run(P4Task& task, const CommandArgs& args)
|
||||
{
|
||||
ClearStatus();
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
std::string errorMessage;
|
||||
|
||||
const string cmd = args.size() > 1 && args[1] == "unchangedOnly" ?
|
||||
|
@ -19,12 +19,12 @@ public:
|
|||
"revert -c ";
|
||||
|
||||
ChangelistRevisions changes;
|
||||
Pipe() >> changes;
|
||||
Conn() >> changes;
|
||||
|
||||
if (changes.empty())
|
||||
{
|
||||
Pipe().WarnLine("Changes to revert is empty", MARemote);
|
||||
Pipe().EndResponse();
|
||||
Conn().WarnLine("Changes to revert is empty", MARemote);
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -40,13 +40,13 @@ public:
|
|||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
// @TODO: send changed assets
|
||||
VersionedAssetList dummy;
|
||||
Pipe() << dummy;
|
||||
Conn() << dummy;
|
||||
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,22 +15,22 @@ public:
|
|||
m_ProjectPath = task.GetP4Root();
|
||||
m_Result.clear();
|
||||
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
|
||||
string cmd = SetupCommand(args);
|
||||
|
||||
VersionedAssetList assetList;
|
||||
Pipe() >> assetList;
|
||||
Conn() >> assetList;
|
||||
string paths = ResolvePaths(assetList, kPathWild | kPathSkipFolders);
|
||||
|
||||
Pipe().Log().Debug() << "Paths resolved are: " << paths << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Paths resolved are: " << paths << Endl;
|
||||
|
||||
if (paths.empty())
|
||||
{
|
||||
Pipe().BeginList();
|
||||
Pipe().WarnLine("No paths for revert command", MARemote);
|
||||
Pipe().EndList();
|
||||
Pipe().EndResponse();
|
||||
Conn().BeginList();
|
||||
Conn().WarnLine("No paths for revert command", MARemote);
|
||||
Conn().EndList();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -41,22 +41,22 @@ public:
|
|||
if (!MapToLocal(task, m_Result))
|
||||
{
|
||||
// Abort since there was an error mapping files to depot path
|
||||
Pipe().BeginList();
|
||||
Pipe().WarnLine("Files couldn't be mapped in perforce view");
|
||||
Pipe().EndList();
|
||||
Pipe().EndResponse();
|
||||
Conn().BeginList();
|
||||
Conn().WarnLine("Files couldn't be mapped in perforce view");
|
||||
Conn().EndList();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
IncludeFolders(assetList);
|
||||
|
||||
Pipe() << m_Result;
|
||||
Conn() << m_Result;
|
||||
m_Result.clear();
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -125,8 +125,8 @@ public:
|
|||
|
||||
if (EndsWith(value, TrimEnd(" - file(s) not opened on this client.\n")))
|
||||
{
|
||||
Pipe().Log().Debug() << value << unityplugin::Endl;
|
||||
Pipe().VerboseLine(value);
|
||||
Conn().Log().Debug() << value << Endl;
|
||||
Conn().VerboseLine(value);
|
||||
return; // ignore
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
string::size_type iPathEnd = d.rfind("#");
|
||||
if (iPathEnd == string::npos)
|
||||
{
|
||||
Pipe().WarnLine(string("Invalid revert asset - ") + d);
|
||||
Conn().WarnLine(string("Invalid revert asset - ") + d);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@ public:
|
|||
if (!task.CommandRun(cmd, this))
|
||||
{
|
||||
string errorMessage = GetStatusMessage();
|
||||
Pipe().Log().Notice() << "ERROR: " << errorMessage << unityplugin::Endl;
|
||||
Conn().Log().Notice() << "ERROR: " << errorMessage << Endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_Root.empty())
|
||||
task.SetP4Root(m_Root);
|
||||
Pipe().Log().Info() << "Root set to " << m_Root << unityplugin::Endl;
|
||||
Conn().Log().Info() << "Root set to " << m_Root << Endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
void OutputInfo( char level, const char *data )
|
||||
{
|
||||
stringstream ss(data);
|
||||
Pipe().VerboseLine(data);
|
||||
Conn().VerboseLine(data);
|
||||
size_t minlen = 5; // "Root:"
|
||||
|
||||
string line;
|
||||
|
|
|
@ -38,7 +38,7 @@ void P4StatusBaseCommand::OutputStat( StrDict *varList )
|
|||
|
||||
string key(var.Text());
|
||||
string value(val.Text());
|
||||
// Pipe().Log().Debug() << key << " # " << value << endl;
|
||||
// Conn().Log().Debug() << key << " # " << value << endl;
|
||||
|
||||
if (EndsWith(value, notFound) && !StartsWith(key, invalidPath))
|
||||
{
|
||||
|
@ -109,9 +109,9 @@ void P4StatusBaseCommand::OutputStat( StrDict *varList )
|
|||
current.RemoveState(kLocal);
|
||||
}
|
||||
|
||||
Pipe().VerboseLine(current.GetPath());
|
||||
Conn().VerboseLine(current.GetPath());
|
||||
|
||||
Pipe() << current;
|
||||
Conn() << current;
|
||||
}
|
||||
|
||||
void P4StatusBaseCommand::HandleError( Error *err )
|
||||
|
@ -135,13 +135,13 @@ void P4StatusBaseCommand::HandleError( Error *err )
|
|||
// tried to get status with no files matching wildcard //... which is ok
|
||||
// or
|
||||
// tried to get status of empty dir ie. not matching /path/to/empty/dir/... which is ok
|
||||
Pipe().VerboseLine(value);
|
||||
Conn().VerboseLine(value);
|
||||
return;
|
||||
}
|
||||
else if (AddUnknown(asset, value))
|
||||
{
|
||||
Pipe() << asset;
|
||||
Pipe().VerboseLine(value);
|
||||
Conn() << asset;
|
||||
Conn().VerboseLine(value);
|
||||
return; // just ignore errors for unknown files and return them anyway
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,13 +16,13 @@ bool P4StatusCommand::Run(P4Task& task, const CommandArgs& args)
|
|||
ClearStatus();
|
||||
|
||||
bool recursive = args.size() > 1;
|
||||
Pipe().Log().Info() << "StatusCommand::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << "StatusCommand::Run()" << Endl;
|
||||
|
||||
VersionedAssetList assetList;
|
||||
Pipe() >> assetList;
|
||||
Conn() >> assetList;
|
||||
|
||||
RunAndSend(task, assetList, recursive);
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
if (P4Task::IsOnline() && !wasOnline)
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ bool P4StatusCommand::Run(P4Task& task, const CommandArgs& args)
|
|||
P4Task::NotifyOnline();
|
||||
}
|
||||
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ void P4StatusCommand::RunAndSend(P4Task& task, const VersionedAssetList& assetLi
|
|||
{
|
||||
string paths = ResolvePaths(assetList, kPathWild | kPathSkipFolders | (recursive ? kPathRecursive : kNone) );
|
||||
|
||||
Pipe().Log().Debug() << "Paths to stat are: " << paths << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Paths to stat are: " << paths << Endl;
|
||||
|
||||
Pipe().BeginList();
|
||||
Conn().BeginList();
|
||||
|
||||
if (paths.empty())
|
||||
{
|
||||
Pipe().EndList();
|
||||
// Pipe().ErrorLine("No paths to stat", MASystem);
|
||||
Conn().EndList();
|
||||
// Conn().ErrorLine("No paths to stat", MASystem);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ void P4StatusCommand::RunAndSend(P4Task& task, const VersionedAssetList& assetLi
|
|||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe().EndList();
|
||||
Conn().EndList();
|
||||
}
|
||||
|
||||
P4StatusCommand cStatus("status");
|
||||
|
|
|
@ -42,20 +42,20 @@ public:
|
|||
ClearStatus();
|
||||
m_Spec.clear();
|
||||
|
||||
Pipe().Log().Info() << args[0] << "::Run()" << unityplugin::Endl;
|
||||
Conn().Log().Info() << args[0] << "::Run()" << Endl;
|
||||
|
||||
bool saveOnly = args.size() > 1 && args[1] == "saveOnly";
|
||||
|
||||
Changelist changelist;
|
||||
Pipe() >> changelist;
|
||||
Conn() >> changelist;
|
||||
|
||||
VersionedAssetList assetList;
|
||||
Pipe() >> assetList;
|
||||
Conn() >> assetList;
|
||||
bool hasFiles = !assetList.empty();
|
||||
|
||||
// Run a view mapping job to get the right depot relative paths for the spec file
|
||||
string localPaths = ResolvePaths(assetList, kPathWild | kPathSkipFolders);
|
||||
Pipe().Log().Debug() << "Paths resolved are: " << localPaths << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Paths resolved are: " << localPaths << Endl;
|
||||
|
||||
const vector<Mapping>& mappings = GetMappings(task, assetList);
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
{
|
||||
// Abort since there was an error mapping files to depot path
|
||||
RunAndSendStatus(task, assetList);
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
|
||||
// The OutputState and other callbacks will now output to stdout.
|
||||
// We just wrap up the communication here.
|
||||
Pipe() << GetStatus();
|
||||
Conn() << GetStatus();
|
||||
|
||||
if (hasFiles)
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
; // @TODO: handle this case
|
||||
}
|
||||
|
||||
Pipe().EndResponse();
|
||||
Conn().EndResponse();
|
||||
|
||||
m_Spec.clear();
|
||||
return true;
|
||||
|
@ -120,8 +120,8 @@ public:
|
|||
// Default handler of P4
|
||||
virtual void InputData( StrBuf *buf, Error *err )
|
||||
{
|
||||
Pipe().Log().Debug() << "Spec is:" << unityplugin::Endl;
|
||||
Pipe().Log().Debug() << m_Spec << unityplugin::Endl;
|
||||
Conn().Log().Debug() << "Spec is:" << Endl;
|
||||
Conn().Log().Debug() << m_Spec << Endl;
|
||||
buf->Set(m_Spec.c_str());
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
|
||||
if (StartsWith(value, pendingMerges))
|
||||
{
|
||||
Pipe().WarnLine("Merges still pending. Resolve before submitting.", MASystem);
|
||||
Conn().WarnLine("Merges still pending. Resolve before submitting.", MASystem);
|
||||
return; // ignore
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ const std::string& P4Task::GetAssetsPath() const
|
|||
|
||||
int P4Task::Run()
|
||||
{
|
||||
m_Connection = new UnityConnection("./Library/p4plugin.log");
|
||||
m_Connection = new Connection("./Library/p4plugin.log");
|
||||
|
||||
|
||||
try
|
||||
|
@ -168,7 +168,7 @@ int P4Task::Run()
|
|||
|
||||
// Make it convenient to get the pipe even though the commands
|
||||
// are callback based.
|
||||
P4Command::s_UnityPipe = &m_Connection->Pipe();
|
||||
P4Command::s_Conn = m_Connection;
|
||||
|
||||
if (cmd == UCOM_Invalid)
|
||||
return 1; // error
|
||||
|
@ -180,7 +180,7 @@ int P4Task::Run()
|
|||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
m_Connection->Log().Fatal() << "Unhandled exception: " << e.what() << unityplugin::Endl;
|
||||
m_Connection->Log().Fatal() << "Unhandled exception: " << e.what() << Endl;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -190,8 +190,8 @@ bool P4Task::Dispatch(UnityCommand cmd, const std::vector<string>& args)
|
|||
// Simple hack to test custom commands
|
||||
if (cmd == UCOM_CustomCommand)
|
||||
{
|
||||
m_Connection->Pipe().WarnLine(string("You called the custom command ") + args[1]);
|
||||
m_Connection->Pipe().EndResponse();
|
||||
m_Connection->WarnLine(string("You called the custom command ") + args[1]);
|
||||
m_Connection->EndResponse();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ bool P4Task::Connect()
|
|||
if (status.size())
|
||||
{
|
||||
if (P4Command::HandleOnlineStatusOnError(&m_Error))
|
||||
SendToPipe(m_Connection->Pipe(), status, MAProtocol);
|
||||
SendToConnection(*m_Connection, status, MAProtocol);
|
||||
}
|
||||
|
||||
if( m_Error.Test() )
|
||||
|
@ -282,10 +282,10 @@ void P4Task::NotifyOffline(const string& reason)
|
|||
int i = 0;
|
||||
while (disableCmds[i])
|
||||
{
|
||||
s_Singleton->m_Connection->Pipe().Command(string("disableCommand ") + disableCmds[i], MAProtocol);
|
||||
s_Singleton->m_Connection->Command(string("disableCommand ") + disableCmds[i], MAProtocol);
|
||||
++i;
|
||||
}
|
||||
s_Singleton->m_Connection->Pipe().Command(string("offline ") + reason, MAProtocol);
|
||||
s_Singleton->m_Connection->Command(string("offline ") + reason, MAProtocol);
|
||||
}
|
||||
|
||||
void P4Task::NotifyOnline()
|
||||
|
@ -303,11 +303,11 @@ void P4Task::NotifyOnline()
|
|||
if (s_Singleton->m_IsOnline)
|
||||
return;
|
||||
|
||||
s_Singleton->m_Connection->Pipe().Command("online", MAProtocol);
|
||||
s_Singleton->m_Connection->Command("online", MAProtocol);
|
||||
int i = 0;
|
||||
while (enableCmds[i])
|
||||
{
|
||||
s_Singleton->m_Connection->Pipe().Command(string("enableCommand ") + enableCmds[i], MAProtocol);
|
||||
s_Singleton->m_Connection->Command(string("enableCommand ") + enableCmds[i], MAProtocol);
|
||||
++i;
|
||||
}
|
||||
s_Singleton->m_IsOnline = true;
|
||||
|
@ -334,12 +334,12 @@ bool P4Task::Login()
|
|||
|
||||
if (HasUnicodeNeededError(p4c->GetStatus()))
|
||||
{
|
||||
m_Connection->Pipe().InfoLine("Enabling unicode mode");
|
||||
m_Connection->InfoLine("Enabling unicode mode");
|
||||
EnableUTF8Mode();
|
||||
loggedIn = p4c->Run(*this, args);
|
||||
}
|
||||
|
||||
SendToPipe(m_Connection->Pipe(), p4c->GetStatus(), MAProtocol);
|
||||
SendToConnection(*m_Connection, p4c->GetStatus(), MAProtocol);
|
||||
|
||||
if (loggedIn)
|
||||
{
|
||||
|
@ -348,7 +348,7 @@ bool P4Task::Login()
|
|||
|
||||
if (GetP4Password().empty())
|
||||
{
|
||||
m_Connection->Log().Debug() << "Empty password -> skipping login" << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << "Empty password -> skipping login" << Endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ bool P4Task::Login()
|
|||
loggedIn = p4c->Run(*this, args);
|
||||
}
|
||||
|
||||
SendToPipe(m_Connection->Pipe(), p4c->GetStatus(), MAProtocol);
|
||||
SendToConnection(*m_Connection, p4c->GetStatus(), MAProtocol);
|
||||
|
||||
if (!loggedIn)
|
||||
{
|
||||
|
@ -378,7 +378,7 @@ bool P4Task::Login()
|
|||
vector<string> args;
|
||||
args.push_back("spec");
|
||||
bool res = p4c->Run(*this, args); // fetched root info
|
||||
SendToPipe(m_Connection->Pipe(), p4c->GetStatus(), MAProtocol);
|
||||
SendToConnection(*m_Connection, p4c->GetStatus(), MAProtocol);
|
||||
if (!res)
|
||||
NotifyOffline("Couldn't fetch client spec file from perforce server");
|
||||
return res;
|
||||
|
@ -413,7 +413,7 @@ bool P4Task::Disconnect()
|
|||
// NotifyOffline("Disconnected");
|
||||
|
||||
VCSStatus status = errorToVCSStatus(m_Error);
|
||||
SendToPipe(m_Connection->Pipe(), status, MAProtocol);
|
||||
SendToConnection(*m_Connection, status, MAProtocol);
|
||||
|
||||
if( m_Error.Test() )
|
||||
return false;
|
||||
|
@ -431,8 +431,8 @@ bool P4Task::IsConnected()
|
|||
bool P4Task::CommandRun(const string& command, P4Command* client)
|
||||
{
|
||||
|
||||
m_Connection->Log().Info() << command << unityplugin::Endl;
|
||||
m_Connection->Pipe().VerboseLine(command);
|
||||
m_Connection->Log().Info() << command << Endl;
|
||||
m_Connection->VerboseLine(command);
|
||||
|
||||
// Force connection if this hasn't been set-up already.
|
||||
// That is unless the command explicitely disallows connect.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "clientapi.h"
|
||||
#include "Status.h"
|
||||
#include "UnityConnection.h"
|
||||
#include "Connection.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
// Command execution
|
||||
std::string m_CommandOutput;
|
||||
|
||||
UnityConnection* m_Connection;
|
||||
Connection* m_Connection;
|
||||
|
||||
friend class P4Command;
|
||||
static P4Task* s_Singleton;
|
||||
|
|
|
@ -26,46 +26,46 @@ public:
|
|||
break;
|
||||
|
||||
case CK_AssetsPath:
|
||||
req.conn.Log().Info() << "Set assetsPath to " << val << unityplugin::Endl;
|
||||
req.conn.Log().Info() << "Set assetsPath to " << val << Endl;
|
||||
task.SetAssetsPath(val);
|
||||
break;
|
||||
|
||||
case CK_LogLevel:
|
||||
req.conn.Log().Info() << "Set log level to " << val << unityplugin::Endl;
|
||||
req.conn.Log().Info() << "Set log level to " << val << Endl;
|
||||
req.conn.Log().SetLogLevel(req.GetLogLevel());
|
||||
break;
|
||||
|
||||
case CK_Unknown:
|
||||
if (req.keyStr == "vcSubversionRepos")
|
||||
{
|
||||
req.conn.Log().Info() << "Set repos to " << val << unityplugin::Endl;
|
||||
req.conn.Log().Info() << "Set repos to " << val << Endl;
|
||||
task.SetRepository(val);
|
||||
}
|
||||
else if (req.keyStr == "vcSubversionUsername")
|
||||
{
|
||||
req.conn.Log().Info() << "Set username to " << val << unityplugin::Endl;
|
||||
req.conn.Log().Info() << "Set username to " << val << Endl;
|
||||
task.SetUser(val);
|
||||
}
|
||||
else if (req.keyStr == "vcSubversionPassword")
|
||||
{
|
||||
req.conn.Log().Info() << "Set password to *********" << unityplugin::Endl;
|
||||
req.conn.Log().Info() << "Set password to *********" << Endl;
|
||||
task.SetPassword(val);
|
||||
}
|
||||
else if (req.keyStr == "vcSubversionOptions")
|
||||
{
|
||||
req.conn.Log().Info() << "Set options to " << val << unityplugin::Endl;
|
||||
req.conn.Log().Info() << "Set options to " << val << Endl;
|
||||
task.SetOptions(val);
|
||||
}
|
||||
else if (req.keyStr == "vcSubversionExecutable")
|
||||
{
|
||||
req.conn.Log().Info() << "Set executable path to \"" << val << "\"" << unityplugin::Endl;
|
||||
req.conn.Log().Info() << "Set executable path to \"" << val << "\"" << Endl;
|
||||
task.SetSvnExecutable(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = "Unknown config field set on subversion plugin: ";
|
||||
msg += req.keyStr;
|
||||
req.conn.Pipe().WarnLine(msg, MAConfig);
|
||||
req.conn.WarnLine(msg, MAConfig);
|
||||
req.invalid = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
if (!EnsureDirectory(req.targetDir))
|
||||
{
|
||||
std::string msg = ToString("Could not create temp dir: ", req.targetDir);
|
||||
req.Pipe().ErrorLine(msg);
|
||||
req.conn.ErrorLine(msg);
|
||||
req.assets.clear();
|
||||
resp.Write();
|
||||
return true;
|
||||
|
@ -50,23 +50,23 @@ public:
|
|||
// include this asset in the response.
|
||||
if (!EnsurePresent(task, mine))
|
||||
{
|
||||
//req.conn.Log().Debug() << access(mine.GetPath().c_str(), F_OK) << unityplugin::Endl;
|
||||
req.conn.Log().Notice() << "No 'mine' file " << mine.GetPath() << unityplugin::Endl;
|
||||
req.Pipe().ErrorLine(std::string("No 'mine' file for ") + assetPath);
|
||||
//req.conn.Log().Debug() << access(mine.GetPath().c_str(), F_OK) << Endl;
|
||||
req.conn.Log().Notice() << "No 'mine' file " << mine.GetPath() << Endl;
|
||||
req.conn.ErrorLine(std::string("No 'mine' file for ") + assetPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!EnsurePresent(task, conflict, assetPath))
|
||||
{
|
||||
req.conn.Log().Notice() << "No 'conflict' file " << conflict.GetPath() << unityplugin::Endl;
|
||||
req.Pipe().ErrorLine(std::string("No 'conflict' file for ") + assetPath);
|
||||
req.conn.Log().Notice() << "No 'conflict' file " << conflict.GetPath() << Endl;
|
||||
req.conn.ErrorLine(std::string("No 'conflict' file for ") + assetPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!EnsurePresent(task, base, assetPath))
|
||||
{
|
||||
req.conn.Log().Notice() << "No 'base' file " << base.GetPath() << unityplugin::Endl;
|
||||
req.Pipe().ErrorLine(std::string("No 'base' file for ") + assetPath);
|
||||
req.conn.Log().Notice() << "No 'base' file " << base.GetPath() << Endl;
|
||||
req.conn.ErrorLine(std::string("No 'base' file for ") + assetPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,8 @@ public:
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
req.conn.Log().Notice() << e.what() << unityplugin::Endl;
|
||||
req.conn.Pipe().ErrorLine("Error downloading file through svn");
|
||||
req.conn.Log().Notice() << e.what() << Endl;
|
||||
req.conn.ErrorLine("Error downloading file through svn");
|
||||
resp.assets.clear();
|
||||
resp.Write();
|
||||
return true;
|
||||
|
|
|
@ -8,12 +8,12 @@ public:
|
|||
{
|
||||
// Subversion does
|
||||
SvnLogResult result;
|
||||
req.conn.Log().Info() << "Incoming assets for revision " << req.revision << unityplugin::Endl;
|
||||
req.conn.Log().Info() << "Incoming assets for revision " << req.revision << Endl;
|
||||
task.GetLog(result, req.revision, req.revision, true);
|
||||
|
||||
if (result.entries.empty())
|
||||
{
|
||||
req.conn.Pipe().WarnLine("No assets for svn revision");
|
||||
req.conn.WarnLine("No assets for svn revision");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
{
|
||||
VersionedAssetSet::const_iterator j = aset.find(*i);
|
||||
if (j == aset.end())
|
||||
req.conn.Log().Notice() << "Couldn't get state of file in incoming changelist. Skipping " << j->GetPath() << unityplugin::Endl;
|
||||
req.conn.Log().Notice() << "Couldn't get state of file in incoming changelist. Skipping " << j->GetPath() << Endl;
|
||||
else
|
||||
*i = *j;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ public:
|
|||
bool Run(SvnTask& task, MoveChangelistRequest& req, MoveChangelistResponse& resp)
|
||||
{
|
||||
// Revert to base
|
||||
req.Pipe().Progress(-1, 0, "Moving changelist");
|
||||
req.conn.Progress(-1, 0, "Moving changelist");
|
||||
|
||||
std::string cmd = "changelist ";
|
||||
if (req.changelist == kDefaultListRevision)
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
++i;
|
||||
if (i == req.assets.end())
|
||||
{
|
||||
req.conn.Pipe().ErrorLine(ToString("No destination path while moving source path ", srcPath));
|
||||
req.conn.ErrorLine(ToString("No destination path while moving source path ", srcPath));
|
||||
break;
|
||||
}
|
||||
std::string dstPath = "\"";
|
||||
|
|
|
@ -7,7 +7,7 @@ public:
|
|||
bool Run(SvnTask& task, OutgoingAssetsRequest& req, OutgoingAssetsResponse& resp)
|
||||
{
|
||||
// Subversion does
|
||||
req.conn.Log().Info() << "Outgoing assets for list " << req.revision << unityplugin::Endl;
|
||||
req.conn.Log().Info() << "Outgoing assets for list " << req.revision << Endl;
|
||||
|
||||
VersionedAssetList empty;
|
||||
VersionedAssetList assets;
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
if (!EnsureDirectory(tmpDir))
|
||||
{
|
||||
req.conn.Pipe().WarnLine(std::string("Could not create temp folder during 'revert keep modifications': ") + tmpDir);
|
||||
req.conn.WarnLine(std::string("Could not create temp folder during 'revert keep modifications': ") + tmpDir);
|
||||
resp.Write();
|
||||
return true;
|
||||
}
|
||||
|
@ -50,10 +50,10 @@ public:
|
|||
// Find relative folder path to projectPath
|
||||
std::string relPath = i->GetPath().substr(0, projectPath.length());
|
||||
std::string copyTo = tmpDir + relPath;
|
||||
req.conn.Log().Debug() << "CopyFile " << i->GetPath() << " -> " << copyTo << unityplugin::Endl;
|
||||
req.conn.Log().Debug() << "CopyFile " << i->GetPath() << " -> " << copyTo << Endl;
|
||||
if (!CopyAFile(i->GetPath(), copyTo, true))
|
||||
{
|
||||
req.conn.Pipe().WarnLine(std::string("Could not copy file info to temp folder during 'revert keep modifications'"));
|
||||
req.conn.WarnLine(std::string("Could not copy file info to temp folder during 'revert keep modifications'"));
|
||||
resp.Write();
|
||||
return true;
|
||||
}
|
||||
|
@ -83,10 +83,10 @@ public:
|
|||
// Find relative folder path to projectPath
|
||||
std::string relPath = i->GetPath().substr(0, projectPath.length());
|
||||
std::string copyFrom = tmpDir + relPath;
|
||||
req.conn.Log().Debug() << "CopyFile " << copyFrom << " -> " << i->GetPath() << unityplugin::Endl;
|
||||
req.conn.Log().Debug() << "CopyFile " << copyFrom << " -> " << i->GetPath() << Endl;
|
||||
if (!CopyAFile(copyFrom, i->GetPath(), true))
|
||||
{
|
||||
req.conn.Pipe().WarnLine(std::string("Could not copy file info from temp folder during 'revert keep modifications'"));
|
||||
req.conn.WarnLine(std::string("Could not copy file info from temp folder during 'revert keep modifications'"));
|
||||
// Keep going to try to make the damage as small as possible
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
// also used to move assets to a newly constructed changelist
|
||||
if (saveOnly)
|
||||
{
|
||||
req.Pipe().Progress(-1, 0, "Saving changelist");
|
||||
req.conn.Progress(-1, 0, "Saving changelist");
|
||||
std::string createChangelistCmd = "changelist ";
|
||||
std::string firstLineOfDescription = req.changelist.GetDescription();
|
||||
firstLineOfDescription = firstLineOfDescription.substr(0, firstLineOfDescription.find('\n'));
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
}
|
||||
cmd += Join(Paths(req.assets), " ", "\"");
|
||||
|
||||
req.Pipe().Progress(-1, 0, "submitting");
|
||||
req.conn.Progress(-1, 0, "submitting");
|
||||
APOpen ppipe = task.RunCommand(cmd);
|
||||
|
||||
std::string line;
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
req.conn.Log().Info() << line << "\n";
|
||||
|
||||
if (line.find("is not under version control and is not part of the commit, yet its child") != std::string::npos)
|
||||
req.conn.Pipe().WarnLine(line.substr(5)); // strip "svn: "
|
||||
req.conn.WarnLine(line.substr(5)); // strip "svn: "
|
||||
}
|
||||
|
||||
task.GetStatus(req.assets, resp.assets, recursive);
|
||||
|
|
|
@ -105,7 +105,7 @@ void SvnTask::SetSvnExecutable(const std::string& e)
|
|||
m_SvnPath = e;
|
||||
return;
|
||||
}
|
||||
m_Connection->Pipe().WarnLine(string("No svn executable at path '") + e + "'");
|
||||
m_Connection->WarnLine(string("No svn executable at path '") + e + "'");
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
|
@ -157,7 +157,7 @@ string SvnTask::GetProjectPath() const
|
|||
|
||||
int SvnTask::Run()
|
||||
{
|
||||
m_Connection = new UnityConnection("./Library/svnplugin.log");
|
||||
m_Connection = new Connection("./Library/svnplugin.log");
|
||||
|
||||
UnityCommand cmd;
|
||||
CommandArgs args;
|
||||
|
@ -179,23 +179,23 @@ int SvnTask::Run()
|
|||
}
|
||||
catch (SvnException& ex)
|
||||
{
|
||||
m_Connection->Log().Fatal() << "Fatal 1: " << ex.what() << unityplugin::Endl;
|
||||
m_Connection->Pipe().ErrorLine(ex.what());
|
||||
m_Connection->Pipe().EndResponse();
|
||||
m_Connection->Log().Fatal() << "Fatal 1: " << ex.what() << Endl;
|
||||
m_Connection->ErrorLine(ex.what());
|
||||
m_Connection->EndResponse();
|
||||
return 1;
|
||||
}
|
||||
catch (PluginException& ex)
|
||||
{
|
||||
m_Connection->Log().Fatal() << "Fatal 2: " << ex.what() << unityplugin::Endl;
|
||||
m_Connection->Pipe().ErrorLine(ex.what());
|
||||
m_Connection->Pipe().EndResponse();
|
||||
m_Connection->Log().Fatal() << "Fatal 2: " << ex.what() << Endl;
|
||||
m_Connection->ErrorLine(ex.what());
|
||||
m_Connection->EndResponse();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
m_Connection->Log().Fatal() << "Fatal: " << e.what() << unityplugin::Endl;
|
||||
m_Connection->Log().Fatal() << "Fatal: " << e.what() << Endl;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -206,7 +206,7 @@ APOpen SvnTask::RunCommand(const std::string& cmd)
|
|||
string cred = GetCredentials();
|
||||
string cmdline = "\"";
|
||||
cmdline += m_SvnPath + "\" " + cred + cmd;
|
||||
m_Connection->Log().Info() << cmdline << unityplugin::Endl;
|
||||
m_Connection->Log().Info() << cmdline << Endl;
|
||||
try
|
||||
{
|
||||
return APOpen(new POpen(cmdline));
|
||||
|
@ -499,7 +499,7 @@ bool SvnTask::HandleConnectErrorLine(const std::string& line)
|
|||
string::size_type si = line.find('\'');
|
||||
if (si != string::npos)
|
||||
msg += line.substr(si);
|
||||
m_Connection->Pipe().WarnLine(msg, MAProtocol);
|
||||
m_Connection->WarnLine(msg, MAProtocol);
|
||||
NotifyOffline(msg);
|
||||
}
|
||||
else if (svnVersionError)
|
||||
|
@ -508,7 +508,7 @@ bool SvnTask::HandleConnectErrorLine(const std::string& line)
|
|||
string msg = "Project ";
|
||||
msg += line.substr(i);
|
||||
msg += ". The unity builtin svn is a lower version. You can specify a custom svn path in Editor Settings.";
|
||||
m_Connection->Pipe().WarnLine(msg, MAProtocol);
|
||||
m_Connection->WarnLine(msg, MAProtocol);
|
||||
NotifyOffline(msg);
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ bool SvnTask::GetStatusWithChangelists(const VersionedAssetList& assets,
|
|||
cmd += " ";
|
||||
cmd += Join(Paths(assets), " ", "\"");
|
||||
|
||||
m_Connection->Pipe().Progress(-1, 0, "secs. while reading status...");
|
||||
m_Connection->Progress(-1, 0, "secs. while reading status...");
|
||||
|
||||
APOpen ppipe = RunCommand(cmd);
|
||||
|
||||
|
@ -547,11 +547,11 @@ bool SvnTask::GetStatusWithChangelists(const VersionedAssetList& assets,
|
|||
time_t thisTick = time(NULL);
|
||||
if (lastTick != thisTick)
|
||||
{
|
||||
m_Connection->Pipe().Progress(-1, thisTick - startTick, "secs. while reading status...");
|
||||
m_Connection->Progress(-1, thisTick - startTick, "secs. while reading status...");
|
||||
lastTick = thisTick;
|
||||
}
|
||||
|
||||
m_Connection->Log().Debug() << line << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << line << Endl;
|
||||
if (EndsWith(line, " was not found."))
|
||||
continue;
|
||||
|
||||
|
@ -560,7 +560,7 @@ bool SvnTask::GetStatusWithChangelists(const VersionedAssetList& assets,
|
|||
// Special case: If "EditorSettings.asset" is local if means that the repository is not valid and we mark it as such
|
||||
if (EndsWith(line, "\\ProjectSettings\\EditorSettings.asset' is not a working copy") || EndsWith(line, "/ProjectSettings/EditorSettings.asset' is not a working copy"))
|
||||
{
|
||||
m_Connection->Pipe().WarnLine("EditorSettings.asset file not part of a subversion working copy\nRemember to add at least the 'Assets' folder and meta file to subversion");
|
||||
m_Connection->WarnLine("EditorSettings.asset file not part of a subversion working copy\nRemember to add at least the 'Assets' folder and meta file to subversion");
|
||||
NotifyOffline("Project is not in a subversion working folder", true);
|
||||
return true;
|
||||
}
|
||||
|
@ -689,17 +689,17 @@ void SvnTask::GetLog(SvnLogResult& result, const std::string& from, const std::s
|
|||
cacheRev = atoi(from.c_str());
|
||||
if (cacheRev)
|
||||
{
|
||||
m_Connection->Log().Debug() << "Checking cache for single log revision " << cacheRev << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << "Checking cache for single log revision " << cacheRev << Endl;
|
||||
std::map<int, SvnLogResult::Entry>::iterator i = g_LogCache.find(cacheRev);
|
||||
if (i != g_LogCache.end())
|
||||
{
|
||||
m_Connection->Log().Debug() << " Found in cache" << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << " Found in cache" << Endl;
|
||||
result.entries.push_back(i->second);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Connection->Log().Debug() << " Not in cache" << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << " Not in cache" << Endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ void SvnTask::GetLog(SvnLogResult& result, const std::string& from, const std::s
|
|||
if (includeAssets)
|
||||
cmd += " -v ";
|
||||
|
||||
m_Connection->Pipe().Progress(-1, 0, "secs. while reading log...");
|
||||
m_Connection->Progress(-1, 0, "secs. while reading log...");
|
||||
|
||||
APOpen ppipe = RunCommand(cmd);
|
||||
|
||||
|
@ -740,11 +740,11 @@ void SvnTask::GetLog(SvnLogResult& result, const std::string& from, const std::s
|
|||
time_t thisTick = time(NULL);
|
||||
if (lastTick != thisTick)
|
||||
{
|
||||
m_Connection->Pipe().Progress(-1, thisTick - startTick, "secs. while reading log...");
|
||||
m_Connection->Progress(-1, thisTick - startTick, "secs. while reading log...");
|
||||
lastTick = thisTick;
|
||||
}
|
||||
|
||||
m_Connection->Log().Debug() << line << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << line << Endl;
|
||||
if (EndsWith(line, "is not a working copy"))
|
||||
{
|
||||
NotifyOffline("Project is not in a subversion working folder", true);
|
||||
|
@ -767,7 +767,7 @@ void SvnTask::GetLog(SvnLogResult& result, const std::string& from, const std::s
|
|||
if (!ppipe->ReadLine(line))
|
||||
break;
|
||||
|
||||
m_Connection->Log().Debug() << line << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << line << Endl;
|
||||
Enforce<SvnException>(line.length() >= MIN_HEADER_LINE_LENGTH && line[0] == 'r',
|
||||
string("Invalid log header: ") + line);
|
||||
|
||||
|
@ -790,7 +790,7 @@ void SvnTask::GetLog(SvnLogResult& result, const std::string& from, const std::s
|
|||
if (!ppipe->ReadLine(line))
|
||||
break;
|
||||
|
||||
m_Connection->Log().Debug() << line << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << line << Endl;
|
||||
|
||||
// Read until blank line which delimits asset files
|
||||
while (ppipe->ReadLine(line))
|
||||
|
@ -798,7 +798,7 @@ void SvnTask::GetLog(SvnLogResult& result, const std::string& from, const std::s
|
|||
if (line.empty())
|
||||
break;
|
||||
|
||||
m_Connection->Log().Debug() << line << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << line << Endl;
|
||||
|
||||
asset.Reset();
|
||||
string::size_type i1 = line.find_first_not_of(' ');
|
||||
|
@ -866,14 +866,14 @@ void SvnTask::GetLog(SvnLogResult& result, const std::string& from, const std::s
|
|||
// Skip first line of message which is blank
|
||||
if (!ppipe->ReadLine(line))
|
||||
break;
|
||||
m_Connection->Log().Debug() << line << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << line << Endl;
|
||||
}
|
||||
|
||||
for (long i = 0; i < messageLineCount; i++)
|
||||
{
|
||||
if (!ppipe->ReadLine(line))
|
||||
break;
|
||||
m_Connection->Log().Debug() << line << unityplugin::Endl;
|
||||
m_Connection->Log().Debug() << line << Endl;
|
||||
entry.message += line + "\n";
|
||||
}
|
||||
|
||||
|
@ -920,11 +920,11 @@ void SvnTask::NotifyOffline(const std::string& reason, bool invalidWorkingCopy)
|
|||
int i = 0;
|
||||
while (disableCmds[i])
|
||||
{
|
||||
m_Connection->Pipe().Command(string("disableCommand ") + disableCmds[i], MAProtocol);
|
||||
m_Connection->Command(string("disableCommand ") + disableCmds[i], MAProtocol);
|
||||
++i;
|
||||
}
|
||||
|
||||
m_Connection->Pipe().Command(string("offline ") + reason, MAProtocol);
|
||||
m_Connection->Command(string("offline ") + reason, MAProtocol);
|
||||
|
||||
g_LogCacheAssetsCount = 0;
|
||||
g_LogCache.clear();
|
||||
|
@ -951,7 +951,7 @@ void SvnTask::NotifyOnline()
|
|||
int i = 0;
|
||||
while (enableCmds[i])
|
||||
{
|
||||
m_Connection->Pipe().Command(string("enableCommand ") + enableCmds[i], MAProtocol);
|
||||
m_Connection->Command(string("enableCommand ") + enableCmds[i], MAProtocol);
|
||||
++i;
|
||||
}
|
||||
|
||||
|
@ -963,11 +963,11 @@ void SvnTask::NotifyOnline()
|
|||
i = 0;
|
||||
while (disableCmds[i])
|
||||
{
|
||||
m_Connection->Pipe().Command(string("disableCommand ") + disableCmds[i], MAProtocol);
|
||||
m_Connection->Command(string("disableCommand ") + disableCmds[i], MAProtocol);
|
||||
++i;
|
||||
}
|
||||
m_IsOnline = true;
|
||||
m_Connection->Pipe().Command("online");
|
||||
m_Connection->Command("online");
|
||||
g_LogCacheAssetsCount = 0;
|
||||
g_LogCache.clear();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#pragma once
|
||||
#include "UnityConnection.h"
|
||||
#include "Connection.h"
|
||||
#include "VersionedAsset.h"
|
||||
#include "Utility.h"
|
||||
|
||||
|
@ -58,7 +58,7 @@ private:
|
|||
|
||||
bool m_IsOnline;
|
||||
|
||||
UnityConnection* m_Connection;
|
||||
Connection* m_Connection;
|
||||
};
|
||||
|
||||
class SvnException : public std::exception
|
||||
|
|
Загрузка…
Ссылка в новой задаче