Signed-off-by: Tommie Gannert <[email protected]>
---
src/org/opensolaris/opengrok/index/Indexer.java | 51 +++++++++++++++----------
1 file changed, 30 insertions(+), 21 deletions(-)
diff --git a/src/org/opensolaris/opengrok/index/Indexer.java
b/src/org/opensolaris/opengrok/index/Indexer.java
index 7b6688d..c16f5f7 100644
--- a/src/org/opensolaris/opengrok/index/Indexer.java
+++ b/src/org/opensolaris/opengrok/index/Indexer.java
@@ -600,7 +600,6 @@ public final class Indexer {
}
if (addProjects) {
- File files[] = env.getSourceRootFile().listFiles();
List<Project> projects = env.getProjects();
// Keep a copy of the old project list so that we can preserve
@@ -611,26 +610,7 @@ public final class Indexer {
}
projects.clear();
-
- // Add a project for each top-level directory in source root.
- for (File file : files) {
- String name = file.getName();
- String path = "/" + name;
- if (oldProjects.containsKey(path)) {
- // This is an existing object. Reuse the old project,
- // possibly with customizations, instead of creating a
- // new with default values.
- projects.add(oldProjects.get(path));
- } else if (!name.startsWith(".") && file.isDirectory()) {
- // Found a new directory with no matching project, so
- // create a new project with default properties.
- Project p = new Project();
- p.setDescription(name);
- p.setPath(path);
- p.setTabSize(env.getConfiguration().getTabSize());
- projects.add(p);
- }
- }
+ addProjectsRecursively(env.getSourceRootFile(), env,
oldProjects, "", projects);
// The projects should be sorted...
Collections.sort(projects, new Comparator<Project>() {
@@ -684,6 +664,35 @@ public final class Indexer {
}
}
+ private void addProjectsRecursively(File directory,
RuntimeEnvironment env, Map<String, Project> oldProjects, String
prefix, List<Project> projects) {
+ // Add a project for each subdirectory in source root that is also
+ // a repository.
+ for (File file : directory.listFiles()) {
+ String name = (prefix.isEmpty() ? file.getName() :
prefix + "/" + file.getName());
+ String path = "/" + name;
+ if (oldProjects.containsKey(path)) {
+ // This is an existing object. Reuse the old project,
+ // possibly with customizations, instead of creating a
+ // new with default values.
+ projects.add(oldProjects.get(path));
+ } else if (!name.startsWith(".") && file.isDirectory()) {
+ // Check if there is a repository in this
directory. If not,
+ // recurse into it.
+ if (HistoryGuru.getInstance().hasHistory(file)) {
+ // Found a new directory with no matching project, so
+ // create a new project with default properties.
+ Project p = new Project();
+ p.setDescription(name);
+ p.setPath(path);
+ p.setTabSize(env.getConfiguration().getTabSize());
+ projects.add(p);
+ } else {
+ addProjectsRecursively(file, env,
oldProjects, name, projects);
+ }
+ }
+ }
+ }
+
public void doIndexerExecution(final boolean update, int
noThreads, List<String> subFiles,
IndexChangedListener progress)
throws IOException {
--
1.8.0.2
_______________________________________________
opengrok-dev mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opengrok-dev