SVN 1.6 support. svnkit: 1-3-0-beta3, patched for IDEA
[fedora-idea.git] / vcs-api / src / com / intellij / openapi / vcs / changes / ExternallyRenamedChange.java
blobf7d80d45c2f9e7d6dd1b184ea2cd9d0e5d83b925
1 package com.intellij.openapi.vcs.changes;
3 import com.intellij.openapi.project.Project;
4 import com.intellij.openapi.util.Comparing;
5 import com.intellij.openapi.vcs.FilePath;
6 import com.intellij.openapi.vcs.VcsBundle;
7 import org.jetbrains.annotations.Nullable;
9 public class ExternallyRenamedChange extends Change {
10 private String myRenamedTargetName;
11 private boolean myCopied;
12 private final String myOriginUrl;
14 public ExternallyRenamedChange(final ContentRevision beforeRevision, final ContentRevision afterRevision, final String originUrl) {
15 super(beforeRevision, afterRevision);
16 myOriginUrl = originUrl;
17 myCopied = true;
20 public void setRenamedOrMovedTarget(final FilePath target) {
21 myMoved = myRenamed = false;
23 if ((getBeforeRevision() != null) || (getAfterRevision() == null)) {
24 // not external rename or move
25 return;
27 final FilePath localPath = ChangesUtil.getFilePath(this);
28 if (localPath.getIOFile().getAbsolutePath().equals(target.getIOFile().getAbsolutePath())) {
29 // not rename or move
30 return;
33 if (Comparing.equal(target.getParentPath(), localPath.getParentPath())) {
34 myRenamed = true;
35 } else {
36 myMoved = true;
38 myCopied = false;
40 myRenamedTargetName = target.getName();
41 myRenameOrMoveCached = true;
44 @Override
45 public String getOriginText(final Project project) {
46 if (myCopied) {
47 return VcsBundle.message("change.file.copied.from.text", myOriginUrl);
49 return super.getOriginText(project);
52 @Nullable
53 protected String getRenamedText() {
54 if (myRenamedTargetName != null) {
55 return VcsBundle.message((getBeforeRevision() != null) ? "change.file.renamed.to.text" : "change.file.renamed.from.text", myRenamedTargetName);
57 return super.getRenamedText();
60 @Nullable
61 protected String getMovedText(final Project project) {
62 if (myRenamedTargetName != null) {
63 return VcsBundle.message((getBeforeRevision() != null) ? "change.file.moved.to.text" : "change.file.moved.from.text", myRenamedTargetName);
65 return super.getMovedText(project);
68 public boolean isCopied() {
69 return myCopied;
72 public void setCopied(final boolean copied) {
73 myCopied = copied;