Permalink
Browse files

Added class to fetch log asynchronously so the UI doesn't block.

Added a check that the executable used by the log genration command exists (only implemented on Windows currently).

Moved log format classes to formats sub directory.
  • Loading branch information...
1 parent 5786726 commit 5b2ba32f75de821bcb4935f7bfafdd05e4fdd4a2 @acaudwell committed Apr 9, 2012
View
@@ -32,8 +32,8 @@
<Add library="glu32" />
<Add library="glew32" />
<Add library="freetype" />
- <Add library="boost_filesystem-mgw44-mt-1_46_1" />
- <Add library="libboost_system-mgw44-mt-1_46_1" />
+ <Add library="boost_filesystem-mgw46-mt-1_48" />
+ <Add library="libboost_system-mgw46-mt-1_48" />
</Linker>
<Unit filename="data\shaders\bloom.frag" />
<Unit filename="data\shaders\bloom.vert" />
@@ -43,14 +43,8 @@
<Unit filename="data\shaders\text.vert" />
<Unit filename="src\action.cpp" />
<Unit filename="src\action.h" />
- <Unit filename="src\apache.cpp" />
- <Unit filename="src\apache.h" />
<Unit filename="src\bloom.cpp" />
<Unit filename="src\bloom.h" />
- <Unit filename="src\bzr.cpp" />
- <Unit filename="src\bzr.h" />
- <Unit filename="src\commitlog.cpp" />
- <Unit filename="src\commitlog.h" />
<Unit filename="src\core\bounds.h" />
<Unit filename="src\core\conffile.cpp" />
<Unit filename="src\core\conffile.h" />
@@ -92,30 +86,40 @@
<Unit filename="src\core\vbo.h" />
<Unit filename="src\core\vectors.cpp" />
<Unit filename="src\core\vectors.h" />
- <Unit filename="src\custom.cpp" />
- <Unit filename="src\custom.h" />
- <Unit filename="src\cvs-exp.cpp" />
- <Unit filename="src\cvs-exp.h" />
- <Unit filename="src\cvs2cl.cpp" />
- <Unit filename="src\cvs2cl.h" />
<Unit filename="src\dirnode.cpp" />
<Unit filename="src\dirnode.h" />
<Unit filename="src\file.cpp" />
<Unit filename="src\file.h" />
- <Unit filename="src\git.cpp" />
- <Unit filename="src\git.h" />
- <Unit filename="src\gitraw.cpp" />
- <Unit filename="src\gitraw.h" />
+ <Unit filename="src\formats\apache.cpp" />
+ <Unit filename="src\formats\apache.h" />
+ <Unit filename="src\formats\bzr.cpp" />
+ <Unit filename="src\formats\bzr.h" />
+ <Unit filename="src\formats\commitlog.cpp" />
+ <Unit filename="src\formats\commitlog.h" />
+ <Unit filename="src\formats\custom.cpp" />
+ <Unit filename="src\formats\custom.h" />
+ <Unit filename="src\formats\cvs-exp.cpp" />
+ <Unit filename="src\formats\cvs-exp.h" />
+ <Unit filename="src\formats\cvs2cl.cpp" />
+ <Unit filename="src\formats\cvs2cl.h" />
+ <Unit filename="src\formats\git.cpp" />
+ <Unit filename="src\formats\git.h" />
+ <Unit filename="src\formats\gitraw.cpp" />
+ <Unit filename="src\formats\gitraw.h" />
+ <Unit filename="src\formats\hg.cpp" />
+ <Unit filename="src\formats\hg.h" />
+ <Unit filename="src\formats\svn.cpp" />
+ <Unit filename="src\formats\svn.h" />
<Unit filename="src\gource.cpp" />
<Unit filename="src\gource.h" />
<Unit filename="src\gource_settings.cpp" />
<Unit filename="src\gource_settings.h" />
<Unit filename="src\gource_shell.cpp" />
<Unit filename="src\gource_shell.h" />
- <Unit filename="src\hg.cpp" />
- <Unit filename="src\hg.h" />
<Unit filename="src\key.cpp" />
<Unit filename="src\key.h" />
+ <Unit filename="src\logmill.cpp" />
+ <Unit filename="src\logmill.h" />
<Unit filename="src\main.cpp" />
<Unit filename="src\main.h" />
<Unit filename="src\pawn.cpp" />
@@ -124,8 +128,6 @@
<Unit filename="src\slider.h" />
<Unit filename="src\spline.cpp" />
<Unit filename="src\spline.h" />
- <Unit filename="src\svn.cpp" />
- <Unit filename="src\svn.h" />
<Unit filename="src\textbox.cpp" />
<Unit filename="src\textbox.h" />
<Unit filename="src\tinyxml\tinystr.cpp" />
File renamed without changes.
File renamed without changes.
@@ -53,14 +53,17 @@ BaseLog* BazaarLog::generateLog(const std::string& dir) {
std::string command = getLogCommand();
+ // do we have this client installed
+ requireExecutable("bzr");
+
createTempLog();
if(temp_file.size()==0) return 0;
char cmd_buff[2048];
sprintf(cmd_buff, "%s %s > %s", command.c_str(), dir.c_str(), temp_file.c_str());
- int command_rc = system(cmd_buff);
+ int command_rc = systemCommand(cmd_buff);
if(command_rc != 0) {
return 0;
File renamed without changes.
@@ -16,7 +16,7 @@
*/
#include "commitlog.h"
-#include "gource_settings.h"
+#include "../gource_settings.h"
std::string munge_utf8(const std::string& str) {
@@ -86,6 +86,26 @@ RCommitLog::~RCommitLog() {
}
}
+int RCommitLog::systemCommand(const std::string& command) {
+#ifdef _WIN32
+ SDLAppCreateWindowsConsole();
+#endif
+ return system(command.c_str());
+}
+
+// TODO: implement check for 'nix OSs
+void RCommitLog::requireExecutable(const std::string& exename) {
+
+#ifdef _WIN32
+ TCHAR exePath[MAX_PATH];
+ DWORD result = SearchPath(0, exename.c_str(), ".exe", MAX_PATH, exePath, 0);
+
+ if(result) return;
+
+ throw SDLAppException("unable to find %s.exe", exename.c_str());
+#endif
+}
+
//check firstChar of stream is as expected. if no firstChar defined just returns true.
bool RCommitLog::checkFirstChar(int firstChar, std::istream& stream) {
@@ -19,11 +19,11 @@
#define RCOMMIT_LOG_H
-#include "core/seeklog.h"
-#include "core/display.h"
-#include "core/regex.h"
-#include "core/stringhash.h"
-#include "core/utf8/utf8.h"
+#include "../core/seeklog.h"
+#include "../core/display.h"
+#include "../core/regex.h"
+#include "../core/stringhash.h"
+#include "../core/utf8/utf8.h"
#include <time.h>
#include <string>
@@ -92,6 +92,9 @@ class RCommitLog {
std::string getLogCommand();
+ int systemCommand(const std::string& command);
+ void requireExecutable(const std::string& exename);
+
bool getCommitAt(float percent, RCommit& commit);
bool findNextCommit(RCommit& commit, int attempts);
bool nextCommit(RCommit& commit, bool validate = true);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -18,16 +18,15 @@
#ifndef CVS2CL_H
#define CVS2CL_H
-#include "gource_settings.h"
-
+#include "../gource_settings.h"
#include "commitlog.h"
#include <sstream>
#ifdef HAVE_LIBTINYXML
#include <tinyxml.h>
#else
-#include "tinyxml/tinyxml.h"
+#include "../tinyxml/tinyxml.h"
#endif
@@ -65,6 +65,9 @@ BaseLog* GitCommitLog::generateLog(const std::string& dir) {
return 0;
}
+ // do we have this client installed
+ requireExecutable("git");
+
std::string command = getLogCommand();
//create temp file
@@ -79,7 +82,7 @@ BaseLog* GitCommitLog::generateLog(const std::string& dir) {
char cmd_buff[2048];
sprintf(cmd_buff, "%s > %s", command.c_str(), temp_file.c_str());
- int command_rc = system(cmd_buff);
+ int command_rc = systemCommand(cmd_buff);
if(command_rc != 0) {
chdir(cwd_buff);
@@ -96,7 +99,7 @@ BaseLog* GitCommitLog::generateLog(const std::string& dir) {
if(!strcmp(firstBytes, "user:%aN")) {
char *pos = strstr(cmd_buff, "%aN");
pos[2] = 'n';
- command_rc = system(cmd_buff);
+ command_rc = systemCommand(cmd_buff);
}
//change back to original directoy
@@ -18,8 +18,7 @@
#ifndef GITLOG_H
#define GITLOG_H
-#include "gource_settings.h"
-
+#include "../gource_settings.h"
#include "commitlog.h"
#include <unistd.h>
File renamed without changes.
File renamed without changes.
@@ -53,6 +53,9 @@ BaseLog* MercurialLog::generateLog(const std::string& dir) {
return 0;
}
+ // do we have this client installed
+ requireExecutable("hg");
+
std::string command = getLogCommand();
createTempLog();
@@ -62,7 +65,7 @@ BaseLog* MercurialLog::generateLog(const std::string& dir) {
char cmd_buff[2048];
sprintf(cmd_buff, "%s -R \"%s\" > %s", command.c_str(), dir.c_str(), temp_file.c_str());
- int command_rc = system(cmd_buff);
+ int command_rc = systemCommand(cmd_buff);
if(command_rc != 0) {
return 0;
@@ -77,12 +80,12 @@ BaseLog* MercurialLog::generateLog(const std::string& dir) {
bool MercurialLog::parseCommit(RCommit& commit) {
while(parseCommitEntry(commit));
-
+
return !commit.files.empty();
}
bool MercurialLog::parseCommitEntry(RCommit& commit) {
-
+
std::string line;
std::vector<std::string> entries;
@@ -106,7 +109,7 @@ bool MercurialLog::parseCommitEntry(RCommit& commit) {
return false;
}
}
-
+
std::string action = "A";
if(!entries[2].empty()) {
File renamed without changes.
@@ -58,6 +58,9 @@ BaseLog* SVNCommitLog::generateLog(const std::string& dir) {
return 0;
}
+ // do we have this client installed
+ requireExecutable("svn");
+
std::string command = getLogCommand();
//create temp file
@@ -72,7 +75,7 @@ BaseLog* SVNCommitLog::generateLog(const std::string& dir) {
char cmd_buff[2048];
sprintf(cmd_buff, "%s > %s", command.c_str(), temp_file.c_str());
- int command_rc = system(cmd_buff);
+ int command_rc = systemCommand(cmd_buff);
chdir(cwd_buff);
@@ -18,7 +18,7 @@
#ifndef SVNLOG_H
#define SVNLOG_H
-#include "gource_settings.h"
+#include "../gource_settings.h"
#include "commitlog.h"
@@ -27,7 +27,7 @@
#ifdef HAVE_LIBTINYXML
#include <tinyxml.h>
#else
-#include "tinyxml/tinyxml.h"
+#include "../tinyxml/tinyxml.h"
#endif
#include <unistd.h>
Oops, something went wrong.

0 comments on commit 5b2ba32

Please sign in to comment.