mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] ensure that text and hash filter are consistent
This commit is contained in:
@@ -213,6 +213,31 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUi {
|
||||
super(VcsLogFilterCollection.TEXT_FILTER, VcsLogFilterCollection.HASH_FILTER, dataPackProvider, properties, filters);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected FilterPair<VcsLogTextFilter, VcsLogHashFilter> getFilterFromProperties() {
|
||||
FilterPair<VcsLogTextFilter, VcsLogHashFilter> filterPair = super.getFilterFromProperties();
|
||||
if (filterPair == null) return null;
|
||||
// check filters correctness
|
||||
if (filterPair.getFilter1() != null && !StringUtil.isEmptyOrSpaces(filterPair.getFilter1().getText())) {
|
||||
VcsLogHashFilter hashFilterFromText = VcsLogFilterObject.fromHash(filterPair.getFilter1().getText());
|
||||
if (!Objects.equals(filterPair.getFilter2(), hashFilterFromText)) {
|
||||
LOG.warn("Set hash filter " + filterPair.getFilter2() + " is inconsistent with text filter." +
|
||||
" Replacing with " + hashFilterFromText);
|
||||
return new FilterPair<>(filterPair.getFilter1(), hashFilterFromText);
|
||||
}
|
||||
}
|
||||
else if (filterPair.getFilter2() != null && !filterPair.getFilter2().getHashes().isEmpty()) {
|
||||
VcsLogTextFilter textFilterFromHashes = createTextFilter(StringUtil.join(filterPair.getFilter2().getHashes(), " "));
|
||||
LOG.warn("Set hash filter " +
|
||||
filterPair.getFilter2() +
|
||||
" is inconsistent with empty text filter. Using text filter " +
|
||||
textFilterFromHashes);
|
||||
return new FilterPair<>(textFilterFromHashes, filterPair.getFilter2());
|
||||
}
|
||||
return filterPair;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String getText() {
|
||||
if (myText != null) {
|
||||
|
||||
+14
-1
@@ -7,9 +7,9 @@ import com.intellij.vcs.log.util.VcsLogUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
class VcsLogHashFilterImpl implements VcsLogHashFilter {
|
||||
|
||||
@NotNull private final Collection<String> myHashes;
|
||||
|
||||
VcsLogHashFilterImpl(@NotNull Collection<String> hashes) {
|
||||
@@ -32,4 +32,17 @@ class VcsLogHashFilterImpl implements VcsLogHashFilter {
|
||||
public String toString() {
|
||||
return "hashes:" + myHashes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
VcsLogHashFilterImpl filter = (VcsLogHashFilterImpl)o;
|
||||
return myHashes.equals(filter.myHashes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(myHashes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user