Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unify file quoting in SCCS/Mercurial #4565

Merged
merged 4 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.history;
Expand Down Expand Up @@ -81,13 +81,12 @@ void parse(File file, String sinceRevision, String tillRevision, Integer numComm
Executor executor = repository.getHistoryLogExecutor(file, sinceRevision, tillRevision, false,
numCommits);
int status = executor.exec(true, this);

if (status != 0) {
throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() +
"\" Exit code: " + status);
throw new HistoryException(String.format("Failed to get history for '%s' (exit status %d)",
file.getAbsolutePath(), status));
}
} catch (IOException e) {
throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e);
throw new HistoryException(String.format("Failed to get history for '%s'", file.getAbsolutePath()), e);
}

// If a changeset to start from is specified, remove that changeset from the list,
Expand Down Expand Up @@ -151,7 +150,7 @@ private void removeChangesets(List<RepositoryWithHistoryTraversal.ChangesetInfo>
* {@link org.opengrok.indexer.history.RepositoryWithHistoryTraversal.ChangesetInfo} elements.
*
* @param input The output from the process
* @throws java.io.IOException If an error occurs while reading the stream
* @throws IOException If an error occurs while reading the stream
*/
@Override
public void processStream(InputStream input) throws IOException {
Expand Down Expand Up @@ -182,7 +181,7 @@ public void processStream(InputStream input) throws IOException {
} else if (s.startsWith(MercurialRepository.FILES) && entry != null) {
String[] strings = s.split(" ");
for (int ii = 1; ii < strings.length; ++ii) {
if (strings[ii].length() > 0) {
if (!strings[ii].isEmpty()) {
File f = new File(mydir, strings[ii]);
try {
String path = env.getPathRelativeToSourceRoot(f);
Expand Down Expand Up @@ -221,7 +220,7 @@ public void processStream(InputStream input) throws IOException {
} else if (s.equals(MercurialRepository.END_OF_ENTRY)
&& entry != null) {
entry = null;
} else if (s.length() > 0) {
} else if (!s.isEmpty()) {
LOGGER.log(Level.WARNING,
"Invalid/unexpected output {0} from hg log for repo {1}",
new Object[]{s, repository.getDirectoryName()});
Expand All @@ -235,10 +234,10 @@ public void processStream(InputStream input) throws IOException {
* This is to prevent problems if the log message contains one of the
* prefixes that {@link #processStream(InputStream)} is looking for (bug
* #405).
*
* <p>
* This method is way too tolerant, and won't complain if the line has
* a different format than expected. It will return weird results, though.
*
* </p>
* @param line the XML encoded line
* @return the decoded description
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
*/
package org.opengrok.indexer.history;

Expand Down Expand Up @@ -68,14 +68,13 @@ History parse(File file) throws HistoryException {
try {
return parseFile(file);
} catch (IOException e) {
throw new HistoryException("Failed to get history for " +
"\"" + file.getAbsolutePath() + "\":", e);
throw new HistoryException(String.format("Failed to get history for '%s'", file.getAbsolutePath()), e);
} catch (ParseException e) {
throw new HistoryException("Failed to parse history for " +
"\"" + file.getAbsolutePath() + "\":", e);
throw new HistoryException(String.format("Failed to parse history for '%s'", file.getAbsolutePath()), e);
}
}

@Nullable
private History parseFile(File file) throws IOException, ParseException {
File f = getSCCSFile(file);
if (f == null) {
Expand Down Expand Up @@ -110,9 +109,9 @@ private History parseFile(File file) throws IOException, ParseException {
* Read a single line of delta record into the {@link #sccsRecord} member.
*
* @return boolean indicating whether there is another record.
* @throws java.io.IOException on I/O error
* @throws IOException on I/O error
*/
private boolean next() throws java.io.IOException {
private boolean next() throws IOException {
sep = true;
sccsRecord.setLength(0);
int c;
Expand Down Expand Up @@ -189,7 +188,7 @@ private boolean isActive() {
return active;
}

private int read() throws java.io.IOException {
private int read() throws IOException {
int c, d, dt;
while ((c = in.read()) != -1) {
switch (c) { //NOPMD
Expand Down
Loading