From 8dbcd94740864a815737480ea96efbbc4a74ad22 Mon Sep 17 00:00:00 2001 From: irengrig Date: Thu, 15 Nov 2012 16:29:04 +0400 Subject: [PATCH] Subversion: test for svnkit to reproduce "IDEA-93475 IDEA forgets the lineage of file" --- .../org/jetbrains/idea/svn/Idea93475Test.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 plugins/svn4idea/src/org/jetbrains/idea/svn/Idea93475Test.java diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/Idea93475Test.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/Idea93475Test.java new file mode 100644 index 000000000000..bab89aa0848e --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/Idea93475Test.java @@ -0,0 +1,80 @@ +/* + * Copyright 2000-2012 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 org.jetbrains.idea.svn; + +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions; +import org.tmatesoft.svn.core.wc.*; + +import java.io.File; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 11/15/12 + * Time: 3:39 PM + */ +public class Idea93475Test { + private final static String ourWcPath = "C:\\TestProjects\\sortedProjects\\Subversion\\Sasha\\renameNewWithVersioned"; + + public static void main(String[] args) { + try { + SVNStatusClient client = new SVNStatusClient((ISVNRepositoryPool)null, new DefaultSVNOptions()); + File src = new File(ourWcPath, "cde\\text1.txt"); + assertStatus(client, src, SVNStatusType.STATUS_NORMAL); + + File src1 = new File(ourWcPath, "cde\\text2.txt"); + assertStatus(client, src, SVNStatusType.STATUS_NORMAL); + + File dir = new File(ourWcPath, "abc"); + assertStatus(client, dir, SVNStatusType.STATUS_ADDED); + + File dst = new File(dir, "text1.txt"); + File dst1 = new File(dir, "text2.txt"); + + SVNMoveClient moveClient = new SVNMoveClient((ISVNRepositoryPool)null, new DefaultSVNOptions()); + moveClient.doMove(src, dst); + moveClient.doMove(src1, dst1); + + assertStatus(client, dst, SVNStatusType.STATUS_ADDED); + assertStatus(client, dst1, SVNStatusType.STATUS_ADDED); + + assert client.doStatus(dst, false).getCopyFromURL() != null; + assert client.doStatus(dst1, false).getCopyFromURL() != null; + + // now rename the directory + final File renamedDir = new File(ourWcPath, "abc_renamed"); + moveClient.doMove(dir, renamedDir); + + File dstInRenamed = new File(renamedDir, "text1.txt"); + File dst1InRenamed = new File(renamedDir, "text2.txt"); + + assertStatus(client, dstInRenamed, SVNStatusType.STATUS_ADDED); + assertStatus(client, dst1InRenamed, SVNStatusType.STATUS_ADDED); + + assert client.doStatus(dstInRenamed, false).getCopyFromURL() != null; + assert client.doStatus(dst1InRenamed, false).getCopyFromURL() != null; + } + catch (SVNException e) { + e.printStackTrace(); + } + } + + private static void assertStatus(SVNStatusClient client, File src, final SVNStatusType type) throws SVNException { + SVNStatus status1 = client.doStatus(src, false); + assert status1 != null && type.equals(status1.getNodeStatus()); + } +}