Skip to content
Browse files

Don't add files that match the path of a known directory.

This issue occurs with SVN logs of old repositories that do not
indicate the 'kind' of the path is a directory.
  • Loading branch information...
1 parent f60a7f4 commit 8fb3fe7eb5a0d2003d121e04cf26a230b8dbbb9c @acaudwell committed
Showing with 29 additions and 6 deletions.
  1. +1 −0 ChangeLog
  2. +15 −1 src/dirnode.cpp
  3. +1 −0 src/dirnode.h
  4. +12 −5 src/gource.cpp
View
1 ChangeLog
@@ -1,5 +1,6 @@
0.38:
* Use AM_CPPFLAGS in Makefile.am to allow passing custom CPPFLAGS.
+ * Don't add files that match the path of a known directory.
0.37:
* Made SVN log GMT timestamp conversion fix portable.
View
16 src/dirnode.cpp
@@ -147,6 +147,19 @@ RDirNode* RDirNode::getParent() const{
}
+bool RDirNode::isDir(const std::string& path) const {
+
+ if(prefixedBy(path)) return true;
+
+ if(path.find(abspath) != 0) return false;
+
+ for(std::list<RDirNode*>::const_iterator it = children.begin(); it != children.end(); it++) {
+ if((*it)->isDir(path)) return true;
+ }
+
+ return false;
+}
+
//finds directories closest to the root directory prefixed by path (eg foo/ may match just foo/ or could also match foo/bar1, foo/bar2, ... if foo/ doesn't exist).
void RDirNode::findDirs(const std::string& path, std::list<RDirNode*>& dirs) {
@@ -402,9 +415,10 @@ bool RDirNode::addFile(RFile* f) {
//do we have a file in this directory thats fullpath is a prefix of this file, if so
//that file is actually a directory - the file should be removed, and a directory with that path added
//if this is the root node we do this regardless of if the file was added to a child node
+
for(std::list<RFile*>::const_iterator it = files.begin(); it != files.end(); it++) {
RFile* file = (*it);
-
+
if(f->path.find(file->fullpath) == 0) {
//fprintf(stderr, "removing %s as is actually the directory of %s\n", file->fullpath.c_str(), f->fullpath.c_str());
file->remove(true);
View
1 src/dirnode.h
@@ -159,6 +159,7 @@ class RDirNode : public QuadItem {
RDirNode* getParent() const;
+ bool isDir(const std::string& path) const;
void findDirs(const std::string& path, std::list<RDirNode*>& dirs);
const vec2f & getPos() const;
View
17 src/gource.cpp
@@ -980,6 +980,16 @@ void Gource::deleteFile(RFile* file) {
RFile* Gource::addFile(const RCommitFile& cf) {
+ //if we already have max files in circulation
+ //we cant add any more
+ if(gGourceSettings.max_files > 0 && files.size() >= gGourceSettings.max_files) return 0;
+
+ //see if this is a directory
+ std::string file_as_dir = cf.filename;
+ if(file_as_dir[file_as_dir.size()-1] != '/') file_as_dir.append("/");
+
+ if(root->isDir(file_as_dir)) return 0;
+
int tagid = tag_seq++;
RFile* file = new RFile(cf.filename, cf.colour, vec2f(0.0,0.0), tagid);
@@ -1178,12 +1188,9 @@ void Gource::processCommit(RCommit& commit, float t) {
if(file == 0) {
- //if we already have max files in circulation
- //we cant add any more
- if(gGourceSettings.max_files > 0 && files.size() >= gGourceSettings.max_files)
- continue;
-
file = addFile(cf);
+
+ if(!file) continue;
}
addFileAction(commit.username, cf.action, file, t);

0 comments on commit 8fb3fe7

Please sign in to comment.
Something went wrong with that request. Please try again.