Skip to content

Commit a7f94bf

Browse files
committed
follow-up fixes for Mercurial renamed files handling
fixes #666
1 parent 0b8c5fb commit a7f94bf

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/org/opensolaris/opengrok/history/FileHistoryCache.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public void store(History history, Repository repository)
253253
String repodir = env.getPathRelativeToSourceRoot(
254254
new File(repository.getDirectoryName()), 0);
255255
String shortestfile = fullfile.substring(repodir.length() + 1);
256-
if (history.isIgnored(shortestfile)) {
256+
if (history.isRenamed(shortestfile)) {
257257
hist = repository.getHistory(test);
258258
}
259259
} catch (IOException ex) {

src/org/opensolaris/opengrok/history/History.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ public class History {
3333
/** Entries in the log. The first entry is the most recent one. */
3434
private List<HistoryEntry> entries;
3535
/**
36-
* files to ignore during cache creation.
36+
* track renamed files so they can be treated in special way (for some
37+
* SCMs) during cache creation.
3738
* These are relative to repository root.
3839
*/
39-
private List<String> ignoredFiles = new ArrayList<String>();
40+
private List<String> renamedFiles = new ArrayList<String>();
4041

4142
public History() {
4243
this(new ArrayList<HistoryEntry>());
@@ -46,9 +47,9 @@ public History() {
4647
this.entries = entries;
4748
}
4849

49-
History(List<HistoryEntry> entries, List<String> ignored) {
50+
History(List<HistoryEntry> entries, List<String> renamed) {
5051
this.entries = entries;
51-
this.ignoredFiles = ignored;
52+
this.renamedFiles = renamed;
5253
}
5354

5455
/**
@@ -101,11 +102,11 @@ public boolean hasTags() {
101102
return false;
102103
}
103104

104-
public boolean isIgnored(String file) {
105-
return ignoredFiles.contains(file);
105+
public boolean isRenamed(String file) {
106+
return renamedFiles.contains(file);
106107
}
107108

108-
public List<String> getIgnoredFiles() {
109-
return ignoredFiles;
109+
public List<String> getRenamedFiles() {
110+
return renamedFiles;
110111
}
111112
}

src/org/opensolaris/opengrok/history/JDBCHistoryCache.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ private void storeHistory(ConnectionResource conn, History history,
744744
addDirchange.setInt(1, changesetId);
745745
addFilechange.setInt(1, changesetId);
746746
for (String file : entry.getFiles()) {
747-
// ignore ignored files
747+
// ignore non-existent files
748748
String repodir = "";
749749
try {
750750
repodir = env.getPathRelativeToSourceRoot(
@@ -753,10 +753,11 @@ private void storeHistory(ConnectionResource conn, History history,
753753
Logger.getLogger(
754754
JDBCHistoryCache.class.getName()).log(
755755
Level.SEVERE, null, ex);
756+
continue;
756757
}
757758

758759
String fullPath = toUnixPath(file);
759-
if (!history.isIgnored(
760+
if (!history.isRenamed(
760761
file.substring(repodir.length() + 1))) {
761762
int fileId = files.get(fullPath);
762763
addFilechange.setInt(2, fileId);
@@ -792,7 +793,7 @@ private void storeHistory(ConnectionResource conn, History history,
792793
* have been renamed in Mercurial repository.
793794
* This ensures that their complete history (follow) will be saved.
794795
*/
795-
for (String filename: history.getIgnoredFiles()) {
796+
for (String filename: history.getRenamedFiles()) {
796797
String file_path = repository.getDirectoryName() +
797798
File.separatorChar + filename;
798799
File file = new File(file_path);

src/org/opensolaris/opengrok/history/MercurialHistoryParser.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class MercurialHistoryParser implements Executor.StreamHandler {
5151
private final MercurialRepository repository;
5252
private final String mydir;
5353
private boolean isDir;
54-
private final List<String> ignoredFiles = new ArrayList<String>();
54+
private final List<String> renamedFiles = new ArrayList<String>();
5555

5656
MercurialHistoryParser(MercurialRepository repository) {
5757
this.repository = repository;
@@ -93,7 +93,7 @@ History parse(File file, String changeset) throws HistoryException {
9393
repository.removeAndVerifyOldestChangeset(entries, changeset);
9494
}
9595

96-
return new History(entries, ignoredFiles);
96+
return new History(entries, renamedFiles);
9797
}
9898

9999
/**
@@ -156,7 +156,7 @@ public void processStream(InputStream input) throws IOException {
156156
String[] move = part.split(" \\(");
157157
File f = new File(mydir + move[0]);
158158
if (!move[0].isEmpty() && f.exists()) {
159-
ignoredFiles.add(move[0]);
159+
renamedFiles.add(move[0]);
160160
}
161161
}
162162

0 commit comments

Comments
 (0)