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
;
20 public void setRenamedOrMovedTarget(final FilePath target
) {
21 myMoved
= myRenamed
= false;
23 if ((getBeforeRevision() != null) || (getAfterRevision() == null)) {
24 // not external rename or move
27 final FilePath localPath
= ChangesUtil
.getFilePath(this);
28 if (localPath
.getIOFile().getAbsolutePath().equals(target
.getIOFile().getAbsolutePath())) {
33 if (Comparing
.equal(target
.getParentPath(), localPath
.getParentPath())) {
40 myRenamedTargetName
= target
.getName();
41 myRenameOrMoveCached
= true;
45 public String
getOriginText(final Project project
) {
47 return VcsBundle
.message("change.file.copied.from.text", myOriginUrl
);
49 return super.getOriginText(project
);
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();
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() {
72 public void setCopied(final boolean copied
) {