vcs: cleanup - inline util method

This commit is contained in:
Aleksey Pivovarov
2017-09-26 19:50:41 +03:00
parent edf74799e4
commit 5d31cec5d0
2 changed files with 23 additions and 53 deletions
@@ -25,7 +25,6 @@ import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.impl.VcsPathPresenter;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcsUtil.VcsFilePathUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -89,27 +88,30 @@ public class Change {
}
public Type getType() {
if (myType == null) {
if (myBeforeRevision == null) {
myType = Type.NEW;
return myType;
}
if (myAfterRevision == null) {
myType = Type.DELETED;
return myType;
}
if ((! Comparing.equal(myBeforeRevision.getFile(), myAfterRevision.getFile())) ||
((! SystemInfo.isFileSystemCaseSensitive) && VcsFilePathUtil
.caseDiffers(myBeforeRevision.getFile().getPath(), myAfterRevision.getFile().getPath()))) {
myType = Type.MOVED;
return myType;
}
myType = Type.MODIFICATION;
Type type = myType;
if (type == null) {
myType = type = calcType();
}
return myType;
return type;
}
@NotNull
private Type calcType() {
if (myBeforeRevision == null) return Type.NEW;
if (myAfterRevision == null) return Type.DELETED;
FilePath bFile = myBeforeRevision.getFile();
FilePath aFile = myAfterRevision.getFile();
if (!Comparing.equal(bFile, aFile)) return Type.MOVED;
// enforce case-sensitive check
if (!SystemInfo.isFileSystemCaseSensitive) {
String bPath = bFile.getPath();
String aPath = aFile.getPath();
if (!bPath.equals(aPath) && bPath.equalsIgnoreCase(aPath)) return Type.MOVED;
}
return Type.MODIFICATION;
}
@Nullable
@@ -1,32 +0,0 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.vcsUtil;
import java.io.File;
public class VcsFilePathUtil {
public static boolean caseDiffers(final String s1, final String s2) {
String s1Trimmed = s1.trim();
String s2Trimmed = s2.trim();
if (File.separatorChar != '/') {
s1Trimmed = s1Trimmed.replace(File.separatorChar, '/');
s2Trimmed = s2Trimmed.replace(File.separatorChar, '/');
}
return (! s1Trimmed.equals(s2Trimmed)) && s1Trimmed.equalsIgnoreCase(s2Trimmed);
}
}