@@ -102,38 +102,32 @@ private void doFileHistory(String filename, List<HistoryEntry> historyEntries,
102
102
Repository repository , File srcFile , File root , boolean renamed )
103
103
throws HistoryException {
104
104
105
- History hist = null ;
105
+ File file = new File (root , filename );
106
+ // Only store directory history for the top-level directory.
107
+ if (file .isDirectory () && !filename .equals (repository .getDirectoryName ())) {
108
+ LOGGER .log (Level .FINE , "Not storing history cache for {0}: not top level directory" , file );
109
+ return ;
110
+ }
106
111
107
112
/*
108
113
* If the file was renamed (in the changesets that are being indexed),
109
114
* its history is not stored in the historyEntries so it needs to be acquired
110
115
* directly from the repository.
111
- * This ensures that complete history of the file (across renames)
112
- * will be saved.
116
+ * This ensures that complete history of the file (across renames) will be saved.
113
117
*/
118
+ History hist ;
114
119
if (renamed ) {
115
120
hist = repository .getHistory (srcFile );
121
+ } else {
122
+ hist = new History (historyEntries );
116
123
}
117
124
118
- File file = new File (root , filename );
119
-
120
- if (hist == null ) {
121
- hist = new History ();
122
-
123
- // File based history cache does not store files for individual
124
- // changesets so strip them unless it is history for the repository.
125
- for (HistoryEntry ent : historyEntries ) {
126
- if (file .isDirectory () && filename .equals (repository .getDirectoryName ())) {
127
- ent .stripTags ();
128
- } else {
129
- ent .strip ();
130
- }
131
- }
132
-
133
- // add all history entries
134
- hist .setHistoryEntries (historyEntries );
135
- } else {
136
- for (HistoryEntry ent : hist .getHistoryEntries ()) {
125
+ // File based history cache does not store files for individual
126
+ // changesets so strip them unless it is history for the repository.
127
+ for (HistoryEntry ent : hist .getHistoryEntries ()) {
128
+ if (file .isDirectory ()) {
129
+ ent .stripTags ();
130
+ } else {
137
131
ent .strip ();
138
132
}
139
133
}
@@ -143,10 +137,7 @@ private void doFileHistory(String filename, List<HistoryEntry> historyEntries,
143
137
repository .assignTagsInHistory (hist );
144
138
}
145
139
146
- // Only store directory history for the top-level.
147
- if (!file .isDirectory () || filename .equals (repository .getDirectoryName ())) {
148
- storeFile (hist , file , repository , !renamed );
149
- }
140
+ storeFile (hist , file , repository , !renamed );
150
141
}
151
142
152
143
private boolean isRenamedFile (String filename , Repository repository , History history )
@@ -462,15 +453,8 @@ public void store(History history, Repository repository)
462
453
list = new ArrayList <>();
463
454
map .put (s , list );
464
455
}
465
- /*
466
- * We need to do deep copy in order to have different tags
467
- * per each commit.
468
- */
469
- if (env .isTagsEnabled () && repository .hasFileBasedTags ()) {
470
- list .add (new HistoryEntry (e ));
471
- } else {
472
- list .add (e );
473
- }
456
+
457
+ list .add (e );
474
458
}
475
459
}
476
460
0 commit comments