[git] remove deprecated AbstractHash

This commit is contained in:
Julia Beliaeva
2017-07-12 18:05:28 +03:00
parent adbd75d086
commit 42bcc477b8
3 changed files with 6 additions and 141 deletions
@@ -23,9 +23,10 @@ import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.impl.HashImpl;
import git4idea.GitContentRevision;
import git4idea.GitRevisionNumber;
import git4idea.history.wholeTree.AbstractHash;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -53,14 +54,14 @@ public class GitChangesParser {
}
private static List<GitRevisionNumber> prepareParentRevisions(List<String> parentsHashes) {
final List<AbstractHash> parents = new ArrayList<>(parentsHashes.size());
final List<Hash> parents = new ArrayList<>(parentsHashes.size());
for (String parentsShortHash : parentsHashes) {
parents.add(AbstractHash.create(parentsShortHash));
parents.add(HashImpl.build(parentsShortHash));
}
final List<GitRevisionNumber> parentRevisions = new ArrayList<>(parents.size());
for (AbstractHash parent : parents) {
parentRevisions.add(new GitRevisionNumber(parent.getString()));
for (Hash parent : parents) {
parentRevisions.add(new GitRevisionNumber(parent.asString()));
}
return parentRevisions;
}
@@ -1,69 +0,0 @@
/*
* Copyright 2000-2010 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 git4idea.history.wholeTree;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.impl.HashImpl;
import org.jetbrains.annotations.NotNull;
/**
* @author irengrig
*/
@Deprecated
public class AbstractHash {
@NotNull private final Hash myHash;
private AbstractHash(@NotNull Hash hash) {
myHash = hash;
}
@NotNull
public static AbstractHash create(final String hash) {
return new AbstractHash(HashImpl.build(hash));
}
public String getString() {
return myHash.asString();
}
@Override
public String toString() {
return getString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractHash hash = (AbstractHash)o;
if (!myHash.equals(hash.myHash)) return false;
return true;
}
@Override
public int hashCode() {
return myHash.hashCode();
}
public static boolean hashesEqual(@NotNull final AbstractHash hash1, @NotNull final AbstractHash hash2) {
if (hash1.equals(hash2)) return true;
final String s1 = hash1.getString();
final String s2 = hash2.getString();
if (s1.startsWith(s2) || s2.startsWith(s1)) return true;
return false;
}
}
@@ -1,67 +0,0 @@
/*
* Copyright 2000-2010 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 git4idea.tests;
import git4idea.history.wholeTree.AbstractHash;
import junit.framework.Assert;
import junit.framework.TestCase;
/**
* @author irengrig
*/
public class AbstractHashTest extends TestCase {
public void testSimple() throws Exception {
final String hash = "0a5b9f";
final AbstractHash abstractHash = AbstractHash.create(hash);
Assert.assertFalse(abstractHash.getClass().getName().contains("AbstractHash.StringPresentation"));
Assert.assertEquals(hash, abstractHash.getString());
}
public void testShort() throws Exception {
final String hash = "f";
final AbstractHash abstractHash = AbstractHash.create(hash);
Assert.assertFalse(abstractHash.getClass().getName().contains("AbstractHash.StringPresentation"));
Assert.assertEquals(hash, abstractHash.getString());
final String hash1 = "ff";
final AbstractHash abstractHash1 = AbstractHash.create(hash1);
Assert.assertFalse(abstractHash1.getClass().getName().contains("AbstractHash.StringPresentation"));
Assert.assertEquals(hash1, abstractHash1.getString());
}
public void testLong() throws Exception {
final String hash = "0123456789abcdef0123456789abcdef01234567";
final AbstractHash abstractHash = AbstractHash.create(hash);
Assert.assertFalse(abstractHash.getClass().getName().contains("AbstractHash.StringPresentation"));
Assert.assertEquals(hash, abstractHash.getString());
}
public void testLeadingNulls() throws Exception {
final String hash0 = "0";
final AbstractHash abstractHash0 = AbstractHash.create(hash0);
Assert.assertFalse(abstractHash0.getClass().getName().contains("AbstractHash.StringPresentation"));
Assert.assertEquals(hash0, abstractHash0.getString());
final String hash = "0f";
final AbstractHash abstractHash = AbstractHash.create(hash);
Assert.assertFalse(abstractHash.getClass().getName().contains("AbstractHash.StringPresentation"));
Assert.assertEquals(hash, abstractHash.getString());
final String hash1 = "001";
final AbstractHash abstractHash1 = AbstractHash.create(hash1);
Assert.assertFalse(abstractHash1.getClass().getName().contains("AbstractHash.StringPresentation"));
Assert.assertEquals(hash1, abstractHash1.getString());
final String hash2 = "000";
final AbstractHash abstractHash2 = AbstractHash.create(hash2);
Assert.assertFalse(abstractHash2.getClass().getName().contains("AbstractHash.StringPresentation"));
Assert.assertEquals(hash2, abstractHash2.getString());
}
}