Skip to content

Commit c185897

Browse files
author
Vladimir Kotal
authored
directory name of RepositoryInfo should be stored as relative path (#1758)
fixes #1754
1 parent f2e843d commit c185897

13 files changed

+190
-151
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ Executor getHistoryLogExecutor(final File file, final String sinceRevision)
8282
throws IOException {
8383
String abs = file.getCanonicalPath();
8484
String filename = "";
85-
if (abs.length() > directoryName.length()) {
86-
filename = abs.substring(directoryName.length() + 1);
85+
if (abs.length() > getDirectoryName().length()) {
86+
filename = abs.substring(getDirectoryName().length() + 1);
8787
}
8888

8989
List<String> cmd = new ArrayList<String>();
@@ -108,12 +108,12 @@ Executor getHistoryLogExecutor(final File file, final String sinceRevision)
108108
public InputStream getHistoryGet(String parent, String basename, String rev) {
109109
InputStream ret = null;
110110

111-
File directory = new File(directoryName);
111+
File directory = new File(getDirectoryName());
112112

113113
Process process = null;
114114
try {
115115
String filename = (new File(parent, basename)).getCanonicalPath()
116-
.substring(directoryName.length() + 1);
116+
.substring(getDirectoryName().length() + 1);
117117
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
118118
String argv[] = {RepoCommand, "cat", "-r", rev, filename};
119119
process = Runtime.getRuntime().exec(argv, null, directory);
@@ -354,7 +354,7 @@ protected void buildTagList(File directory) {
354354

355355
@Override
356356
String determineParent() throws IOException {
357-
File directory = new File(directoryName);
357+
File directory = new File(getDirectoryName());
358358

359359
List<String> cmd = new ArrayList<>();
360360
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ String determineBranch() throws IOException {
172172
*/
173173
@Override
174174
String determineParent() throws IOException {
175-
final File directory = new File(directoryName);
175+
final File directory = new File(getDirectoryName());
176176

177177
final ArrayList<String> argv = new ArrayList<String>();
178178
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ String determineBranch() throws IOException {
197197
Executor getHistoryLogExecutor(final File file) throws IOException {
198198
String abs = file.getCanonicalPath();
199199
String filename = "";
200-
if (abs.length() > directoryName.length()) {
201-
filename = abs.substring(directoryName.length() + 1);
200+
if (abs.length() > getDirectoryName().length()) {
201+
filename = abs.substring(getDirectoryName().length() + 1);
202202
}
203203

204204
List<String> cmd = new ArrayList<>();
@@ -347,7 +347,7 @@ protected Annotation parseAnnotation(Reader input, String fileName)
347347

348348
@Override
349349
String determineParent() throws IOException {
350-
File rootFile = new File(directoryName + File.separator + "CVS"
350+
File rootFile = new File(getDirectoryName() + File.separator + "CVS"
351351
+ File.separator + "Root");
352352
String parent = null;
353353

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public void setVerbose(boolean verbose) {
9595
Executor getHistoryLogExecutor(final File file) throws IOException {
9696
String abs = file.getCanonicalPath();
9797
String filename = "";
98-
if (abs.length() > directoryName.length()) {
99-
filename = abs.substring(directoryName.length() + 1);
98+
if (abs.length() > getDirectoryName().length()) {
99+
filename = abs.substring(getDirectoryName().length() + 1);
100100
}
101101

102102
List<String> cmd = new ArrayList<>();
@@ -117,12 +117,12 @@ Executor getHistoryLogExecutor(final File file) throws IOException {
117117
public InputStream getHistoryGet(String parent, String basename, String rev) {
118118
InputStream ret = null;
119119

120-
File directory = new File(directoryName);
120+
File directory = new File(getDirectoryName());
121121

122122
Process process = null;
123123
try {
124124
String filename = (new File(parent, basename)).getCanonicalPath()
125-
.substring(directoryName.length() + 1);
125+
.substring(getDirectoryName().length() + 1);
126126
final File tmp = File.createTempFile("opengrok", "tmp");
127127
String tmpName = tmp.getCanonicalPath();
128128

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ Executor getHistoryLogExecutor(final File file, String sinceRevision)
118118

119119
String abs = file.getCanonicalPath();
120120
String filename = "";
121-
if (abs.length() > directoryName.length()) {
122-
filename = abs.substring(directoryName.length() + 1);
121+
if (abs.length() > getDirectoryName().length()) {
122+
filename = abs.substring(getDirectoryName().length() + 1);
123123
}
124124

125125
List<String> cmd = new ArrayList<>();
@@ -167,10 +167,10 @@ Executor getRenamedFilesExecutor(final File file, String sinceRevision) throws I
167167
cmd.add(sinceRevision + "..");
168168
}
169169

170-
if (file.getCanonicalPath().length() > directoryName.length() + 1) {
170+
if (file.getCanonicalPath().length() > getDirectoryName().length() + 1) {
171171
// this is a file in the repository
172172
cmd.add("--");
173-
cmd.add(file.getCanonicalPath().substring(directoryName.length() + 1));
173+
cmd.add(file.getCanonicalPath().substring(getDirectoryName().length() + 1));
174174
}
175175

176176
return new Executor(cmd, new File(getDirectoryName()), sinceRevision != null);
@@ -201,11 +201,11 @@ Reader newLogReader(InputStream input) throws IOException {
201201
*/
202202
private InputStream getHistoryRev(String fullpath, String rev) {
203203
InputStream ret = null;
204-
File directory = new File(directoryName);
204+
File directory = new File(getDirectoryName());
205205
Process process = null;
206206

207207
try {
208-
String filename = fullpath.substring(directoryName.length() + 1);
208+
String filename = fullpath.substring(getDirectoryName().length() + 1);
209209
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
210210
String argv[] = {
211211
RepoCommand,
@@ -303,15 +303,15 @@ public String get() {
303303
*/
304304
protected String findOriginalName(String fullpath, String changeset)
305305
throws IOException {
306-
if (fullpath == null || fullpath.isEmpty() || fullpath.length() < directoryName.length()) {
306+
if (fullpath == null || fullpath.isEmpty() || fullpath.length() < getDirectoryName().length()) {
307307
throw new IOException(String.format("Invalid file path string: %s", fullpath));
308308
}
309309

310310
if (changeset == null || changeset.isEmpty()) {
311311
throw new IOException(String.format("Invalid changeset string for path %s: %s", fullpath, changeset));
312312
}
313313

314-
String file = fullpath.replace(directoryName + File.separator, "");
314+
String file = fullpath.replace(getDirectoryName() + File.separator, "");
315315
/*
316316
* Get the list of file renames for given file to the specified
317317
* revision.
@@ -330,7 +330,7 @@ protected String findOriginalName(String fullpath, String changeset)
330330
};
331331

332332
ProcessBuilder pb = new ProcessBuilder(argv);
333-
Process process = Runtime.getRuntime().exec(argv, null, new File(directoryName));
333+
Process process = Runtime.getRuntime().exec(argv, null, new File(getDirectoryName()));
334334

335335
try {
336336
try (BufferedReader in = new BufferedReader(
@@ -365,7 +365,7 @@ protected String findOriginalName(String fullpath, String changeset)
365365
}
366366
}
367367

368-
return (fullpath.substring(0, directoryName.length() + 1) + file);
368+
return (fullpath.substring(0, getDirectoryName().length() + 1) + file);
369369
}
370370

371371
/**
@@ -405,7 +405,7 @@ public Annotation annotate(File file, String revision) throws IOException {
405405
}
406406
cmd.add("--");
407407
cmd.add(findOriginalName(file.getAbsolutePath(), revision));
408-
File directory = new File(directoryName);
408+
File directory = new File(getDirectoryName());
409409
exec = new Executor(cmd, directory);
410410
status = exec.exec();
411411
}
@@ -648,7 +648,7 @@ protected void buildTagList(File directory) {
648648
@Override
649649
String determineParent() throws IOException {
650650
String parent = null;
651-
File directory = new File(directoryName);
651+
File directory = new File(getDirectoryName());
652652

653653
List<String> cmd = new ArrayList<>();
654654
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
@@ -667,7 +667,7 @@ String determineParent() throws IOException {
667667
String parts[] = line.split("\\s+");
668668
if (parts.length != 3) {
669669
LOGGER.log(Level.WARNING,
670-
"Failed to get parent for {0}", directoryName);
670+
"Failed to get parent for {0}", getDirectoryName());
671671
}
672672
parent = parts[1];
673673
break;
@@ -681,7 +681,7 @@ String determineParent() throws IOException {
681681
@Override
682682
String determineBranch() throws IOException {
683683
String branch = null;
684-
File directory = new File(directoryName);
684+
File directory = new File(getDirectoryName());
685685

686686
List<String> cmd = new ArrayList<>();
687687
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
@@ -707,7 +707,7 @@ String determineBranch() throws IOException {
707707

708708
@Override
709709
public String determineCurrentVersion() throws IOException {
710-
File directory = new File(directoryName);
710+
File directory = new File(getDirectoryName());
711711
List<String> cmd = new ArrayList<>();
712712
// The delimiter must not be contained in the date format emitted by
713713
// {@code GIT_DATE_OPT}.

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ String determineBranch() throws IOException {
132132
cmd.add(RepoCommand);
133133
cmd.add("branch");
134134

135-
Executor executor = new Executor(cmd, new File(directoryName));
135+
Executor executor = new Executor(cmd, new File(getDirectoryName()));
136136
if (executor.exec(false) != 0) {
137137
throw new IOException(executor.getErrorString());
138138
}
@@ -156,8 +156,8 @@ Executor getHistoryLogExecutor(File file, String sinceRevision)
156156
String filename = "";
157157
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
158158

159-
if (abs.length() > directoryName.length()) {
160-
filename = abs.substring(directoryName.length() + 1);
159+
if (abs.length() > getDirectoryName().length()) {
160+
filename = abs.substring(getDirectoryName().length() + 1);
161161
}
162162

163163
List<String> cmd = new ArrayList<>();
@@ -206,7 +206,7 @@ Executor getHistoryLogExecutor(File file, String sinceRevision)
206206
cmd.add(filename);
207207
}
208208

209-
return new Executor(cmd, new File(directoryName), sinceRevision != null);
209+
return new Executor(cmd, new File(getDirectoryName()), sinceRevision != null);
210210
}
211211

212212
/**
@@ -219,7 +219,7 @@ Executor getHistoryLogExecutor(File file, String sinceRevision)
219219
private InputStream getHistoryRev(String fullpath, String rev) {
220220
InputStream ret = null;
221221

222-
File directory = new File(directoryName);
222+
File directory = new File(getDirectoryName());
223223

224224
Process process = null;
225225
String revision = rev;
@@ -229,7 +229,7 @@ private InputStream getHistoryRev(String fullpath, String rev) {
229229
}
230230
try {
231231
String filename
232-
= fullpath.substring(directoryName.length() + 1);
232+
= fullpath.substring(getDirectoryName().length() + 1);
233233
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
234234
String argv[] = {RepoCommand, "cat", "-r", revision, filename};
235235
process = Runtime.getRuntime().exec(argv, null, directory);
@@ -284,7 +284,7 @@ private InputStream getHistoryRev(String fullpath, String rev) {
284284
private String findOriginalName(String fullpath, String full_rev_to_find)
285285
throws IOException {
286286
Matcher matcher = LOG_COPIES_PATTERN.matcher("");
287-
String file = fullpath.substring(directoryName.length() + 1);
287+
String file = fullpath.substring(getDirectoryName().length() + 1);
288288
ArrayList<String> argv = new ArrayList<>();
289289

290290
// Extract {rev} from the full revision specification string.
@@ -375,7 +375,7 @@ private String findOriginalName(String fullpath, String full_rev_to_find)
375375
}
376376
}
377377

378-
return (fullpath.substring(0, directoryName.length() + 1) + file);
378+
return (fullpath.substring(0, getDirectoryName().length() + 1) + file);
379379
}
380380

381381
@Override
@@ -514,7 +514,7 @@ public boolean fileHasAnnotation(File file) {
514514

515515
@Override
516516
public void update() throws IOException {
517-
File directory = new File(directoryName);
517+
File directory = new File(getDirectoryName());
518518

519519
List<String> cmd = new ArrayList<>();
520520
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
@@ -686,7 +686,7 @@ protected void buildTagList(File directory) {
686686

687687
@Override
688688
String determineParent() throws IOException {
689-
File directory = new File(directoryName);
689+
File directory = new File(getDirectoryName());
690690

691691
List<String> cmd = new ArrayList<>();
692692
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
@@ -704,7 +704,7 @@ String determineParent() throws IOException {
704704
@Override
705705
public String determineCurrentVersion() throws IOException {
706706
String line = null;
707-
File directory = new File(directoryName);
707+
File directory = new File(getDirectoryName());
708708

709709
List<String> cmd = new ArrayList<>();
710710
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ public MonotoneRepository() {
7070
public InputStream getHistoryGet(String parent, String basename, String rev) {
7171
InputStream ret = null;
7272

73-
File directory = new File(directoryName);
73+
File directory = new File(getDirectoryName());
7474

7575
Process process = null;
7676
String revision = rev;
7777

7878
try {
7979
String filename = (new File(parent, basename)).getCanonicalPath()
80-
.substring(directoryName.length() + 1);
80+
.substring(getDirectoryName().length() + 1);
8181
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
8282
String argv[] = {RepoCommand, "cat", "-r", revision, filename};
8383
process = Runtime.getRuntime().exec(argv, null, directory);
@@ -126,8 +126,8 @@ Executor getHistoryLogExecutor(File file, String sinceRevision)
126126
throws IOException {
127127
String abs = file.getCanonicalPath();
128128
String filename = "";
129-
if (abs.length() > directoryName.length()) {
130-
filename = abs.substring(directoryName.length() + 1);
129+
if (abs.length() > getDirectoryName().length()) {
130+
filename = abs.substring(getDirectoryName().length() + 1);
131131
}
132132

133133
List<String> cmd = new ArrayList<>();
@@ -145,7 +145,7 @@ Executor getHistoryLogExecutor(File file, String sinceRevision)
145145
cmd.add("--no-format-dates");
146146
cmd.add(filename);
147147

148-
return new Executor(cmd, new File(directoryName), sinceRevision != null);
148+
return new Executor(cmd, new File(getDirectoryName()), sinceRevision != null);
149149
}
150150
/**
151151
* Pattern used to extract author/revision from hg annotate.
@@ -173,7 +173,7 @@ public Annotation annotate(File file, String revision) throws IOException {
173173
cmd.add(revision);
174174
}
175175
cmd.add(file.getName());
176-
File directory = new File(directoryName);
176+
File directory = new File(getDirectoryName());
177177

178178
Executor executor = new Executor(cmd, directory);
179179
if (executor.exec() != 0) {
@@ -207,7 +207,7 @@ public boolean fileHasAnnotation(File file) {
207207

208208
@Override
209209
public void update() throws IOException {
210-
File directory = new File(directoryName);
210+
File directory = new File(getDirectoryName());
211211
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
212212

213213
List<String> cmd = new ArrayList<>();
@@ -283,7 +283,7 @@ private boolean useDeprecated() {
283283
@Override
284284
String determineParent() throws IOException {
285285
String parent = null;
286-
File directory = new File(directoryName);
286+
File directory = new File(getDirectoryName());
287287

288288
List<String> cmd = new ArrayList<>();
289289
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
@@ -303,7 +303,7 @@ String determineParent() throws IOException {
303303
String parts[] = line.split("\\s+");
304304
if (parts.length != 3) {
305305
LOGGER.log(Level.WARNING,
306-
"Failed to get parent for {0}", directoryName);
306+
"Failed to get parent for {0}", getDirectoryName());
307307
}
308308
parent = parts[2];
309309
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ final void createCache(HistoryCache cache, String sinceRevision)
344344
// We need to refresh list of tags for incremental reindex.
345345
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
346346
if (env.isTagsEnabled() && this.hasFileBasedTags()) {
347-
this.buildTagList(new File(this.directoryName));
347+
this.buildTagList(new File(this.getDirectoryName()));
348348
}
349349

350350
if (history != null) {

0 commit comments

Comments
 (0)