svn: Refactored "FirstInBranch" - used "SVNURL" instead of "String"

This commit is contained in:
Konstantin Kolosovsky
2016-10-11 04:28:23 +03:00
parent 9e3ac5b3e9
commit 2e2a5ebb22
5 changed files with 18 additions and 14 deletions
@@ -25,12 +25,12 @@ import org.jetbrains.idea.svn.commandLine.SvnBindException;
import org.tmatesoft.svn.core.SVNCancelException;
import org.tmatesoft.svn.core.SVNErrorCode;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc2.SvnTarget;
import static org.jetbrains.idea.svn.SvnUtil.createUrl;
import static org.jetbrains.idea.svn.SvnUtil.ensureStartSlash;
import static org.tmatesoft.svn.core.internal.util.SVNPathUtil.getRelativePath;
import static org.jetbrains.idea.svn.SvnUtil.getRelativeUrl;
import static org.tmatesoft.svn.core.internal.util.SVNPathUtil.isAncestor;
// TODO: This one seem to determine revision in which branch was created - copied from trunk.
@@ -41,18 +41,18 @@ public class FirstInBranch {
@NotNull private final SvnVcs myVcs;
@NotNull private final String myRepositoryRelativeBranchUrl;
@NotNull private final String myRepositoryRelativeTrunkUrl;
@NotNull private final String myRepositoryRoot;
@NotNull private final SVNURL myRepositoryRoot;
public FirstInBranch(@NotNull SvnVcs vcs, @NotNull String repositoryRoot, @NotNull String branchUrl, @NotNull String trunkUrl) {
public FirstInBranch(@NotNull SvnVcs vcs, @NotNull SVNURL repositoryRoot, @NotNull String branchUrl, @NotNull String trunkUrl) {
myVcs = vcs;
myRepositoryRoot = repositoryRoot;
myRepositoryRelativeBranchUrl = ensureStartSlash(getRelativePath(repositoryRoot, branchUrl));
myRepositoryRelativeTrunkUrl = ensureStartSlash(getRelativePath(repositoryRoot, trunkUrl));
myRepositoryRelativeBranchUrl = ensureStartSlash(getRelativeUrl(repositoryRoot.toDecodedString(), branchUrl));
myRepositoryRelativeTrunkUrl = ensureStartSlash(getRelativeUrl(repositoryRoot.toDecodedString(), trunkUrl));
}
@Nullable
public CopyData run() throws VcsException {
SvnTarget target = SvnTarget.fromURL(createUrl(myRepositoryRoot));
SvnTarget target = SvnTarget.fromURL(myRepositoryRoot);
HistoryClient client = ApplicationManager.getApplication().runReadAction((Computable<HistoryClient>)() -> {
if (myVcs.getProject().isDisposed()) return null;
return myVcs.getFactory(target).createHistoryClient();
@@ -19,6 +19,7 @@ import com.intellij.openapi.vcs.VcsException;
import com.intellij.util.Consumer;
import com.intellij.util.continuation.Where;
import org.jetbrains.annotations.NotNull;
import org.tmatesoft.svn.core.SVNURL;
public class LookForBranchOriginTask extends BaseMergeTask {
@@ -35,7 +36,7 @@ public class LookForBranchOriginTask extends BaseMergeTask {
@Override
public void run() {
String repoUrl = myMergeContext.getWcInfo().getRepoUrl();
SVNURL repoUrl = myMergeContext.getWcInfo().getRootInfo().getRepositoryUrlUrl();
String sourceUrl = myFromSource ? myMergeContext.getSourceUrl() : myMergeContext.getWcInfo().getRootUrl();
String targetUrl = myFromSource ? myMergeContext.getWcInfo().getRootUrl() : myMergeContext.getSourceUrl();
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnVcs;
import org.jetbrains.idea.svn.history.CopyData;
import org.jetbrains.idea.svn.history.FirstInBranch;
import org.tmatesoft.svn.core.SVNURL;
import java.io.DataInput;
import java.io.DataOutput;
@@ -175,9 +176,9 @@ public class SvnBranchPointsCalculator {
}
@Nullable
public WrapperInvertor calculateCopyPoint(@NotNull String repoUrl, @NotNull String sourceUrl, @NotNull String targetUrl)
public WrapperInvertor calculateCopyPoint(@NotNull SVNURL repoUrl, @NotNull String sourceUrl, @NotNull String targetUrl)
throws VcsException {
WrapperInvertor result = getBestHit(repoUrl, sourceUrl, targetUrl);
WrapperInvertor result = getBestHit(repoUrl.toDecodedString(), sourceUrl, targetUrl);
if (result == null) {
CopyData copyData = new FirstInBranch(myVcs, repoUrl, targetUrl, sourceUrl).run();
@@ -188,12 +189,12 @@ public class SvnBranchPointsCalculator {
? new BranchCopyData(sourceUrl, copyData.getCopySourceRevision(), targetUrl, copyData.getCopyTargetRevision())
: new BranchCopyData(targetUrl, copyData.getCopySourceRevision(), sourceUrl, copyData.getCopyTargetRevision());
persist(repoUrl, branchCopyData);
persist(repoUrl.toDecodedString(), branchCopyData);
result = new WrapperInvertor(!copyData.isTrunkSupposedCorrect(), branchCopyData);
}
}
logCopyData(repoUrl, sourceUrl, targetUrl, result);
logCopyData(repoUrl.toDecodedString(), sourceUrl, targetUrl, result);
return result;
}
@@ -78,7 +78,8 @@ public class BranchInfo {
if (myCopyRevison != null && Comparing.equal(myCopyRevison.getPath(), branchPath)) {
return myCopyRevison.getRevision();
}
myCopyRevison = new SvnMergeInfoCache.CopyRevison(myVcs, branchPath, myInfo.getRepoUrl(), myBranch.getUrl(), myInfo.getRootUrl());
myCopyRevison = new SvnMergeInfoCache.CopyRevison(myVcs, branchPath, myInfo.getRootInfo().getRepositoryUrlUrl(), myBranch.getUrl(),
myInfo.getRootUrl());
return -1;
}
@@ -35,6 +35,7 @@ import org.jetbrains.idea.svn.dialogs.WCInfoWithBranches;
import org.jetbrains.idea.svn.history.CopyData;
import org.jetbrains.idea.svn.history.FirstInBranch;
import org.jetbrains.idea.svn.history.SvnChangeList;
import org.tmatesoft.svn.core.SVNURL;
import java.util.Map;
@@ -123,7 +124,7 @@ public class SvnMergeInfoCache {
private final String myPath;
private volatile long myRevision;
CopyRevison(final SvnVcs vcs, final String path, final String repositoryRoot, final String branchUrl, final String trunkUrl) {
CopyRevison(final SvnVcs vcs, final String path, @NotNull SVNURL repositoryRoot, final String branchUrl, final String trunkUrl) {
myPath = path;
myRevision = -1;