forked from oracle/opengrok
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
per project renamed file handling (oracle#2134)
- Loading branch information
Vladimir Kotal
authored
May 31, 2018
1 parent
38f7757
commit 0817a68
Showing
11 changed files
with
117 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>. | ||
*/ | ||
|
||
|
@@ -54,6 +54,7 @@ | |
import java.util.logging.Logger; | ||
import java.util.zip.GZIPInputStream; | ||
import java.util.zip.GZIPOutputStream; | ||
import org.opensolaris.opengrok.configuration.Project; | ||
import org.opensolaris.opengrok.configuration.RuntimeEnvironment; | ||
import org.opensolaris.opengrok.logger.LoggerFactory; | ||
import org.opensolaris.opengrok.util.ForbiddenSymlinkException; | ||
|
@@ -406,6 +407,7 @@ private void finishStore(Repository repository, String latestRev) { | |
public void store(History history, Repository repository) | ||
throws HistoryException { | ||
final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); | ||
final boolean handleRenamedFiles = repository.isHandleRenamedFiles(); | ||
|
||
String latestRev = null; | ||
|
||
|
@@ -475,7 +477,7 @@ public void store(History history, Repository repository) | |
int fileHistoryCount = 0; | ||
for (Map.Entry<String, List<HistoryEntry>> map_entry : map.entrySet()) { | ||
try { | ||
if (env.isHandleHistoryOfRenamedFiles() && | ||
if (handleRenamedFiles && | ||
isRenamedFile(map_entry.getKey(), env, repository, history)) { | ||
continue; | ||
} | ||
|
@@ -491,7 +493,7 @@ public void store(History history, Repository repository) | |
|
||
LOGGER.log(Level.FINE, "Stored history for {0} files", fileHistoryCount); | ||
|
||
if (!env.isHandleHistoryOfRenamedFiles()) { | ||
if (!handleRenamedFiles) { | ||
finishStore(repository, latestRev); | ||
return; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opensolaris.opengrok.history; | ||
|
@@ -59,6 +59,12 @@ private enum ParseState { | |
private GitRepository repository = new GitRepository(); | ||
private List<HistoryEntry> entries = new ArrayList<>(); | ||
|
||
private final boolean handleRenamedFiles; | ||
|
||
GitHistoryParser(boolean flag) { | ||
handleRenamedFiles = flag; | ||
} | ||
|
||
/** | ||
* Process the output from the log command and insert the HistoryEntries | ||
* into the history field. | ||
|
@@ -177,7 +183,7 @@ History parse(File file, Repository repos, String sinceRevision) throws HistoryE | |
status)); | ||
} | ||
|
||
if (RuntimeEnvironment.getInstance().isHandleHistoryOfRenamedFiles()) { | ||
if (handleRenamedFiles) { | ||
executor = repository.getRenamedFilesExecutor(file, sinceRevision); | ||
status = executor.exec(true, parser); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opensolaris.opengrok.history; | ||
|
@@ -93,7 +93,7 @@ public class MercurialRepository extends Repository { | |
+ END_OF_ENTRY + "\\n"; | ||
|
||
/** | ||
* Template for formatting hg log output for directories. | ||
* Template for formatting {@code hg log} output for directories. | ||
*/ | ||
private static final String DIR_TEMPLATE_RENAMED | ||
= TEMPLATE_STUB + FILE_LIST | ||
|
@@ -104,7 +104,7 @@ public class MercurialRepository extends Repository { | |
|
||
private static final Pattern LOG_COPIES_PATTERN | ||
= Pattern.compile("^(\\d+):(.*)"); | ||
|
||
public MercurialRepository() { | ||
type = "Mercurial"; | ||
datePatterns = new String[]{ | ||
|
@@ -188,7 +188,7 @@ Executor getHistoryLogExecutor(File file, String sinceRevision) | |
|
||
cmd.add("--template"); | ||
if (file.isDirectory()) { | ||
cmd.add(env.isHandleHistoryOfRenamedFiles() ? DIR_TEMPLATE_RENAMED : DIR_TEMPLATE); | ||
cmd.add(this.isHandleRenamedFiles() ? DIR_TEMPLATE_RENAMED : DIR_TEMPLATE); | ||
} else { | ||
cmd.add(FILE_TEMPLATE); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.