import java.util.Collections;
import org.eclipse.jgit.annotations.Nullable;
-import org.eclipse.jgit.api.errors.CanceledException;
import org.eclipse.jgit.blame.Candidate.BlobCandidate;
import org.eclipse.jgit.blame.Candidate.ReverseCandidate;
import org.eclipse.jgit.blame.ReverseWalk.ReverseCommit;
if (n.sourceCommit == null)
return result(n);
- DiffEntry r;
- try {
- r = findRename(parent, n.sourceCommit, n.sourcePath);
- if (r == null) {
- return result(n);
- }
- } catch (CanceledException e) {
+ DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath);
+ if (r == null)
return result(n);
- }
if (0 == r.getOldId().prefixCompare(n.sourceBlob)) {
// A 100% rename without any content change can also
return false;
}
- private boolean processMerge(Candidate n)
- throws IOException {
+ private boolean processMerge(Candidate n) throws IOException {
int pCnt = n.getParentCount();
// If any single parent exactly matches the merge, follow only
if (ids != null && ids[pIdx] != null)
continue;
- DiffEntry r;
- try {
- r = findRename(parent, n.sourceCommit, n.sourcePath);
- if (r == null) {
- continue;
- }
- } catch (CanceledException e) {
+ DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath);
+ if (r == null)
continue;
- }
if (n instanceof ReverseCandidate) {
if (ids == null)
}
private DiffEntry findRename(RevCommit parent, RevCommit commit,
- PathFilter path) throws IOException, CanceledException {
+ PathFilter path) throws IOException {
if (renameDetector == null)
return null;
import java.util.HashMap;
import java.util.List;
-import org.eclipse.jgit.api.errors.CanceledException;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.diff.SimilarityIndex.TableFullException;
+import org.eclipse.jgit.errors.CancelledException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.AbbreviatedObjectId;
import org.eclipse.jgit.lib.FileMode;
* file contents cannot be read from the repository.
*/
public List<DiffEntry> compute() throws IOException {
- try {
- return compute(NullProgressMonitor.INSTANCE);
- } catch (CanceledException e) {
- return Collections.emptyList();
- }
+ return compute(NullProgressMonitor.INSTANCE);
}
/**
* representing all files that have been changed.
* @throws java.io.IOException
* file contents cannot be read from the repository.
- * @throws CanceledException
+ * @throws CancelledException
* if rename detection was cancelled
*/
+ // TODO(ms): use org.eclipse.jgit.api.errors.CanceledException in next major
+ // version
public List<DiffEntry> compute(ProgressMonitor pm)
- throws IOException, CanceledException {
+ throws IOException, CancelledException {
if (!done) {
try {
return compute(objectReader, pm);
* representing all files that have been changed.
* @throws java.io.IOException
* file contents cannot be read from the repository.
- * @throws CanceledException
+ * @throws CancelledException
* if rename detection was cancelled
*/
+ // TODO(ms): use org.eclipse.jgit.api.errors.CanceledException in next major
+ // version
public List<DiffEntry> compute(ObjectReader reader, ProgressMonitor pm)
- throws IOException, CanceledException {
+ throws IOException, CancelledException {
final ContentSource cs = ContentSource.create(reader);
return compute(new ContentSource.Pair(cs, cs), pm);
}
* representing all files that have been changed.
* @throws java.io.IOException
* file contents cannot be read from the repository.
- * @throws CanceledException
+ * @throws CancelledException
* if rename detection was cancelled
*/
+ // TODO(ms): use org.eclipse.jgit.api.errors.CanceledException in next major
+ // version
public List<DiffEntry> compute(ContentSource.Pair reader, ProgressMonitor pm)
- throws IOException, CanceledException {
+ throws IOException, CancelledException {
if (!done) {
done = true;
done = false;
}
- private void advanceOrCancel(ProgressMonitor pm) throws CanceledException {
+ private void advanceOrCancel(ProgressMonitor pm) throws CancelledException {
if (pm.isCancelled()) {
- throw new CanceledException(JGitText.get().renameCancelled);
+ throw new CancelledException(JGitText.get().renameCancelled);
}
pm.update(1);
}
private void breakModifies(ContentSource.Pair reader, ProgressMonitor pm)
- throws IOException, CanceledException {
+ throws IOException, CancelledException {
ArrayList<DiffEntry> newEntries = new ArrayList<>(entries.size());
pm.beginTask(JGitText.get().renamesBreakingModifies, entries.size());
entries = newEntries;
}
- private void rejoinModifies(ProgressMonitor pm) throws CanceledException {
+ private void rejoinModifies(ProgressMonitor pm) throws CancelledException {
HashMap<String, DiffEntry> nameMap = new HashMap<>();
ArrayList<DiffEntry> newAdded = new ArrayList<>(added.size());
private void findContentRenames(ContentSource.Pair reader,
ProgressMonitor pm)
- throws IOException, CanceledException {
+ throws IOException, CancelledException {
int cnt = Math.max(added.size(), deleted.size());
if (getRenameLimit() == 0 || cnt <= getRenameLimit()) {
SimilarityRenameDetector d;
}
@SuppressWarnings("unchecked")
- private void findExactRenames(ProgressMonitor pm) throws CanceledException {
+ private void findExactRenames(ProgressMonitor pm)
+ throws CancelledException {
pm.beginTask(JGitText.get().renamesFindingExact, //
added.size() + added.size() + deleted.size()
+ added.size() * deleted.size());
matrix[mNext] = SimilarityRenameDetector.encode(score, delIdx, addIdx);
mNext++;
if (pm.isCancelled()) {
- throw new CanceledException(
+ throw new CancelledException(
JGitText.get().renameCancelled);
}
}
@SuppressWarnings("unchecked")
private HashMap<AbbreviatedObjectId, Object> populateMap(
List<DiffEntry> diffEntries, ProgressMonitor pm)
- throws CanceledException {
+ throws CancelledException {
HashMap<AbbreviatedObjectId, Object> map = new HashMap<>();
for (DiffEntry de : diffEntries) {
Object old = map.put(id(de), de);
import java.util.BitSet;
import java.util.List;
-import org.eclipse.jgit.api.errors.CanceledException;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.diff.SimilarityIndex.TableFullException;
+import org.eclipse.jgit.errors.CancelledException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.NullProgressMonitor;
renameScore = score;
}
- void compute(ProgressMonitor pm) throws IOException, CanceledException {
+ void compute(ProgressMonitor pm) throws IOException, CancelledException {
if (pm == null)
pm = NullProgressMonitor.INSTANCE;
//
for (--mNext; mNext >= 0; mNext--) {
if (pm.isCancelled()) {
- throw new CanceledException(JGitText.get().renameCancelled);
+ // TODO(ms): use org.eclipse.jgit.api.errors.CanceledException
+ // in next major version
+ throw new CancelledException(JGitText.get().renameCancelled);
}
long ent = matrix[mNext];
int sIdx = srcFile(ent);
}
private int buildMatrix(ProgressMonitor pm)
- throws IOException, CanceledException {
+ throws IOException, CancelledException {
// Allocate for the worst-case scenario where every pair has a
// score that we need to consider. We might not need that many.
//
for (int dstIdx = 0; dstIdx < dsts.size(); dstIdx++) {
if (pm.isCancelled()) {
- throw new CanceledException(JGitText.get().renameCancelled);
+ // TODO(ms): use
+ // org.eclipse.jgit.api.errors.CanceledException in next
+ // major version
+ throw new CancelledException(
+ JGitText.get().renameCancelled);
}
DiffEntry dstEnt = dsts.get(dstIdx);