diff --git a/plugins/hg4idea/hg4idea.iml b/plugins/hg4idea/hg4idea.iml
index 0a3ed3081eb0..7c4d59c3f238 100644
--- a/plugins/hg4idea/hg4idea.iml
+++ b/plugins/hg4idea/hg4idea.iml
@@ -16,6 +16,7 @@
+
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgChange.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgChange.java
index 5fe933799c09..d1f225a38e32 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgChange.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgChange.java
@@ -12,15 +12,14 @@
// limitations under the License.
package org.zmlx.hg4idea;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
+import com.google.common.base.Objects;
import org.jetbrains.annotations.NotNull;
public final class HgChange {
- private HgFile beforeFile;
- private HgFile afterFile;
- private HgFileStatusEnum status;
+ @NotNull private HgFile beforeFile;
+ @NotNull private HgFile afterFile;
+ @NotNull private HgFileStatusEnum status;
public HgChange(@NotNull HgFile hgFile, @NotNull HgFileStatusEnum status) {
this.beforeFile = hgFile;
@@ -55,29 +54,34 @@ public final class HgChange {
this.status = status;
}
+
@Override
- public boolean equals(Object object) {
- if (object == this) {
+ public boolean equals(Object o) {
+ if (this == o) {
return true;
}
- if (!(object instanceof HgChange)) {
+ if (o == null || getClass() != o.getClass()) {
return false;
}
- HgChange that = (HgChange) object;
- return new EqualsBuilder()
- .append(beforeFile, that.beforeFile)
- .append(afterFile, that.afterFile)
- .append(status, that.status)
- .isEquals();
+
+ HgChange change = (HgChange)o;
+
+ if (!afterFile.equals(change.afterFile)) {
+ return false;
+ }
+ if (!beforeFile.equals(change.beforeFile)) {
+ return false;
+ }
+ if (status != change.status) {
+ return false;
+ }
+
+ return true;
}
@Override
public int hashCode() {
- return new HashCodeBuilder()
- .append(beforeFile)
- .append(afterFile)
- .append(status)
- .toHashCode();
+ return Objects.hashCode(beforeFile, afterFile, status);
}
@Override
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgContentRevision.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgContentRevision.java
index 4a93eddb7bc9..aeea8fd66b4f 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgContentRevision.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgContentRevision.java
@@ -12,6 +12,7 @@
// limitations under the License.
package org.zmlx.hg4idea;
+import com.google.common.base.Objects;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.FilePath;
@@ -19,8 +20,6 @@ import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsUtil;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.command.HgCatCommand;
@@ -31,13 +30,13 @@ import java.io.UnsupportedEncodingException;
public class HgContentRevision implements ContentRevision {
private final Project myProject;
- private final HgFile myHgFile;
+ @NotNull private final HgFile myHgFile;
@NotNull private final HgRevisionNumber myRevisionNumber;
private FilePath filePath;
private String content;
- public HgContentRevision(Project project, HgFile hgFile, @NotNull HgRevisionNumber revisionNumber) {
+ public HgContentRevision(Project project, @NotNull HgFile hgFile, @NotNull HgRevisionNumber revisionNumber) {
myProject = project;
myHgFile = hgFile;
myRevisionNumber = revisionNumber;
@@ -90,26 +89,28 @@ public class HgContentRevision implements ContentRevision {
}
@Override
- public int hashCode() {
- return new HashCodeBuilder()
- .append(myHgFile)
- .append(myRevisionNumber)
- .toHashCode();
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ HgContentRevision revision = (HgContentRevision)o;
+
+ if (!myHgFile.equals(revision.myHgFile)) {
+ return false;
+ }
+ if (!myRevisionNumber.equals(revision.myRevisionNumber)) {
+ return false;
+ }
+
+ return true;
}
@Override
- public boolean equals(Object object) {
- if (object == this) {
- return true;
- }
- if (!(object instanceof HgContentRevision)) {
- return false;
- }
- HgContentRevision that = (HgContentRevision) object;
- return new EqualsBuilder()
- .append(myHgFile, that.myHgFile)
- .append(myRevisionNumber, that.myRevisionNumber)
- .isEquals();
+ public int hashCode() {
+ return Objects.hashCode(myHgFile, myRevisionNumber);
}
-
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgFile.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgFile.java
index 15a7d85718c8..924822f5ecb3 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgFile.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgFile.java
@@ -12,17 +12,15 @@
// limitations under the License.
package org.zmlx.hg4idea;
+import com.google.common.base.Objects;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsUtil;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -86,34 +84,37 @@ public class HgFile {
}
@Override
- public boolean equals(Object object) {
- if (object == this) {
+ public boolean equals(Object o) {
+ if (this == o) {
return true;
}
- if (!(object instanceof HgFile)) {
+ if (o == null || getClass() != o.getClass()) {
return false;
}
- HgFile that = (HgFile) object;
- return new EqualsBuilder()
- .append(vcsRoot, that.vcsRoot)
- .append(file, that.file)
- .isEquals();
+
+ HgFile that = (HgFile)o;
+
+ if (!vcsRoot.equals(that.vcsRoot)) {
+ return false;
+ }
+ if (file != null ? !FileUtil.filesEqual(file, that.file) : that.file != null) {
+ return false;
+ }
+
+ return true;
}
@Override
public int hashCode() {
- return new HashCodeBuilder()
- .append(vcsRoot)
- .append(file)
- .toHashCode();
+ return Objects.hashCode(vcsRoot, file);
}
@Override
public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
- .append("repo", vcsRoot)
- .append("file", file)
- .append("relativePath", getRelativePath())
+ return Objects.toStringHelper(HgFile.class)
+ .add("repo", vcsRoot)
+ .add("file", file)
+ .add("relativePath", getRelativePath())
.toString();
}
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgFileRevision.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgFileRevision.java
index b1d0c085874f..a22ace75430f 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgFileRevision.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgFileRevision.java
@@ -12,14 +12,14 @@
// limitations under the License.
package org.zmlx.hg4idea;
+import com.google.common.base.Objects;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Throwable2Computable;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.impl.ContentRevisionCache;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.command.HgCatCommand;
import org.zmlx.hg4idea.util.HgUtil;
@@ -33,8 +33,8 @@ import java.util.Set;
public class HgFileRevision implements VcsFileRevision {
private final Project project;
- private final HgFile hgFile;
- private final HgRevisionNumber vcsRevisionNumber;
+ @NotNull private final HgFile hgFile;
+ @NotNull private final HgRevisionNumber vcsRevisionNumber;
private final String branchName;
private final Date revisionDate;
private final String author;
@@ -44,7 +44,7 @@ public class HgFileRevision implements VcsFileRevision {
private final Set filesDeleted;
private Map filesCopied;
- public HgFileRevision(Project project, HgFile hgFile, HgRevisionNumber vcsRevisionNumber,
+ public HgFileRevision(Project project, @NotNull HgFile hgFile, @NotNull HgRevisionNumber vcsRevisionNumber,
String branchName, Date revisionDate, String author, String commitMessage,
Set filesModified, Set filesAdded, Set filesDeleted, Map filesCopied) {
this.project = project;
@@ -119,35 +119,38 @@ public class HgFileRevision implements VcsFileRevision {
public byte[] getContent() throws IOException, VcsException {
return ContentRevisionCache.getOrLoadAsBytes(project, hgFile.toFilePath(), getRevisionNumber(), HgVcs.getKey(),
- ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable() {
- @Override
- public byte[] compute() throws VcsException, IOException {
- return loadContent();
- }
- });
+ ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
+ new Throwable2Computable() {
+ @Override
+ public byte[] compute() throws VcsException, IOException {
+ return loadContent();
+ }
+ });
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ HgFileRevision revision = (HgFileRevision)o;
+
+ if (!hgFile.equals(revision.hgFile)) {
+ return false;
+ }
+ if (!vcsRevisionNumber.equals(revision.vcsRevisionNumber)) {
+ return false;
+ }
+
+ return true;
}
@Override
public int hashCode() {
- return new HashCodeBuilder()
- .append(hgFile)
- .append(vcsRevisionNumber)
- .toHashCode();
+ return Objects.hashCode(hgFile, vcsRevisionNumber);
}
-
- @Override
- public boolean equals(Object object) {
- if (object == this) {
- return true;
- }
- if (!(object instanceof HgFileRevision)) {
- return false;
- }
- HgFileRevision that = (HgFileRevision) object;
- return new EqualsBuilder()
- .append(hgFile, that.hgFile)
- .append(vcsRevisionNumber, that.vcsRevisionNumber)
- .isEquals();
- }
-
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgRevisionNumber.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgRevisionNumber.java
index 639e858e2ae1..5c78a863d0ec 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgRevisionNumber.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgRevisionNumber.java
@@ -12,8 +12,8 @@
// limitations under the License.
package org.zmlx.hg4idea;
+import com.google.common.base.Objects;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
-import org.apache.commons.lang.builder.HashCodeBuilder;
import java.util.Collections;
import java.util.List;
@@ -136,10 +136,7 @@ public class HgRevisionNumber implements VcsRevisionNumber {
@Override
public int hashCode() {
- return new HashCodeBuilder()
- .append(revision)
- .append(changeset)
- .toHashCode();
+ return Objects.hashCode(revision, changeset);
}
@Override
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRevisionsCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRevisionsCommand.java
index f6167053c7c6..b37faee10f6a 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRevisionsCommand.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRevisionsCommand.java
@@ -65,7 +65,7 @@ abstract class HgRevisionsCommand {
HgCommandExecutor executor, VirtualFile repo, String template, int limit, HgFile hgFile
);
- public final List execute(HgFile hgFile, int limit, boolean includeFiles) {
+ public final List execute(final HgFile hgFile, int limit, boolean includeFiles) {
if ((limit <= 0 && limit != -1) || hgFile == null || hgFile.getRepo() == null) {
return Collections.emptyList();
}
@@ -113,7 +113,7 @@ abstract class HgRevisionsCommand {
parents.add(HgRevisionNumber.getInstance(parentParts[0], parentParts[1]));
}
}
- HgRevisionNumber vcsRevisionNumber = HgRevisionNumber.getInstance(
+ final HgRevisionNumber vcsRevisionNumber = HgRevisionNumber.getInstance(
revisionString,
changeset,
parents
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCurrentContentRevision.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCurrentContentRevision.java
index 89960b6e8667..c6c4bf72710b 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCurrentContentRevision.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCurrentContentRevision.java
@@ -34,7 +34,7 @@ class HgCurrentContentRevision extends CurrentContentRevision {
return revisionNumber;
}
- public static ContentRevision create(HgFile hgFile, HgRevisionNumber revision) {
+ public static ContentRevision create(@NotNull HgFile hgFile, HgRevisionNumber revision) {
VirtualFile virtualFile = VcsUtil.getVirtualFile(hgFile.getFile());
if (virtualFile == null) {
return null;