Permalink
Browse files

Added --user-filter REGEX option.

  • Loading branch information...
1 parent a1ed095 commit ce07573d0b18b68a2fa6e2e683fb7ee9f89dd78f @acaudwell committed Jul 9, 2010
Showing with 102 additions and 38 deletions.
  1. +1 −0 ChangeLog
  2. +14 −6 README
  3. +12 −3 data/gource.1
  4. +30 −19 src/gource.cpp
  5. +44 −10 src/gource_settings.cpp
  6. +1 −0 src/gource_settings.h
View
@@ -17,6 +17,7 @@
* Added --hide 'mouse' option.
* Added --highlight-dirs option.
* Added --file-extensions to show filename extensions only.
+ * Added --user-filter REGEX option.
* Allow --file-idle-time 0 (files will never expire).
* Allow --start-position 'random' to set a random start position.
* --log-command VCS replaces multiple --log-command-VCS options.
View
20 README
@@ -136,6 +136,9 @@ options:
--file-extensions
Show filename extensions only.
+ --user-filter REGEX
+ Filter out any users matching a specified regular expression.
+
--user-image-dir DIRECTORY
Directory containing .jpg or .png images of users
(eg 'Full Name.png') to use as avatars.
@@ -198,21 +201,26 @@ options:
-o, --output-ppm-stream FILE
Output a PPM image stream to a file ('-' for STDOUT).
+ This will automatically hide the progress bar initially and
+ enable 'stop-at-end' unless other behaviour is specified.
+
-r, --output-framerate FPS
Framerate of output (25,30,60). Used with --output-ppm-stream.
--load-config CONFIG_FILE
- Load a config file.
+ Load a gource conf file.
--save-config CONFIG_FILE
- Save a config file with the current options.
+ Save a gource conf file with the current options.
--path PATH
- path Either a Git, Bazaar or Mercurial directory, a pre-generated log
- file (see log commands or the custom log format) or '-' to read
- STDIN. If path is ommited gource will attempt to read a log from
- the current directory.
+ path Either a supported version control directory, a pre-generated log
+ file (see log commands or the custom log format), a gource conf
+ file or '-' to read STDIN.
+
+ If path is ommited, gource will attempt to read a log from the
+ current directory.
Git, Bazaar and Mercurial Examples:
View
@@ -103,11 +103,14 @@ Highlight the names of all users.
\fB\-\-highlight\-dirs\fR
Highlight the names of all directories.
.TP
+\fB\-\-file\-extensions\fR
+Show filename extensions only.
+.TP
\fB\-\-file\-filter REGEX\fR
Filter out any files matching a specified regular expression.
.TP
-\fB\-\-file\-extensions\fR
-Show filename extensions only.
+\fB\-\-user\-filter REGEX\fR
+Filter out any usernames matching a specified regular expression.
.TP
\fB\-\-user\-image\-dir DIRECTORY\fR
Directory containing .jpg or .png images of users (eg 'Full Name.png') to use as avatars.
@@ -170,6 +173,9 @@ Separate multiple elements with commas (eg 'mouse,progress')
.TP
\fB\-o, \-\-output\-ppm\-stream FILE\fR
Output a PPM image stream to a file ('\-' for STDOUT).
+
+This will automatically hide the progress bar initially and enable 'stop\-at\-end' unless other behaviour is specified.
+
.TP
\fB\-r, \-\-output\-framerate FPS\fR
Framerate of output (25,30,60). Used with \-\-output\-ppm\-stream.
@@ -183,7 +189,10 @@ Save a config file with the current options.
\fB\-\-path PATH\fR
.TP
\fBpath\fR
-Either a Git, Bazaar or Mercurial directory, a pre-generated log file (see log commands or the custom log format) or '\-' to read STDIN. If path is ommited \fIgource\fR will attempt to read a log from the current directory.
+Either a supported version control directory, a pre-generated log file (see log commands or the custom log format), a gource conf file or '-' to read STDIN.
+
+If path is ommited, gource will attempt to read a log from the current directory.
+
.SH GIT, BAZAAR AND MERCURIAL EXAMPLES
View the log of the respository in the current path:
View
@@ -913,42 +913,53 @@ void Gource::processCommit(RCommit& commit, float t) {
std::map<std::string, RUser*>::iterator seen_user = users.find(commit.username);
if(seen_user != users.end()) user = seen_user->second;
- //find files of this commit or create it
- for(std::list<RCommitFile>::iterator it = commit.files.begin(); it != commit.files.end(); it++) {
-
- RCommitFile& cf = *it;
-
- bool filtered_filename = false;
- //check filename against filters
- for(std::vector<Regex*>::iterator ri = gGourceSettings.file_filters.begin(); ri != gGourceSettings.file_filters.end(); ri++) {
+ //check user against filters, if found, discard commit
+ if(user == 0 && !gGourceSettings.user_filters.empty()) {
+ for(std::vector<Regex*>::iterator ri = gGourceSettings.user_filters.begin(); ri != gGourceSettings.user_filters.end(); ri++) {
Regex* r = *ri;
- if(r->match(cf.filename)) {
- filtered_filename = true;
- break;
+ if(r->match(commit.username)) {
+ return;
}
}
+ }
- if(filtered_filename) continue;
-
- std::map<std::string, RFile*>::iterator seen_file;
+ //find files of this commit or create it
+ for(std::list<RCommitFile>::iterator it = commit.files.begin(); it != commit.files.end(); it++) {
- seen_file = files.find(cf.filename);
+ RCommitFile& cf = *it;
RFile* file = 0;
- if(seen_file != files.end()) {
+ std::map<std::string, RFile*>::iterator seen_file = files.find(cf.filename);
+ if(seen_file != files.end()) file = seen_file->second;
- file = seen_file->second;
-
- } else {
+ if(file == 0) {
//if we already have max files in circulation
//we cant add any more
if(files.size() >= gGourceSettings.max_files)
continue;
+ //check filename against filters
+ if(!gGourceSettings.file_filters.empty()) {
+
+ bool filtered_filename = false;
+
+ for(std::vector<Regex*>::iterator ri = gGourceSettings.file_filters.begin(); ri != gGourceSettings.file_filters.end(); ri++) {
+ Regex* r = *ri;
+
+ if(r->match(cf.filename)) {
+ filtered_filename = true;
+ break;
+ }
+ }
+
+ if(filtered_filename) continue;
+
+ }
+
int tagid = tag_seq++;
file = new RFile(cf.filename, cf.colour, vec2f(0.0,0.0), tagid);
View
@@ -41,7 +41,6 @@ void GourceSettings::help(bool extended_help) {
printf(" -p, --start-position POSITION Begin at some position (0.0-1.0 or 'random')\n");
printf(" --stop-position POSITION Stop at some position\n");
printf(" -t, --stop-at-time SECONDS Stop after a specified number of seconds\n");
- printf(" --stop-on-idle Stop on break in activity\n");
printf(" --stop-at-end Stop at end of the log\n");
printf(" --dont-stop Keep running after the end of the log\n");
printf(" --loop Loop at the end of the log\n\n");
@@ -58,7 +57,6 @@ void GourceSettings::help(bool extended_help) {
printf(" --colour-images Colourize user images\n\n");
printf(" -i, --file-idle-time SECONDS Time files remain idle (default: 60)\n");
- printf(" --file-filter REGEX Ignore files matching this regexe\n");
printf(" --file-extensions Show filename extensions only\n\n");
printf(" --max-files NUMBER Max number of active files (default: 1000)\n");
@@ -68,11 +66,6 @@ void GourceSettings::help(bool extended_help) {
printf(" --log-format VCS Specify format of the log (git,cvs,hg,bzr,custom)\n");
printf(" --git-branch Get the git log of a particular branch\n\n");
- printf(" --follow-user USER Camera will automatically follow this user\n");
- printf(" --highlight-user USER Highlight the names of a particular user\n");
- printf(" --highlight-users Highlight the names of all users\n\n");
- printf(" --highlight-dirs Highlight the names of all directories\n\n");
-
printf(" --load-config CONF_FILE Load a config file\n");
printf(" --save-config CONF_FILE Save a config file with the current options\n\n");
@@ -108,15 +101,24 @@ if(extended_help) {
printf(" --transparent Make the background transparent\n\n");
+ printf(" --user-filter REGEX Ignore usernames matching this regex\n");
+ printf(" --file-filter REGEX Ignore files matching this regex\n\n");
+
printf(" --user-friction SECONDS Time users come to a complete hault (default: 0.67)\n");
printf(" --user-scale SCALE Change scale of users (default: 1.0)\n");
printf(" --max-user-speed UNITS Speed users can travel per second (default: 500)\n\n");
+ printf(" --follow-user USER Camera will automatically follow this user\n");
+ printf(" --highlight-user USER Highlight the names of a particular user\n");
+ printf(" --highlight-users Highlight the names of all users\n\n");
+ printf(" --highlight-dirs Highlight the names of all directories\n\n");
+
printf(" --path PATH\n\n");
}
- printf("PATH may be a Git, Bazaar or Mercurial dir, a log file or '-' to read STDIN.\n");
- printf("If ommited, gource will attempt to generate a log from the current directory.\n\n");
+ printf("PATH may be a supported version control directory, a log file, a gource config\n");
+ printf("file, or '-' to read STDIN. If ommited, gource will attempt to generate a log\n");
+ printf("from the current directory.\n\n");
if(!extended_help) {
printf("To see the full command line options use '-H'\n\n");
@@ -207,6 +209,7 @@ GourceSettings::GourceSettings() {
arg_types["max-files"] = "int";
arg_types["font-size"] = "int";
+ arg_types["user-filter"] = "multi-value";
arg_types["file-filter"] = "multi-value";
arg_types["follow-user"] = "multi-value";
arg_types["highlight-user"] = "multi-value";
@@ -317,6 +320,12 @@ void GourceSettings::setGourceDefaults() {
}
file_filters.clear();
file_extensions = false;
+
+ //delete user filters
+ for(std::vector<Regex*>::iterator it = user_filters.begin(); it != user_filters.end(); it++) {
+ delete (*it);
+ }
+ user_filters.clear();
}
void GourceSettings::commandLineOption(const std::string& name, const std::string& value) {
@@ -924,13 +933,38 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
if(!r->isValid()) {
delete r;
- conffile.entryException(entry, "invalid filt-filter regular expression");
+ conffile.entryException(entry, "invalid file-filter regular expression");
}
file_filters.push_back(r);
}
}
+ if((entry = gource_settings->getEntry("user-filter")) != 0) {
+
+ ConfEntryList* filters = gource_settings->getEntries("user-filter");
+
+ for(ConfEntryList::iterator it = filters->begin(); it != filters->end(); it++) {
+
+ entry = *it;
+
+ if(!entry->hasValue()) conffile.entryException(entry, "specify user-filter (regex)");
+
+ std::string filter_string = entry->getString();
+
+ Regex* r = new Regex(filter_string, 1);
+
+ if(!r->isValid()) {
+ delete r;
+ conffile.entryException(entry, "invalid user-filter regular expression");
+ }
+
+ user_filters.push_back(r);
+ }
+ }
+
+
+
//validate path
if(gource_settings->hasValue("path")) {
View
@@ -111,6 +111,7 @@ class GourceSettings : public SDLAppSettings {
std::vector<std::string> highlight_users;
std::vector<std::string> follow_users;
std::vector<Regex*> file_filters;
+ std::vector<Regex*> user_filters;
bool file_extensions;
GourceSettings();

0 comments on commit ce07573

Please sign in to comment.