From 5d31cec5d0f10d8cda18c6db33efffd25103118a Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 13 Sep 2017 15:43:03 +0300 Subject: [PATCH] vcs: cleanup - inline util method --- .../intellij/openapi/vcs/changes/Change.java | 44 ++++++++++--------- .../com/intellij/vcsUtil/VcsFilePathUtil.java | 32 -------------- 2 files changed, 23 insertions(+), 53 deletions(-) delete mode 100644 platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/VcsFilePathUtil.java diff --git a/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/Change.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/Change.java index 006bfb7f6f2e..024b8751084e 100644 --- a/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/Change.java +++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/Change.java @@ -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 diff --git a/platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/VcsFilePathUtil.java b/platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/VcsFilePathUtil.java deleted file mode 100644 index b6992f53ab0c..000000000000 --- a/platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/VcsFilePathUtil.java +++ /dev/null @@ -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); - } -}