Skip to content

Commit c701ef8

Browse files
committed
no need to strip the second part of the revision string
also fix style
1 parent 649f481 commit c701ef8

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/MercurialRepository.java

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -280,24 +280,18 @@ Executor getHistoryLogExecutor(File file, String sinceRevision, String tillRevis
280280
* Try to get file contents for given revision.
281281
*
282282
* @param sink a required target sink
283-
* @param fullpath full pathname of the file
284-
* @param rev revision
283+
* @param fullPath full pathname of the file
284+
* @param revision revision
285285
* @return a defined instance with {@code success} == {@code true} if no
286286
* error occurred and with non-zero {@code iterations} if some data was
287287
* transferred
288288
*/
289-
private HistoryRevResult getHistoryRev(BufferSink sink, String fullpath, String rev) {
290-
289+
private HistoryRevResult getHistoryRev(BufferSink sink, String fullPath, String revision) {
291290
HistoryRevResult result = new HistoryRevResult();
292291
File directory = new File(getDirectoryName());
293292

294-
String revision = rev;
295-
if (rev.indexOf(':') != -1) {
296-
revision = rev.substring(0, rev.indexOf(':'));
297-
}
298-
299293
try {
300-
String filename = fullpath.substring(getDirectoryName().length() + 1);
294+
String filename = fullPath.substring(getDirectoryName().length() + 1);
301295
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
302296
String[] argv = {RepoCommand, "cat", "-r", revision, filename};
303297
Executor executor = new Executor(Arrays.asList(argv), directory,
@@ -307,7 +301,7 @@ private HistoryRevResult getHistoryRev(BufferSink sink, String fullpath, String
307301

308302
/*
309303
* If exit value of the process was not 0 then the file did
310-
* not exist or internal hg error occured.
304+
* not exist or internal hg error occurred.
311305
*/
312306
result.success = (status == 0);
313307
} catch (Exception exp) {
@@ -321,13 +315,13 @@ private HistoryRevResult getHistoryRev(BufferSink sink, String fullpath, String
321315
* Get the name of file in given revision. This is used to get contents
322316
* of a file in historical revision.
323317
*
324-
* @param fullpath file path
318+
* @param fullPath file path
325319
* @param fullRevToFind revision number (in the form of <code>{rev}:{node|short}</code>)
326320
* @return original filename
327321
*/
328-
private String findOriginalName(String fullpath, String fullRevToFind) throws IOException {
322+
private String findOriginalName(String fullPath, String fullRevToFind) throws IOException {
329323
Matcher matcher = LOG_COPIES_PATTERN.matcher("");
330-
String file = fullpath.substring(getDirectoryName().length() + 1);
324+
String file = fullPath.substring(getDirectoryName().length() + 1);
331325
ArrayList<String> argv = new ArrayList<>();
332326
File directory = new File(getDirectoryName());
333327

@@ -359,7 +353,7 @@ private String findOriginalName(String fullpath, String fullRevToFind) throws IO
359353
// argv.add("reverse(" + rev_to_find + ":)");
360354
argv.add("--template");
361355
argv.add("{rev}:{file_copies}\\n");
362-
argv.add(fullpath);
356+
argv.add(fullPath);
363357

364358
Executor executor = new Executor(argv, directory,
365359
RuntimeEnvironment.getInstance().getInteractiveCommandTimeout());
@@ -405,26 +399,25 @@ private String findOriginalName(String fullpath, String fullRevToFind) throws IO
405399
if (status != 0) {
406400
LOGGER.log(Level.WARNING,
407401
"Failed to get original name in revision {2} for: \"{0}\" Exit code: {1}",
408-
new Object[]{fullpath, String.valueOf(status), fullRevToFind});
402+
new Object[]{fullPath, String.valueOf(status), fullRevToFind});
409403
return null;
410404
}
411405

412-
return (fullpath.substring(0, getDirectoryName().length() + 1) + file);
406+
return (fullPath.substring(0, getDirectoryName().length() + 1) + file);
413407
}
414408

415409
@Override
416410
boolean getHistoryGet(OutputStream out, String parent, String basename, String rev) {
417-
418-
String fullpath;
411+
String fullPath;
419412
try {
420-
fullpath = new File(parent, basename).getCanonicalPath();
413+
fullPath = new File(parent, basename).getCanonicalPath();
421414
} catch (IOException exp) {
422415
LOGGER.log(Level.SEVERE,
423416
"Failed to get canonical path: {0}", exp.getClass().toString());
424417
return false;
425418
}
426419

427-
HistoryRevResult result = getHistoryRev(out::write, fullpath, rev);
420+
HistoryRevResult result = getHistoryRev(out::write, fullPath, rev);
428421
if (!result.success && result.iterations < 1) {
429422
/*
430423
* If we failed to get the contents it might be that the file was
@@ -433,14 +426,14 @@ boolean getHistoryGet(OutputStream out, String parent, String basename, String r
433426
*/
434427
String origpath;
435428
try {
436-
origpath = findOriginalName(fullpath, rev);
429+
origpath = findOriginalName(fullPath, rev);
437430
} catch (IOException exp) {
438431
LOGGER.log(Level.SEVERE,
439432
"Failed to get original revision: {0}",
440433
exp.getClass().toString());
441434
return false;
442435
}
443-
if (origpath != null && !origpath.equals(fullpath)) {
436+
if (origpath != null && !origpath.equals(fullPath)) {
444437
result = getHistoryRev(out::write, origpath, rev);
445438
}
446439
}

0 commit comments

Comments
 (0)