@@ -72,8 +72,6 @@ public final class HistoryGuru {
72
72
private Map <String , Repository > repositories = new ConcurrentHashMap <>();
73
73
74
74
private final int scanningDepth ;
75
-
76
- private String ignoreRepositoryName = ".opengrok_skip_history" ;
77
75
78
76
/**
79
77
* Creates a new instance of HistoryGuru, and try to set the default source
@@ -344,65 +342,43 @@ private void addRepositories(File[] files, Collection<RepositoryInfo> repos,
344
342
private void addRepositories (File [] files , Collection <RepositoryInfo > repos ,
345
343
IgnoredNames ignoredNames , boolean recursiveSearch , int depth ) {
346
344
347
- // This check for ignoring a repository only works for embedded
348
- // source code control directories used by SCCS and the like.
349
345
for (File file : files ) {
350
- if (file .getName ().equals (ignoreRepositoryName )) {
351
- LOGGER .log (Level .INFO ,
352
- "Skipping history cache creation for {0} and its subdirectories" ,
353
- file .getParentFile ().getAbsolutePath ());
354
- return ;
355
- }
356
- }
357
- for (File file : files ) {
358
- Boolean ignoreRepository = false ;
359
- try {
360
- // This check for ignoring a repository is for the
361
- // kind of repository, such as AccuRev, where the
362
- // entire project folder layout (workspace) is
363
- // considered as the repository. Here we need to
364
- // look inside the folder for the magic file.
365
- if ( file .isDirectory () ) {
366
- String path = file .getCanonicalPath ();
367
- File skipRepository = new File (path , ignoreRepositoryName );
368
- ignoreRepository = skipRepository .exists ();
369
- }
370
- } catch ( IOException exp ) {
371
- LOGGER .log (Level .WARNING ,
372
- "Failed to get canonical path for {0}: {1}" ,
373
- new Object []{file .getAbsolutePath (), exp .getMessage ()});
374
- }
375
-
376
- if ( ignoreRepository ) {
377
- LOGGER .log (Level .INFO ,
378
- "Skipping history cache creation for {0} and its subdirectories" ,
379
- file .getAbsolutePath ());
380
- } else {
381
- Repository repository = null ;
346
+ if (file .isDirectory ()) {
347
+ String path ;
382
348
try {
383
- repository = RepositoryFactory .getRepository (file );
384
- } catch (InstantiationException ie ) {
385
- LOGGER .log (Level .WARNING , "Could not create repository for '"
386
- + file + "', could not instantiate the repository." , ie );
387
- } catch (IllegalAccessException iae ) {
388
- LOGGER .log (Level .WARNING , "Could not create repository for '"
389
- + file + "', missing access rights." , iae );
390
- }
391
- if (repository == null ) {
392
- // Not a repository, search its sub-dirs
393
- if (file .isDirectory () && !ignoredNames .ignore (file )) {
394
- File subFiles [] = file .listFiles ();
395
- if (subFiles == null ) {
396
- LOGGER .log (Level .WARNING ,
397
- "Failed to get sub directories for ''{0}'', check access permissions." ,
398
- file .getAbsolutePath ());
399
- } else if (depth <= scanningDepth ) {
400
- addRepositories (subFiles , repos , ignoredNames , depth + 1 );
401
- }
349
+ path = file .getCanonicalPath ();
350
+ File skipRepository = new File (path , ".opengrok_skip_history" );
351
+ // Should potential repository be ignored?
352
+ if (skipRepository .exists ()) {
353
+ LOGGER .log (Level .INFO ,
354
+ "Skipping history cache creation for {0} and its subdirectories" ,
355
+ file .getAbsolutePath ());
356
+ continue ;
402
357
}
403
- } else {
358
+
359
+ Repository repository = null ;
404
360
try {
405
- String path = file .getCanonicalPath ();
361
+ repository = RepositoryFactory .getRepository (file );
362
+ } catch (InstantiationException ie ) {
363
+ LOGGER .log (Level .WARNING , "Could not create repository for '"
364
+ + file + "', could not instantiate the repository." , ie );
365
+ } catch (IllegalAccessException iae ) {
366
+ LOGGER .log (Level .WARNING , "Could not create repository for '"
367
+ + file + "', missing access rights." , iae );
368
+ }
369
+ if (repository == null ) {
370
+ // Not a repository, search its sub-dirs
371
+ if (!ignoredNames .ignore (file )) {
372
+ File subFiles [] = file .listFiles ();
373
+ if (subFiles == null ) {
374
+ LOGGER .log (Level .WARNING ,
375
+ "Failed to get sub directories for ''{0}'', check access permissions." ,
376
+ file .getAbsolutePath ());
377
+ } else if (depth <= scanningDepth ) {
378
+ addRepositories (subFiles , repos , ignoredNames , depth + 1 );
379
+ }
380
+ }
381
+ } else {
406
382
repository .setDirectoryName (path );
407
383
if (RuntimeEnvironment .getInstance ().isVerbose ()) {
408
384
LOGGER .log (Level .CONFIG , "Adding <{0}> repository: <{1}>" ,
@@ -425,13 +401,12 @@ private void addRepositories(File[] files, Collection<RepositoryInfo> repos,
425
401
false , depth + 1 );
426
402
}
427
403
}
428
-
429
- } catch (IOException exp ) {
430
- LOGGER .log (Level .WARNING ,
431
- "Failed to get canonical path for {0}: {1}" ,
432
- new Object []{file .getAbsolutePath (), exp .getMessage ()});
433
- LOGGER .log (Level .WARNING , "Repository will be ignored..." , exp );
434
404
}
405
+ } catch (IOException exp ) {
406
+ LOGGER .log (Level .WARNING ,
407
+ "Failed to get canonical path for {0}: {1}" ,
408
+ new Object []{file .getAbsolutePath (), exp .getMessage ()});
409
+ LOGGER .log (Level .WARNING , "Repository will be ignored..." , exp );
435
410
}
436
411
}
437
412
}
0 commit comments