[patch]: IDEA-146642 unexpected mapping on applying a VCS patch

* tests added
This commit is contained in:
Nadya Zabrodina
2015-10-27 16:09:37 +03:00
parent c43c0e47c9
commit 40ef04e8cc
@@ -89,7 +89,7 @@ public class MatchPatchPaths {
for (VirtualFile file : files) {
Pair<VirtualFile, Integer> pair = compareNamesImpl(strings, file, i);
if (pair != null && pair.getSecond() < i) {
if (best == null || pair.getSecond() < best.getSecond()) {
if (best == null || pair.getSecond() < best.getSecond() || isGoodAndProjectBased(best, pair)) {
best = pair;
}
}
@@ -110,6 +110,10 @@ public class MatchPatchPaths {
}
}
private boolean isGoodAndProjectBased(@NotNull Pair<VirtualFile, Integer> best, @NotNull Pair<VirtualFile, Integer> pair) {
return pair.getSecond().equals(best.getSecond()) && myBaseDir.equals(pair.getFirst());
}
private static void selectByContextOrByStrip(@NotNull List<PatchAndVariants> candidates,
@NotNull MultiMap<VirtualFile, AbstractFilePatchInProgress> result) {
for (final PatchAndVariants candidate : candidates) {