Initialize mactfs CLI workspace
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
package org.jetbrains.tfsIntegration.core;
|
||||
|
||||
import jcifs.ntlmssp.*;
|
||||
import jcifs.util.Base64;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* @author ksafonov
|
||||
*/
|
||||
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"})
|
||||
public class NtlmDecoder {
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length != 2) {
|
||||
System.out.println("Usage: NtlmDecoder message_type message_text");
|
||||
}
|
||||
|
||||
int messageType = Integer.parseInt(args[0]);
|
||||
switch (messageType) {
|
||||
case 1:
|
||||
processMessage1(args[1]);
|
||||
break;
|
||||
case 2:
|
||||
processMessage2(args[1]);
|
||||
break;
|
||||
case 3:
|
||||
processMessage3(args[1]);
|
||||
break;
|
||||
default:
|
||||
System.out.println("Unknown messsage type, should be 1 or 2");
|
||||
}
|
||||
}
|
||||
|
||||
private static void processMessage1(String arg) {
|
||||
System.out.println("Message 1");
|
||||
try {
|
||||
Type1Message message = new Type1Message(Base64.decode(arg));
|
||||
printFlags(message);
|
||||
System.out.println("Domain: " + message.getSuppliedDomain());
|
||||
System.out.println("Workstation: " + message.getSuppliedWorkstation());
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void processMessage2(String arg) {
|
||||
System.out.println("Message 2");
|
||||
try {
|
||||
Type2Message message = new Type2Message(Base64.decode(arg));
|
||||
printFlags(message);
|
||||
byte[] targetInformation = message.getTargetInformation();
|
||||
if (targetInformation != null) {
|
||||
DataInputStream ds = new DataInputStream(new ByteArrayInputStream(targetInformation));
|
||||
loop:
|
||||
while (true) {
|
||||
short type = readShortLittleEndian(ds);
|
||||
short length = readShortLittleEndian(ds);
|
||||
byte[] contentBuffer = new byte[length];
|
||||
ds.readFully(contentBuffer, 0, length);
|
||||
// little-endian
|
||||
for (int i = 0; i < contentBuffer.length / 2; i++) {
|
||||
byte b = contentBuffer[i * 2];
|
||||
contentBuffer[i * 2] = contentBuffer[i * 2 + 1];
|
||||
contentBuffer[i * 2 + 1] = b;
|
||||
}
|
||||
|
||||
String value = new String(contentBuffer, Charset.forName("UTF-16"));
|
||||
switch (type) {
|
||||
case 1:
|
||||
System.out.print("Server name: ");
|
||||
break;
|
||||
case 2:
|
||||
System.out.print("Domain name: ");
|
||||
break;
|
||||
case 3:
|
||||
System.out.print("DNS host name: ");
|
||||
break;
|
||||
case 4:
|
||||
System.out.print("DNS domain name: ");
|
||||
break;
|
||||
case 0:
|
||||
break loop;
|
||||
default:
|
||||
System.out.print("Unknown (" + type + "): ");
|
||||
}
|
||||
System.out.println(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.out.println("No target information");
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void processMessage3(String arg) {
|
||||
System.out.println("Message 3");
|
||||
try {
|
||||
Type3Message message = new Type3Message(Base64.decode(arg));
|
||||
printFlags(message);
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void printFlags(NtlmMessage message) {
|
||||
int flags = message.getFlags();
|
||||
// jcifs.ntlmssp.NtlmFlags
|
||||
Field[] fields = NtlmFlagsEx.class.getDeclaredFields();
|
||||
System.out.println("Flags: 0x" + Integer.toHexString(flags));
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
int flag = field.getInt(NtlmFlags.class);
|
||||
if ((flags & flag) != 0) {
|
||||
System.out.println(" " + field.getName());
|
||||
flags &= ~flag;
|
||||
}
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (flags != 0) {
|
||||
System.out.println(" Unknown flag: 0x" + Integer.toHexString(flags));
|
||||
}
|
||||
}
|
||||
|
||||
private static short readShortLittleEndian(DataInputStream d) throws IOException {
|
||||
byte[] w = new byte[2];
|
||||
d.readFully(w, 0, 2);
|
||||
return (short)((w[1] & 0xff) << 8 | (w[0] & 0xff));
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
private interface NtlmFlagsEx {
|
||||
// from http://users.sosdg.org/~qiyong/lxr/source/fs/cifs/ntlmssp.h
|
||||
|
||||
int NTLMSSP_NEGOTIATE_UNICODE = 0x01; /* Text strings are unicode */
|
||||
int NTLMSSP_NEGOTIATE_OEM = 0x02; /* Text strings are in OEM */
|
||||
int NTLMSSP_REQUEST_TARGET = 0x04; /* Srv returns its auth realm */
|
||||
/* define reserved9 0x08 */
|
||||
int NTLMSSP_NEGOTIATE_SIGN = 0x0010; /* Request signing capability */
|
||||
int NTLMSSP_NEGOTIATE_SEAL = 0x0020; /* Request confidentiality */
|
||||
int NTLMSSP_NEGOTIATE_DGRAM = 0x0040;
|
||||
int NTLMSSP_NEGOTIATE_LM_KEY = 0x0080; /* Use LM session key */
|
||||
/* defined reserved 8 0x0100 */
|
||||
int NTLMSSP_NEGOTIATE_NTLM = 0x0200; /* NTLM authentication */
|
||||
int NTLMSSP_NEGOTIATE_NT_ONLY = 0x0400; /* Lanman not allowed */
|
||||
int NTLMSSP_ANONYMOUS = 0x0800;
|
||||
int NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED = 0x1000; /* reserved6 */
|
||||
int NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED = 0x2000;
|
||||
int NTLMSSP_NEGOTIATE_LOCAL_CALL = 0x4000; /* client/server same machine */
|
||||
int NTLMSSP_NEGOTIATE_ALWAYS_SIGN = 0x8000; /* Sign. All security levels */
|
||||
int NTLMSSP_TARGET_TYPE_DOMAIN = 0x10000;
|
||||
int NTLMSSP_TARGET_TYPE_SERVER = 0x20000;
|
||||
int NTLMSSP_TARGET_TYPE_SHARE = 0x40000;
|
||||
int NTLMSSP_NEGOTIATE_EXTENDED_SEC = 0x80000; /* NB:not related to NTLMv2 pwd*/
|
||||
/* int NTLMSSP_REQUEST_INIT_RESP 0x100000 */
|
||||
int NTLMSSP_NEGOTIATE_IDENTIFY = 0x100000;
|
||||
int NTLMSSP_REQUEST_ACCEPT_RESP = 0x200000; /* reserved5 */
|
||||
int NTLMSSP_REQUEST_NON_NT_KEY = 0x400000;
|
||||
int NTLMSSP_NEGOTIATE_TARGET_INFO = 0x800000;
|
||||
/* int reserved4 0x1000000 */
|
||||
int NTLMSSP_NEGOTIATE_VERSION = 0x2000000; /* we do not set */
|
||||
/* int reserved3 0x4000000 */
|
||||
/* int reserved2 0x8000000 */
|
||||
/* int reserved1 0x10000000 */
|
||||
int NTLMSSP_NEGOTIATE_128 = 0x20000000;
|
||||
int NTLMSSP_NEGOTIATE_KEY_XCH = 0x40000000;
|
||||
int NTLMSSP_NEGOTIATE_56 = 0x80000000;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CachedContentRevision implements ContentRevision {
|
||||
private final FilePath myFile;
|
||||
private final String myContent;
|
||||
private final VcsRevisionNumber myRevisionNumber;
|
||||
|
||||
|
||||
public CachedContentRevision(ContentRevision contentRevision) throws VcsException {
|
||||
myFile = contentRevision.getFile();
|
||||
myContent = myFile.isDirectory() ? null : contentRevision.getContent();
|
||||
myRevisionNumber = contentRevision.getRevisionNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getContent() {
|
||||
return myContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public FilePath getFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public VcsRevisionNumber getRevisionNumber() {
|
||||
return myRevisionNumber;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.TFSChangeList;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@SuppressWarnings({"ConstantConditions", "HardCodedStringLiteral"})
|
||||
public class ChangeHelper {
|
||||
|
||||
public static boolean containsAdded(Collection<Change> changes, VirtualFile file) {
|
||||
return containsAdded(changes, TfsFileUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
public static boolean containsAdded(Collection<Change> changes, VirtualFile file, String content) throws VcsException {
|
||||
final Change addChange = getAddChange(changes, TfsFileUtil.getFilePath(file));
|
||||
return addChange != null && content.equals(addChange.getAfterRevision().getContent());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Change getAddChange(Collection<Change> changes, FilePath file) {
|
||||
for (Change c : changes) {
|
||||
if (c.getBeforeRevision() == null && c.getAfterRevision() != null) {
|
||||
if (c.getAfterRevision().getFile().equals(file)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean containsAdded(Collection<Change> changes, FilePath file) {
|
||||
return getAddChange(changes, file) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Change getDeleteChange(Collection<Change> changes, FilePath file) {
|
||||
for (Change c : changes) {
|
||||
if (c.getBeforeRevision() != null && c.getAfterRevision() == null) {
|
||||
if (c.getBeforeRevision().getFile().equals(file)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean containsDeleted(Collection<Change> changes, FilePath file) {
|
||||
return getDeleteChange(changes, file) != null;
|
||||
}
|
||||
|
||||
public static boolean containsDeleted(Collection<Change> changes, FilePath file, String content) throws VcsException {
|
||||
final Change deleteChange = getDeleteChange(changes, file);
|
||||
return deleteChange != null && content.equals(deleteChange.getBeforeRevision().getContent());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Change getMoveChange(Collection<Change> changes, final FilePath from, final VirtualFile to) {
|
||||
return getMoveChange(changes, from, TfsFileUtil.getFilePath(to));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Change getMoveChange(Collection<Change> changes, final FilePath from, final FilePath to) {
|
||||
for (Change c : changes) {
|
||||
if (c.getBeforeRevision() != null && c.getAfterRevision() != null) {
|
||||
if (c.getBeforeRevision().getFile().equals(from) && c.getAfterRevision().getFile().equals(to)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean containsModified(Collection<Change> changes, VirtualFile file) {
|
||||
return getModificationChange(changes, TfsFileUtil.getFilePath(file)) != null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean containsModified(Collection<Change> changes, FilePath file) {
|
||||
return getModificationChange(changes, file) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Change getModificationChange(Collection<Change> changes, FilePath file) {
|
||||
for (Change c : changes) {
|
||||
if (c.getBeforeRevision() != null && c.getAfterRevision() != null) {
|
||||
if (c.getBeforeRevision().getFile().equals(file) &&
|
||||
c.getAfterRevision().getFile().equals(file) &&
|
||||
c.getType() == Change.Type.MODIFICATION) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void assertModified(Collection<Change> changes, FilePath file, String contentBefore, String contentAfter)
|
||||
throws VcsException {
|
||||
Change change = getModificationChange(changes, file);
|
||||
Assert.assertNotNull(file.getIOFile().getPath() + " expected to be modified", change);
|
||||
assertContent(change, contentBefore, contentAfter);
|
||||
}
|
||||
|
||||
public static void assertContent(Change change, String contentBefore, String contentAfter) throws VcsException {
|
||||
Assert.assertEquals(contentBefore, change.getBeforeRevision().getContent());
|
||||
Assert.assertEquals(contentAfter, change.getAfterRevision().getContent());
|
||||
}
|
||||
|
||||
public static String toString(final Collection<Change> changes, final VirtualFile rootPath) {
|
||||
String pathPrefix = rootPath.getPath();
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append("Changes:\n");
|
||||
for (Change change : changes) {
|
||||
s.append("\t");
|
||||
if (change.getType() == Change.Type.NEW) {
|
||||
s.append("Add: ").append(getPathRemainder(change.getAfterRevision().getFile(), rootPath));
|
||||
}
|
||||
else if (change.getType() == Change.Type.MODIFICATION) {
|
||||
s.append("Modified: ").append(getPathRemainder(change.getAfterRevision().getFile(), rootPath));
|
||||
}
|
||||
else if (change.getType() == Change.Type.MOVED) {
|
||||
s.append("Rename/move: ").append(getPathRemainder(change.getBeforeRevision().getFile(), rootPath)).append(" -> ")
|
||||
.append(getPathRemainder(change.getAfterRevision().getFile(), rootPath));
|
||||
}
|
||||
else {
|
||||
s.append("Remove: ").append(getPathRemainder(change.getBeforeRevision().getFile(), rootPath));
|
||||
}
|
||||
s.append("\n");
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public static String getPathRemainder(VirtualFile file, VirtualFile rootPath) {
|
||||
String pathPrefix = rootPath.getPresentableUrl();
|
||||
String path = file.getPresentableUrl();
|
||||
|
||||
if (pathPrefix == null || pathPrefix.length() == 0 || !path.startsWith(pathPrefix)) {
|
||||
return path.length() > 0 ? path : file.getPath();
|
||||
}
|
||||
else {
|
||||
if (path.length() == pathPrefix.length()) {
|
||||
return pathPrefix;
|
||||
}
|
||||
else {
|
||||
return path.length() > 0 ? path.substring(pathPrefix.length() + 1) : file.getPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPathRemainder(FilePath filePath, VirtualFile rootPath) {
|
||||
String path = FileUtil.toSystemIndependentName(filePath.getPath());
|
||||
String pathPrefix = FileUtil.toSystemIndependentName(rootPath.getPath());
|
||||
return path.startsWith(pathPrefix) ? path.substring(pathPrefix.length() + 1) : path;
|
||||
}
|
||||
|
||||
|
||||
public static void assertContains(final Collection<Change> subset, final Collection<Change> superset) throws VcsException {
|
||||
for (Change c : subset) {
|
||||
if (c.getType() == Change.Type.NEW) {
|
||||
Assert.assertTrue(containsAdded(superset, c.getAfterRevision().getFile()));
|
||||
}
|
||||
else if (c.getType() == Change.Type.DELETED) {
|
||||
Assert.assertTrue(containsDeleted(superset, c.getBeforeRevision().getFile()));
|
||||
}
|
||||
else if (c.getType() == Change.Type.MODIFICATION) {
|
||||
final Change modificationChange = getModificationChange(superset, c.getBeforeRevision().getFile());
|
||||
Assert.assertNotNull(modificationChange);
|
||||
assertContent(modificationChange, c.getBeforeRevision().getContent(), c.getAfterRevision().getContent());
|
||||
}
|
||||
else {
|
||||
if (TFSChangeList.IDEADEV_29451_WORKAROUND) {
|
||||
final Change deleteChange = getDeleteChange(superset, c.getBeforeRevision().getFile());
|
||||
final Change addChange = getAddChange(superset, c.getAfterRevision().getFile());
|
||||
if (!c.getBeforeRevision().getFile().isDirectory()) {
|
||||
Assert.assertEquals(c.getBeforeRevision().getContent(), deleteChange.getBeforeRevision().getContent());
|
||||
Assert.assertEquals(c.getAfterRevision().getContent(), addChange.getAfterRevision().getContent());
|
||||
}
|
||||
}
|
||||
else {
|
||||
final Change moveChange = getMoveChange(superset, c.getBeforeRevision().getFile(), c.getAfterRevision().getFile());
|
||||
Assert.assertEquals(c.getBeforeRevision().getFile().isDirectory(), moveChange.getBeforeRevision().getFile().isDirectory());
|
||||
|
||||
if (!c.getBeforeRevision().getFile().isDirectory()) {
|
||||
Assert.assertEquals(c.getBeforeRevision().getContent(), moveChange.getBeforeRevision().getContent());
|
||||
Assert.assertEquals(c.getAfterRevision().getContent(), moveChange.getAfterRevision().getContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Change getChangeWithCachedContent(Change change) throws VcsException {
|
||||
ContentRevision beforeRevision = change.getBeforeRevision() != null ? new CachedContentRevision(change.getBeforeRevision()) : null;
|
||||
ContentRevision afterRevision = change.getAfterRevision() != null ? new CachedContentRevision(change.getAfterRevision()) : null;
|
||||
return new Change(beforeRevision, afterRevision, change.getFileStatus());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.ThrowableConsumer;
|
||||
import gnu.trove.Equality;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsUtil;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ConsumeInPartsTest extends TestCase {
|
||||
|
||||
private static class TestConsumer implements ThrowableConsumer<List<String>, RuntimeException> {
|
||||
private final List<String[]> myResults = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void consume(List<String> strings) {
|
||||
myResults.add(ArrayUtilRt.toStringArray(strings));
|
||||
}
|
||||
|
||||
public void assertEquals(String[][] expected) {
|
||||
String[][] actual = myResults.toArray(new String[myResults.size()][]);
|
||||
boolean equals = ArrayUtil.equals(actual, expected, (Equality<String[]>)(o1, o2) -> Arrays.equals(o1, o2));
|
||||
|
||||
StringBuilder message = new StringBuilder("Expected: ");
|
||||
toString(expected, message);
|
||||
message.append("\nActual: ");
|
||||
toString(actual, message);
|
||||
Assert.assertTrue(message.toString(), equals);
|
||||
}
|
||||
|
||||
private void toString(String[][] data, StringBuilder s) {
|
||||
for (String[] item : data) {
|
||||
s.append("{");
|
||||
boolean first = true;
|
||||
for (String i : item) {
|
||||
if (!first) {
|
||||
s.append(",");
|
||||
}
|
||||
first = false;
|
||||
s.append(i);
|
||||
}
|
||||
s.append("}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testEmpty() {
|
||||
TestConsumer consumer = new TestConsumer();
|
||||
List<String> items = Arrays.asList();
|
||||
|
||||
TfsUtil.consumeInParts(items, 5, consumer);
|
||||
consumer.assertEquals(new String[][]{});
|
||||
}
|
||||
|
||||
public void test1() {
|
||||
TestConsumer consumer = new TestConsumer();
|
||||
List<String> items = Arrays.asList("a");
|
||||
|
||||
TfsUtil.consumeInParts(items, 5, consumer);
|
||||
consumer.assertEquals(new String[][]{{"a"}});
|
||||
}
|
||||
|
||||
public void test2() {
|
||||
TestConsumer consumer = new TestConsumer();
|
||||
List<String> items = Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
||||
|
||||
TfsUtil.consumeInParts(items, 5, consumer);
|
||||
consumer.assertEquals(new String[][]{{"1", "2", "3", "4", "5"}, {"6", "7", "8", "9", "10"}});
|
||||
}
|
||||
|
||||
public void test3() {
|
||||
TestConsumer consumer = new TestConsumer();
|
||||
List<String> items = Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
|
||||
|
||||
TfsUtil.consumeInParts(items, 5, consumer);
|
||||
consumer.assertEquals(new String[][]{{"1", "2", "3", "4", "5"}, {"6", "7", "8", "9", "10"}, {"11"}});
|
||||
}
|
||||
|
||||
public void test4() {
|
||||
TestConsumer consumer = new TestConsumer();
|
||||
List<String> items = Arrays.asList("1", "2", "3", "4", "5");
|
||||
|
||||
TfsUtil.consumeInParts(items, 10, consumer);
|
||||
consumer.assertEquals(new String[][]{{"1", "2", "3", "4", "5"}});
|
||||
}
|
||||
|
||||
public void test5() {
|
||||
TestConsumer consumer = new TestConsumer();
|
||||
List<String> items = Arrays.asList("1", "2", "3", "4", "5");
|
||||
|
||||
TfsUtil.consumeInParts(items, 1, consumer);
|
||||
consumer.assertEquals(new String[][]{{"1"}, {"2"}, {"3"}, {"4"}, {"5"}});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.jetbrains.tfsIntegration.tests.TFSTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class MovedFile extends TFSTestCase {
|
||||
|
||||
// moved file (up to date sandbox root\file_original.txt -> up to date sandbox root\subfolder\subfolder2\file_moved.txt)
|
||||
|
||||
@Test
|
||||
public void testMovedFileFromUpToDateToUpToDate() throws VcsException {
|
||||
final String fileContent = "content";
|
||||
final String filenameOriginal = "file_original.txt";
|
||||
FilePath fileOriginal = TfsFileUtil.getFilePath(createFileInCommand(mySandboxRoot, filenameOriginal, fileContent));
|
||||
FilePath subfolder = TfsFileUtil.getFilePath(createDirInCommand(mySandboxRoot, "subfolder"));
|
||||
FilePath subfolder2 = TfsFileUtil.getFilePath(createDirInCommand(subfolder.getVirtualFile(), "subfolder2"));
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
|
||||
commit(getChanges().getChanges(), "test");
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFile(fileOriginal, fileContent, false);
|
||||
|
||||
final String filenameMoved = "file_moved.txt";
|
||||
moveFileInCommand(fileOriginal, subfolder2.getVirtualFile());
|
||||
rename(getChildPath(subfolder2, filenameOriginal), filenameMoved);
|
||||
FilePath fileMoved = getChildPath(subfolder2, filenameMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFile(fileMoved, fileContent, false);
|
||||
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(fileOriginal, fileMoved);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFile(fileOriginal, fileContent, false);
|
||||
|
||||
moveFileInCommand(fileOriginal, subfolder2.getVirtualFile());
|
||||
rename(getChildPath(subfolder2, filenameOriginal), filenameMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFile(fileMoved, fileContent, false);
|
||||
|
||||
commit(getChanges().getChanges(), "test");
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFile(fileMoved, fileContent, false);
|
||||
|
||||
final int latestRevision = getLatestRevisionNumber(mySandboxRoot);
|
||||
|
||||
update(mySandboxRoot, latestRevision - 1);
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFile(fileOriginal, fileContent, false);
|
||||
|
||||
update(mySandboxRoot, latestRevision);
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFile(fileMoved, fileContent, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.jetbrains.tfsIntegration.tests.TFSTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MovedFolder extends TFSTestCase {
|
||||
|
||||
// moved folder (up to date sandbox root\Folder_Original -> up to date sandbox root\subfolder\subfolder2\Folder_Moved)
|
||||
|
||||
@Test
|
||||
public void testMovedFolderFromUpToDateToUpToDate() throws VcsException {
|
||||
final String foldernameOriginal = "Folder_Original";
|
||||
FilePath folderOriginal = TfsFileUtil.getFilePath(createDirInCommand(mySandboxRoot, foldernameOriginal));
|
||||
FilePath subfolder = TfsFileUtil.getFilePath(createDirInCommand(mySandboxRoot, "subfolder"));
|
||||
FilePath subfolder2 = TfsFileUtil.getFilePath(createDirInCommand(subfolder.getVirtualFile(), "subfolder2"));
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFolder(folderOriginal, 0);
|
||||
|
||||
commit(getChanges().getChanges(), "test");
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFolder(folderOriginal, 0);
|
||||
|
||||
final String foldernameMoved = "Folder_Moved";
|
||||
moveFileInCommand(folderOriginal, subfolder2.getVirtualFile());
|
||||
rename(getChildPath(subfolder2, foldernameOriginal), foldernameMoved);
|
||||
FilePath folderMoved = getChildPath(subfolder2, foldernameMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFolder(folderMoved, 0);
|
||||
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(folderOriginal, folderMoved);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFolder(folderOriginal, 0);
|
||||
|
||||
moveFileInCommand(folderOriginal, subfolder2.getVirtualFile());
|
||||
rename(getChildPath(subfolder2, foldernameOriginal), foldernameMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFolder(folderMoved, 0);
|
||||
|
||||
commit(getChanges().getChanges(), "test");
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFolder(folderMoved, 0);
|
||||
|
||||
final int latestRevision = getLatestRevisionNumber(mySandboxRoot);
|
||||
|
||||
update(mySandboxRoot, latestRevision - 1);
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFolder(folderOriginal, 0);
|
||||
|
||||
update(mySandboxRoot, latestRevision);
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFolder(folderMoved, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class MovedModifiedFile extends TFSTestCase {
|
||||
|
||||
// moved and modified file (up to date sandbox root\file_original.txt -> up to date sandbox root\subfolder\subfolder2\file_moved.txt)
|
||||
|
||||
@Test
|
||||
public void testMovedModifiedFileFromUpToDateToUpToDate() throws VcsException, IOException {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
|
||||
final String fileContentOriginal = "content_original";
|
||||
final String filenameOriginal = "file_original.txt";
|
||||
FilePath fileOriginal = TfsFileUtil.getFilePath(createFileInCommand(mySandboxRoot, filenameOriginal, fileContentOriginal));
|
||||
FilePath subfolder = TfsFileUtil.getFilePath(createDirInCommand(mySandboxRoot, "subfolder"));
|
||||
FilePath subfolder2 = TfsFileUtil.getFilePath(createDirInCommand(subfolder.getVirtualFile(), "subfolder2"));
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
commit(getChanges().getChanges(), "test");
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFile(fileOriginal, fileContentOriginal, false);
|
||||
|
||||
final String filenameMoved = "file_moved.txt";
|
||||
moveFileInCommand(fileOriginal, subfolder2.getVirtualFile());
|
||||
rename(getChildPath(subfolder2, filenameOriginal), filenameMoved);
|
||||
FilePath fileMoved = getChildPath(subfolder2, filenameMoved);
|
||||
editFiles(VcsUtil.getVirtualFile(fileMoved.getIOFile()));
|
||||
final String fileContentModified = "content_modified";
|
||||
setFileContent(fileMoved, fileContentModified);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFile(fileMoved, fileContentModified, true);
|
||||
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(fileOriginal, fileMoved, fileContentOriginal, fileContentModified);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFile(fileOriginal, fileContentOriginal, false);
|
||||
|
||||
moveFileInCommand(fileOriginal, subfolder2.getVirtualFile());
|
||||
rename(getChildPath(subfolder2, filenameOriginal), filenameMoved);
|
||||
editFiles(VcsUtil.getVirtualFile(fileMoved.getIOFile()));
|
||||
setFileContent(fileMoved, fileContentModified);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFile(fileMoved, fileContentModified, true);
|
||||
|
||||
commit(getChanges().getChanges(), "test");
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFile(fileMoved, fileContentModified, false);
|
||||
|
||||
final int latestRevision = getLatestRevisionNumber(mySandboxRoot);
|
||||
|
||||
update(mySandboxRoot, latestRevision - 1);
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 0);
|
||||
assertFile(fileOriginal, fileContentOriginal, false);
|
||||
|
||||
update(mySandboxRoot, latestRevision);
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(subfolder, 1);
|
||||
assertFolder(subfolder2, 1);
|
||||
assertFile(fileMoved, fileContentModified, false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,755 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.committed.MockAbstractVcs;
|
||||
import com.intellij.openapi.vcs.checkin.CheckinChangeListSpecificComponent;
|
||||
import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
|
||||
import com.intellij.openapi.vcs.rollback.RollbackProgressListener;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
import com.intellij.openapi.vcs.update.UpdateSession;
|
||||
import com.intellij.openapi.vcs.update.UpdatedFiles;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
|
||||
import com.intellij.testFramework.fixtures.TempDirTestFixture;
|
||||
import com.intellij.testFramework.vcs.AbstractJunitVcsTestCase;
|
||||
import com.intellij.vcs.commit.CommitWorkflowHandler;
|
||||
import com.intellij.vcs.commit.NullCommitWorkflowHandler;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.config.TfsServerConnectionHelper;
|
||||
import org.jetbrains.tfsIntegration.core.TFSChangeList;
|
||||
import org.jetbrains.tfsIntegration.core.TFSProjectConfiguration;
|
||||
import org.jetbrains.tfsIntegration.core.TFSVcs;
|
||||
import org.jetbrains.tfsIntegration.core.TfsBeansHolder;
|
||||
import org.jetbrains.tfsIntegration.core.configuration.Credentials;
|
||||
import org.jetbrains.tfsIntegration.core.configuration.TFSConfigurationManager;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.*;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.conflicts.ConflictsEnvironment;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.operations.ApplyGetOperations;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.version.ChangesetVersionSpec;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings({"ConstantConditions", "HardCodedStringLiteral"})
|
||||
public abstract class TFSTestCase extends AbstractJunitVcsTestCase {
|
||||
|
||||
protected enum TfsServerVersion {
|
||||
TFS_2005_RTM,
|
||||
TFS_2005_SP1,
|
||||
TFS_2008
|
||||
}
|
||||
|
||||
protected static final TfsServerVersion SERVER_VERSION = TfsServerVersion.TFS_2008;
|
||||
|
||||
private static final String SERVER = "http://tfs2010-e:8080/tfs/IDEATests";
|
||||
private static final String SERVER_ROOT = "$/Test";
|
||||
private static final String USER = "IDEATfsTest";
|
||||
private static final String DOMAIN = "TFS2010-E";
|
||||
private static final String PASSWORD = "mwxXU2gyaA";
|
||||
private static final String PROXY = null; //"http://tfs-proxy-01:8081/";
|
||||
|
||||
|
||||
private static final String WORKSPACE_NAME_PREFIX = "__testWorkspace_";
|
||||
private static final String SANDBOX_PREFIX = "sandbox_";
|
||||
|
||||
|
||||
private TempDirTestFixture myTempDirFixture;
|
||||
protected WorkspaceInfo myTestWorkspace;
|
||||
protected VirtualFile mySandboxRoot;
|
||||
private Credentials myOriginalServerCredentials;
|
||||
private URI myOriginalProxyUri;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
Workstation.PRESERVE_CONFIG_FILE = true;
|
||||
|
||||
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
|
||||
myTempDirFixture = fixtureFactory.createTempDirTestFixture();
|
||||
myTempDirFixture.setUp();
|
||||
|
||||
File localRoot = new File(myTempDirFixture.getTempDirPath());
|
||||
localRoot.mkdir();
|
||||
|
||||
|
||||
initProject(localRoot, getTestName());
|
||||
mySandboxRoot = createDirInCommand(myWorkingCopyDir, SANDBOX_PREFIX +
|
||||
Workstation.getComputerName() +
|
||||
"_" +
|
||||
localRoot.getName() +
|
||||
"_" +
|
||||
Calendar.getInstance().getTimeInMillis(), true);
|
||||
|
||||
prepareServer();
|
||||
|
||||
activateVCS(TFSVcs.TFS_NAME);
|
||||
|
||||
createNewWorkspaceFor(localRoot);
|
||||
|
||||
createServerFolder(TfsFileUtil.getFilePath(mySandboxRoot), "sandbox " + mySandboxRoot.getName() + " created");
|
||||
|
||||
ApplyGetOperations.setLocalConflictHandlingType(ApplyGetOperations.LocalConflictHandlingType.ERROR);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
ConflictsEnvironment.setConflictsHandler(null);
|
||||
ConflictsEnvironment.setContentMerger(null);
|
||||
ConflictsEnvironment.setNameMerger(null);
|
||||
}
|
||||
|
||||
private void prepareServer() throws URISyntaxException, TfsException {
|
||||
final URI serverUri = new URI(SERVER);
|
||||
|
||||
myOriginalServerCredentials = TFSConfigurationManager.getInstance().getCredentials(serverUri);
|
||||
myOriginalProxyUri = TFSConfigurationManager.getInstance().getProxyUri(serverUri);
|
||||
|
||||
boolean serverFound = false;
|
||||
for (ServerInfo s : Workstation.getInstance().getServers()) {
|
||||
if (!serverUri.equals(s.getUri())) {
|
||||
Workstation.getInstance().removeServer(s);
|
||||
}
|
||||
else {
|
||||
serverFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
final Credentials testCredentials = new Credentials(USER, DOMAIN, PASSWORD, false, Credentials.Type.NtlmExplicit);
|
||||
TFSConfigurationManager.getInstance().storeCredentials(serverUri, testCredentials);
|
||||
if (!serverFound) {
|
||||
TfsServerConnectionHelper.ensureAuthenticated(myProject, serverUri, true);
|
||||
ServerInfo newServer = new ServerInfo(serverUri, "test", new TfsBeansHolder(serverUri));
|
||||
Workstation.getInstance().addServer(newServer);
|
||||
}
|
||||
|
||||
TFSConfigurationManager.getInstance().storeCredentials(serverUri, testCredentials);
|
||||
TFSConfigurationManager.getInstance().setProxyUri(serverUri, PROXY != null ? new URI(PROXY) : null);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
ConflictsEnvironment.setConflictsHandler(null);
|
||||
ConflictsEnvironment.setContentMerger(null);
|
||||
ConflictsEnvironment.setNameMerger(null);
|
||||
|
||||
try {
|
||||
removeWorkspace(myTestWorkspace);
|
||||
}
|
||||
finally {
|
||||
if (myOriginalServerCredentials != null) {
|
||||
TFSConfigurationManager.getInstance().storeCredentials(new URI(SERVER), myOriginalServerCredentials);
|
||||
}
|
||||
}
|
||||
|
||||
TFSConfigurationManager.getInstance().setProxyUri(new URI(SERVER), myOriginalProxyUri);
|
||||
|
||||
tearDownProject();
|
||||
if (myTempDirFixture != null) {
|
||||
myTempDirFixture.tearDown();
|
||||
myTempDirFixture = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected TFSVcs getVcs() {
|
||||
return TFSVcs.getInstance(myProject);
|
||||
}
|
||||
|
||||
protected void doActionSilently(final VcsConfiguration.StandardConfirmation op) {
|
||||
setStandardConfirmation(TFSVcs.TFS_NAME, op, VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY);
|
||||
}
|
||||
|
||||
protected void doNothingSilently(final VcsConfiguration.StandardConfirmation op) {
|
||||
setStandardConfirmation(TFSVcs.TFS_NAME, op, VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY);
|
||||
}
|
||||
|
||||
private void createNewWorkspaceFor(File root) throws URISyntaxException, TfsException {
|
||||
final String workspaceName = WORKSPACE_NAME_PREFIX + Workstation.getComputerName();
|
||||
final ServerInfo server = Workstation.getInstance().getServer(new URI(SERVER));
|
||||
server.refreshWorkspacesForCurrentOwnerAndComputer(myProject, true);
|
||||
for (WorkspaceInfo workspace : server.getWorkspacesForCurrentOwnerAndComputer()) {
|
||||
if (workspace.getName().equals(workspaceName)) {
|
||||
removeWorkspace(workspace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
myTestWorkspace = new WorkspaceInfo(server, DOMAIN + "\\" + USER, Workstation.getComputerName());
|
||||
myTestWorkspace.setName(workspaceName);
|
||||
myTestWorkspace.addWorkingFolderInfo(new WorkingFolderInfo(WorkingFolderInfo.Status.Active, VcsUtil.getFilePath(root), SERVER_ROOT));
|
||||
myTestWorkspace.saveToServer(myProject, null);
|
||||
}
|
||||
|
||||
private void removeWorkspace(WorkspaceInfo workspace) throws URISyntaxException, TfsException {
|
||||
final ServerInfo server = Workstation.getInstance().getServer(new URI(SERVER));
|
||||
if (server != null) {
|
||||
server.refreshWorkspacesForCurrentOwnerAndComputer(myProject, true);
|
||||
server.deleteWorkspace(workspace, myProject, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected TestChangeListBuilder getChanges() throws VcsException {
|
||||
return getChanges(mySandboxRoot);
|
||||
}
|
||||
|
||||
private TestChangeListBuilder getChanges(VirtualFile root) throws VcsException {
|
||||
ChangeListManagerImpl.getInstanceImpl(myProject).ensureUpToDate();
|
||||
TestChangeListBuilder changeListBuilder = new TestChangeListBuilder(mySandboxRoot, myProject);
|
||||
VcsDirtyScopeImpl scope = new VcsDirtyScopeImpl(new MockAbstractVcs(myProject));
|
||||
getVcs().getChangeProvider().getChanges(scope, changeListBuilder, new EmptyProgressIndicator(), null);
|
||||
return changeListBuilder;
|
||||
}
|
||||
|
||||
private void createServerFolder(FilePath path, String comment) throws VcsException {
|
||||
try {
|
||||
ItemPath itemPath = new ItemPath(path, myTestWorkspace.findServerPathsByLocalPath(path, false, myProject).iterator().next());
|
||||
final ResultWithFailures<GetOperation> addResult = myTestWorkspace.getServer().getVCS()
|
||||
.scheduleForAddition(myTestWorkspace.getName(), myTestWorkspace.getOwnerName(), Collections.singletonList(itemPath), myProject,
|
||||
null);
|
||||
if (!addResult.getFailures().isEmpty()) {
|
||||
throw TfsUtil.collectExceptions(TfsUtil.getVcsExceptions(addResult.getFailures()));
|
||||
}
|
||||
|
||||
final ResultWithFailures<CheckinResult> checkinResult = myTestWorkspace.getServer().getVCS()
|
||||
.checkIn(myTestWorkspace.getName(), myTestWorkspace.getOwnerName(), Collections.singletonList(itemPath.getServerPath()), comment,
|
||||
Collections.emptyMap(), Collections.emptyList(), null, myProject,
|
||||
null);
|
||||
if (!checkinResult.getFailures().isEmpty()) {
|
||||
throw TfsUtil.collectExceptions(TfsUtil.getVcsExceptions(checkinResult.getFailures()));
|
||||
}
|
||||
}
|
||||
catch (TfsException e) {
|
||||
throw new VcsException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void commit(final Collection<Change> changes, final String comment) {
|
||||
CheckinEnvironment env = getVcs().getCheckinEnvironment();
|
||||
RefreshableOnComponent panel = env.createCommitOptions(new CheckinProjectPanel() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CommitWorkflowHandler getCommitWorkflowHandler() {
|
||||
return NullCommitWorkflowHandler.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDiffs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<VirtualFile> getVirtualFiles() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Change> getSelectedChanges() {
|
||||
return changes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<File> getFiles() {
|
||||
Collection<File> result = new ArrayList<>();
|
||||
for (Change change : changes) {
|
||||
if (change.getAfterRevision() != null) {
|
||||
result.add(change.getAfterRevision().getFile().getIOFile());
|
||||
}
|
||||
else {
|
||||
result.add(change.getBeforeRevision().getFile().getIOFile());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean vcsIsAffected(String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<AbstractVcs> getAffectedVcses() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<VirtualFile> getRoots() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCommitMessage(String currentDescription) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCommitMessage() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommitActionName() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveState() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState() {
|
||||
}
|
||||
}, new CommitContext());
|
||||
((CheckinChangeListSpecificComponent)panel).onChangeListSelected(new LocalChangeList() {
|
||||
@Override
|
||||
public Collection<Change> getChanges() {
|
||||
return changes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(@NotNull String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComment(String comment) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadOnly(boolean isReadOnly) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList copy() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
final List<VcsException> errors = env.commit(new ArrayList<>(changes), comment);
|
||||
Assert.assertTrue(getMessage(errors), errors.isEmpty());
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void commitThrowException(final Collection<Change> changes, final String comment) throws VcsException {
|
||||
final List<VcsException> errors = getVcs().getCheckinEnvironment().commit(new ArrayList<>(changes), comment);
|
||||
refreshAll();
|
||||
if (!errors.isEmpty()) {
|
||||
throw new VcsException(getMessage(errors));
|
||||
}
|
||||
}
|
||||
|
||||
protected void commit(Change change, final String comment) {
|
||||
commit(Collections.singletonList(change), comment);
|
||||
}
|
||||
|
||||
protected void rollback(final Change change) {
|
||||
rollback(Collections.singletonList(change));
|
||||
}
|
||||
|
||||
protected void rollback(final Collection<Change> changes) {
|
||||
final List<VcsException> errors = new ArrayList<>();
|
||||
getVcs().getRollbackEnvironment().rollbackChanges(new ArrayList<>(changes), errors, RollbackProgressListener.EMPTY);
|
||||
Assert.assertTrue(getMessage(errors), errors.isEmpty());
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void rollbackAll(TestChangeListBuilder builder) {
|
||||
final List<VcsException> errors = new ArrayList<>();
|
||||
getVcs().getRollbackEnvironment().rollbackMissingFileDeletion(builder.getLocallyDeleted(), errors, RollbackProgressListener.EMPTY);
|
||||
getVcs().getRollbackEnvironment().rollbackChanges(builder.getChanges(), errors, RollbackProgressListener.EMPTY);
|
||||
// ??? errors.addAll(getVcs().getRollbackEnvironment().rollbackIfUnchanged());
|
||||
getVcs().getRollbackEnvironment().rollbackModifiedWithoutCheckout(builder.getHijackedFiles(), errors, RollbackProgressListener.EMPTY);
|
||||
Assert.assertTrue(getMessage(errors), errors.isEmpty());
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void scheduleForAddition(VirtualFile... files) {
|
||||
final List<VcsException> errors = getVcs().getCheckinEnvironment().scheduleUnversionedFilesForAddition(Arrays.asList(files));
|
||||
Assert.assertTrue(getMessage(errors), errors.isEmpty());
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void scheduleForAddition(FilePath... files) {
|
||||
List<VirtualFile> vfiles = new ArrayList<>(files.length);
|
||||
for (FilePath f : files) {
|
||||
vfiles.add(VcsUtil.getVirtualFile(f.getIOFile()));
|
||||
}
|
||||
scheduleForAddition(VfsUtilCore.toVirtualFileArray(vfiles));
|
||||
}
|
||||
|
||||
protected void scheduleForDeletion(FilePath... files) {
|
||||
final List<VcsException> errors = getVcs().getCheckinEnvironment().scheduleMissingFileForDeletion(Arrays.asList(files));
|
||||
Assert.assertTrue(getMessage(errors), errors.isEmpty());
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void scheduleForDeletion(final VirtualFile file) {
|
||||
scheduleForDeletion(TfsFileUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
protected void rollbackHijacked(VirtualFile... files) {
|
||||
rollbackHijacked(Arrays.asList(files));
|
||||
}
|
||||
|
||||
protected void rollbackHijacked(List<VirtualFile> files) {
|
||||
final List<VcsException> errors = new ArrayList<>();
|
||||
getVcs().getRollbackEnvironment().rollbackModifiedWithoutCheckout(files, errors, RollbackProgressListener.EMPTY);
|
||||
Assert.assertTrue(getMessage(errors), errors.isEmpty());
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void refreshAll() {
|
||||
TfsFileUtil.refreshAndMarkDirty(myProject, Collections.singletonList(mySandboxRoot), false);
|
||||
ChangeListManagerImpl.getInstanceImpl(myProject).ensureUpToDate();
|
||||
}
|
||||
|
||||
protected void editFiles(VirtualFile... files) throws VcsException {
|
||||
getVcs().getEditFileProvider().editFiles(files);
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void editFiles(FilePath... files) throws VcsException {
|
||||
VirtualFile[] vf = new VirtualFile[files.length];
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
vf[i] = VcsUtil.getVirtualFile(files[i].getIOFile());
|
||||
}
|
||||
editFiles(vf);
|
||||
}
|
||||
|
||||
protected static String getContent(VirtualFile file) {
|
||||
return new CurrentContentRevision(TfsFileUtil.getFilePath(file)).getContent();
|
||||
}
|
||||
|
||||
protected static String getContent(FilePath file) {
|
||||
return new CurrentContentRevision(file).getContent();
|
||||
}
|
||||
|
||||
protected void deleteFileExternally(FilePath file) {
|
||||
deleteFileExternally(VcsUtil.getVirtualFile(file.getIOFile()));
|
||||
}
|
||||
|
||||
protected void deleteFileExternally(VirtualFile file) {
|
||||
final File ioFile = new File(file.getPath());
|
||||
Assert.assertTrue(FileUtil.delete(ioFile));
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void clearReadonlyAndRenameExternally(final VirtualFile file, final String newName) {
|
||||
FileUtil.setReadOnlyAttribute(file.getPath(), false);
|
||||
final File from = new File(file.getPath());
|
||||
final File to = new File(from.getParent(), newName);
|
||||
Assert.assertTrue(from.renameTo(to));
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
|
||||
protected static VirtualFile getVirtualFile(final VirtualFile parent, final String newName) {
|
||||
return VcsUtil.getVirtualFile(new File(new File(parent.getPath()), newName));
|
||||
}
|
||||
|
||||
protected void clearReadonlyStatusExternally(VirtualFile... files) {
|
||||
for (VirtualFile file : files) {
|
||||
FileUtil.setReadOnlyAttribute(file.getPath(), false);
|
||||
}
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void clearReadonlyStatusExternally(FilePath... files) {
|
||||
for (FilePath file : files) {
|
||||
FileUtil.setReadOnlyAttribute(file.getPath(), false);
|
||||
refreshAll();
|
||||
}
|
||||
}
|
||||
|
||||
protected void rename(final FilePath file, final String newName) {
|
||||
rename(VcsUtil.getVirtualFile(file.getIOFile()), newName);
|
||||
}
|
||||
|
||||
protected void rename(final VirtualFile file, final String newName) {
|
||||
renameFileInCommand(file, newName);
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile createFileInCommand(@NotNull final VirtualFile parent, @NotNull final String name, @Nullable final String content) {
|
||||
final VirtualFile result = super.createFileInCommand(parent, name, content);
|
||||
assertFile(result, content, true);
|
||||
refreshAll();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected VirtualFile createFileInCommand(final FilePath path, @Nullable final String content) {
|
||||
return createFileInCommand(path.getParentPath(), path.getName(), content);
|
||||
}
|
||||
|
||||
protected VirtualFile createFileInCommand(final FilePath parent, final String name, @Nullable final String content) {
|
||||
return createFileInCommand(VcsUtil.getVirtualFile(parent.getIOFile()), name, content);
|
||||
}
|
||||
|
||||
private VirtualFile createDirInCommand(final VirtualFile parent, final String name, boolean suppressRefresh) {
|
||||
final VirtualFile result = super.createDirInCommand(parent, name);
|
||||
if (!suppressRefresh) {
|
||||
refreshAll();
|
||||
}
|
||||
assertFolder(getChildPath(parent, name), 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected VirtualFile createDirInCommand(final FilePath path) {
|
||||
return createDirInCommand(path.getParentPath(), path.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile createDirInCommand(final VirtualFile parent, final String name) {
|
||||
return createDirInCommand(parent, name, false);
|
||||
}
|
||||
|
||||
protected VirtualFile createDirInCommand(final FilePath parent, final String name) {
|
||||
return createDirInCommand(VcsUtil.getVirtualFile(parent.getIOFile()), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renameFileInCommand(final VirtualFile file, final String newName) {
|
||||
super.renameFileInCommand(file, newName);
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void renameFileInCommand(final FilePath file, final String newName) {
|
||||
renameFileInCommand(VcsUtil.getVirtualFile(file.getIOFile()), newName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveFileInCommand(final VirtualFile file, final VirtualFile newParent) {
|
||||
super.moveFileInCommand(file, newParent);
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void moveFileInCommand(final FilePath file, final VirtualFile newParent) {
|
||||
moveFileInCommand(VcsUtil.getVirtualFile(file.getIOFile()), newParent);
|
||||
}
|
||||
|
||||
protected void moveFileInCommand(final FilePath file, final FilePath newParent) {
|
||||
final VirtualFile newParentFile = VcsUtil.getVirtualFile(newParent.getIOFile());
|
||||
Assert.assertNotNull("Target folder " + newParent.getPresentableUrl() + " not exists", newParentFile);
|
||||
moveFileInCommand(file, newParentFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFileInCommand(final VirtualFile file) {
|
||||
super.deleteFileInCommand(file);
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void deleteFileInCommand(final FilePath file) {
|
||||
deleteFileInCommand(VcsUtil.getVirtualFile(file.getIOFile()));
|
||||
}
|
||||
|
||||
protected void commit() throws VcsException {
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
}
|
||||
|
||||
protected void assertFileStatus(VirtualFile file, FileStatus expectedStatus) {
|
||||
Assert.assertEquals(expectedStatus, FileStatusManager.getInstance(myProject).getStatus(file));
|
||||
}
|
||||
|
||||
|
||||
protected static String getMessage(Collection<VcsException> errors) {
|
||||
String result = "";
|
||||
for (VcsException error : errors) {
|
||||
result += error + "\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected static FilePath replaceInPath(FilePath path, FilePath folderFrom, FilePath folderTo) {
|
||||
String from = folderFrom.getIOFile().getPath();
|
||||
String to = folderTo.getIOFile().getPath();
|
||||
|
||||
String result = path.getIOFile().getPath().replace(from, to);
|
||||
return VcsUtil.getFilePath(result);
|
||||
}
|
||||
|
||||
protected static void assertFolder(VirtualFile file, int itemsInside) {
|
||||
Assert.assertTrue(new File(file.getPath()).isDirectory());
|
||||
Assert.assertEquals(itemsInside, new File(file.getPath()).list().length);
|
||||
}
|
||||
|
||||
protected static void assertFolder(FilePath file, int itemsInside) {
|
||||
Assert.assertTrue("Folder " + file.getPresentableUrl() + " not exists", file.getIOFile().exists());
|
||||
Assert.assertTrue("Folder " + file.getPresentableUrl() + " is a file", file.getIOFile().isDirectory());
|
||||
Assert.assertTrue(file.getIOFile().canWrite());
|
||||
Assert.assertEquals("Wrong children number", itemsInside, file.getIOFile().list().length);
|
||||
Assert.assertEquals(itemsInside, file.getIOFile().list().length);
|
||||
}
|
||||
|
||||
protected static void assertFile(FilePath file, String content, boolean writable) {
|
||||
assertFile(file.getIOFile(), content, writable);
|
||||
}
|
||||
|
||||
protected static void assertFile(VirtualFile file, String content, boolean writable) {
|
||||
assertFile(new File(file.getPath()), content, writable);
|
||||
}
|
||||
|
||||
protected static void assertFile(File file, String content, boolean writable) {
|
||||
Assert.assertTrue("File " + file + " not exists", file.exists());
|
||||
Assert.assertTrue("File " + file + " is folder", file.isFile());
|
||||
|
||||
if (writable) {
|
||||
Assert.assertTrue("File " + file + " expected to be writable", file.canWrite());
|
||||
}
|
||||
else {
|
||||
Assert.assertFalse("File " + file + " expected to be read only", file.canWrite());
|
||||
}
|
||||
InputStream stream = null;
|
||||
try {
|
||||
stream = new FileInputStream(file);
|
||||
Assert.assertEquals("File content differs", content, StreamUtil.readText(stream, StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (IOException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
stream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected int getLatestRevisionNumber(VirtualFile file) throws VcsException {
|
||||
final RepositoryLocation location = getVcs().getCommittedChangesProvider().getLocationFor(TfsFileUtil.getFilePath(file));
|
||||
final List<TFSChangeList> historyList = getVcs().getCommittedChangesProvider()
|
||||
.getCommittedChanges(new ChangeBrowserSettings(), location, getVcs().getCommittedChangesProvider().getUnlimitedCountValue());
|
||||
return (int)historyList.get(0).getNumber();
|
||||
}
|
||||
|
||||
protected void update(VirtualFile root, int revision) {
|
||||
TFSProjectConfiguration configuration = TFSProjectConfiguration.getInstance(myProject);
|
||||
configuration.getUpdateWorkspaceInfo(myTestWorkspace).setVersion(new ChangesetVersionSpec(revision));
|
||||
configuration.getState().UPDATE_RECURSIVELY = true;
|
||||
final UpdatedFiles updatedFiles = UpdatedFiles.create();
|
||||
final UpdateSession session = getVcs().getUpdateEnvironment()
|
||||
.updateDirectories(new FilePath[]{TfsFileUtil.getFilePath(root)}, updatedFiles, null, new Ref<>());
|
||||
Assert.assertTrue(getMessage(session.getExceptions()), session.getExceptions().isEmpty());
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
protected void updateTo(int revisionAge) throws VcsException {
|
||||
update(mySandboxRoot, getLatestRevisionNumber(mySandboxRoot) - revisionAge);
|
||||
}
|
||||
|
||||
protected static void setFileContent(final FilePath file, String content) throws IOException {
|
||||
setFileContent(VcsUtil.getVirtualFile(file.getIOFile()), content);
|
||||
}
|
||||
|
||||
protected static void setFileContent(VirtualFile file, String content) throws IOException {
|
||||
file.setBinaryContent(CharsetToolkit.getUtf8Bytes(content));
|
||||
}
|
||||
|
||||
protected static FilePath getChildPath(final FilePath parent, final String childName) {
|
||||
return VcsUtil.getFilePath(new File(parent.getIOFile(), childName));
|
||||
}
|
||||
|
||||
protected static FilePath getChildPath(final VirtualFile parent, final String childName) {
|
||||
return VcsUtil.getFilePath(new File(new File(parent.getPath()), childName));
|
||||
}
|
||||
|
||||
protected String findServerPath(final FilePath localPath) throws TfsException {
|
||||
return myTestWorkspace.findServerPathsByLocalPath(localPath, false, myProject).iterator().next();
|
||||
}
|
||||
|
||||
protected int getItemId(final FilePath path) throws TfsException {
|
||||
final ExtendedItem extendedItem = myTestWorkspace.getServer().getVCS()
|
||||
.getExtendedItem(myTestWorkspace.getName(), myTestWorkspace.getOwnerName(), path, RecursionType.None, DeletedState.NonDeleted,
|
||||
myProject, null);
|
||||
return extendedItem.getItemid();
|
||||
}
|
||||
|
||||
protected void assertUserNameEqual(String userName) {
|
||||
Assert.assertEquals((DOMAIN + "\\" + USER).toUpperCase(), userName.toUpperCase());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.vcs.MockChangelistBuilder;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestChangeListBuilder extends MockChangelistBuilder {
|
||||
|
||||
private final VirtualFile myRootPath;
|
||||
private final Project myProject;
|
||||
|
||||
private final List<FilePath> myLocallyDeletedFiles = new ArrayList<>();
|
||||
private final List<VirtualFile> myHijackedFiles = new ArrayList<>();
|
||||
|
||||
public TestChangeListBuilder(final VirtualFile rootPath, final Project project) {
|
||||
myRootPath = rootPath;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLocallyDeletedFile(FilePath file) {
|
||||
myLocallyDeletedFiles.add(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processModifiedWithoutCheckout(VirtualFile file) {
|
||||
myHijackedFiles.add(file);
|
||||
}
|
||||
|
||||
public void assertUnversioned(FilePath file) {
|
||||
Assert.assertTrue(toString(), isUnversioned(file));
|
||||
}
|
||||
|
||||
public boolean isUnversioned(FilePath file) {
|
||||
return getUnversionedFiles().contains(file);
|
||||
}
|
||||
|
||||
public void assertUnversioned(VirtualFile file) {
|
||||
Assert.assertTrue(toString(), getUnversionedFiles().contains(VcsUtil.getFilePath(file)));
|
||||
assertFileStatus(file, FileStatus.UNKNOWN);
|
||||
}
|
||||
|
||||
public void assertLocallyDeleted(VirtualFile file) {
|
||||
assertLocallyDeleted(TfsFileUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
public void assertLocallyDeleted(String file) {
|
||||
assertLocallyDeleted(VcsUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
public void assertLocallyDeleted(FilePath path) {
|
||||
Assert.assertTrue(toString(), myLocallyDeletedFiles.contains(path));
|
||||
assertFileStatus(path, FileStatus.DELETED_FROM_FS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VirtualFile> getHijackedFiles() {
|
||||
return myHijackedFiles;
|
||||
}
|
||||
|
||||
public void assertHijacked(FilePath file) {
|
||||
assertHijacked(file.getIOFile().getPath());
|
||||
}
|
||||
|
||||
public void assertHijacked(VirtualFile file) {
|
||||
Assert.assertTrue(toString(), myHijackedFiles.contains(file));
|
||||
assertFileStatus(file, FileStatus.HIJACKED);
|
||||
}
|
||||
|
||||
public void assertHijacked(String file) {
|
||||
Assert.assertTrue(toString(), myHijackedFiles.contains(VcsUtil.getVirtualFile(file)));
|
||||
assertFileStatus(file, FileStatus.HIJACKED);
|
||||
}
|
||||
|
||||
public void assertScheduledForAddition(VirtualFile file) {
|
||||
assertScheduledForAddition(TfsFileUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
public void assertScheduledForAddition(String file) {
|
||||
assertScheduledForAddition(VcsUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
public void assertScheduledForAddition(FilePath file) {
|
||||
if (ChangeHelper.containsAdded(getChanges(), file)) {
|
||||
assertFileStatus(file, FileStatus.ADDED);
|
||||
return;
|
||||
}
|
||||
Assert.fail(ChangeHelper.getPathRemainder(file, myRootPath) + " expected to be scheduled for addition\n" + toString());
|
||||
}
|
||||
|
||||
public void assertScheduledForDeletion(VirtualFile file) {
|
||||
assertScheduledForDeletion(TfsFileUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
public void assertScheduledForDeletion(String file) {
|
||||
assertScheduledForDeletion(VcsUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
public void assertScheduledForDeletion(FilePath file) {
|
||||
if (ChangeHelper.containsDeleted(getChanges(), file)) {
|
||||
assertFileStatus(file, FileStatus.DELETED);
|
||||
return;
|
||||
}
|
||||
Assert.fail(ChangeHelper.getPathRemainder(file, myRootPath) + " expected to be scheduled for deletion\n" + toString());
|
||||
}
|
||||
|
||||
public void assertRenamedOrMoved(FilePath from, FilePath to) {
|
||||
Assert.assertNotNull("Move expected: " +
|
||||
ChangeHelper.getPathRemainder(from, myRootPath) +
|
||||
" -> " +
|
||||
ChangeHelper.getPathRemainder(to, myRootPath) +
|
||||
"\n" +
|
||||
toString(), getMoveChange(from, to));
|
||||
}
|
||||
|
||||
public void assertRenamedOrMoved(FilePath from, FilePath to, String originalContent, String modifiedContent) throws VcsException {
|
||||
final Change moveChange = getMoveChange(from, to);
|
||||
Assert.assertNotNull(
|
||||
"Expected " + ChangeHelper.getPathRemainder(from, myRootPath) + " -> " + ChangeHelper.getPathRemainder(to, myRootPath) + "\n" + toString(),
|
||||
moveChange);
|
||||
Assert.assertEquals(originalContent, moveChange.getBeforeRevision().getContent());
|
||||
Assert.assertEquals(modifiedContent, moveChange.getAfterRevision().getContent());
|
||||
}
|
||||
|
||||
|
||||
public void assertRenamedOrMoved(String from, String to) {
|
||||
Assert
|
||||
.assertNotNull("from=" + from + ", to=" + to + "\n" + toString(), getMoveChange(VcsUtil.getFilePath(from), VcsUtil.getFilePath(to)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Change getMoveChange(final String from, String to) {
|
||||
return getMoveChange(VcsUtil.getFilePath(from), VcsUtil.getFilePath(to));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Change getMoveChange(final FilePath from, FilePath to) {
|
||||
return ChangeHelper.getMoveChange(getChanges(), from, to);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Change getModificationChange(final FilePath file) {
|
||||
return ChangeHelper.getModificationChange(getChanges(), file);
|
||||
}
|
||||
|
||||
public void assertModified(VirtualFile file) {
|
||||
assertModified(TfsFileUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
public void assertModified(String file) {
|
||||
assertModified(VcsUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
public void assertModified(FilePath file) {
|
||||
if (ChangeHelper.containsModified(getChanges(), file)) {
|
||||
// TODO: FileStatus HIJACKED while expected MODIFIED
|
||||
//assertFileStatus(file, FileStatus.MODIFIED);
|
||||
return;
|
||||
}
|
||||
Assert.fail(toString());
|
||||
}
|
||||
|
||||
public void assertModified(FilePath file, String originalContent, String modifiedContent) throws VcsException {
|
||||
final Change change = ChangeHelper.getModificationChange(getChanges(), file);
|
||||
Assert.assertNotNull(ChangeHelper.getPathRemainder(file, myRootPath) + " expected to be modified\n" + toString(), change);
|
||||
Assert.assertEquals(originalContent, change.getBeforeRevision().getContent());
|
||||
Assert.assertEquals(modifiedContent, change.getAfterRevision().getContent());
|
||||
}
|
||||
|
||||
public List<FilePath> getLocallyDeleted() {
|
||||
return myLocallyDeletedFiles;
|
||||
}
|
||||
|
||||
public void assertTotalItems(int n) {
|
||||
Assert.assertEquals(toString(), n, getTotalItems());
|
||||
}
|
||||
|
||||
private int getTotalItems() {
|
||||
return getChanges().size() + getUnversionedFiles().size() + myLocallyDeletedFiles.size() + myHijackedFiles.size() + getIgnoredFiles().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append("Total changes: ").append(getTotalItems()).append("\n");
|
||||
|
||||
if (!getChanges().isEmpty()) {
|
||||
s.append(ChangeHelper.toString(getChanges(), myRootPath));
|
||||
}
|
||||
|
||||
if (!myLocallyDeletedFiles.isEmpty()) {
|
||||
s.append("Locally deleted:\n");
|
||||
for (FilePath p : myLocallyDeletedFiles) {
|
||||
s.append("\t").append(ChangeHelper.getPathRemainder(p, myRootPath)).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!myHijackedFiles.isEmpty()) {
|
||||
s.append("Hijacked:\n");
|
||||
for (VirtualFile f : myHijackedFiles) {
|
||||
s.append("\t").append(ChangeHelper.getPathRemainder(f, myRootPath)).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!getUnversionedFiles().isEmpty()) {
|
||||
s.append("Unversioned:\n");
|
||||
for (FilePath f : getUnversionedFiles()) {
|
||||
s.append("\t").append(ChangeHelper.getPathRemainder(f, myRootPath)).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
private void assertFileStatus(@Nullable VirtualFile file, FileStatus expectedStatus) {
|
||||
if (file == null) {
|
||||
Assert.assertTrue("expected status: " + expectedStatus,
|
||||
FileStatus.DELETED == expectedStatus || FileStatus.DELETED_FROM_FS == expectedStatus);
|
||||
}
|
||||
else {
|
||||
final FileStatus realStatus = FileStatusManager.getInstance(myProject).getStatus(file);
|
||||
Assert.assertEquals("FileStatus " + realStatus + " while expected " + expectedStatus, realStatus, expectedStatus);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertFileStatus(String file, FileStatus expectedStatus) {
|
||||
assertFileStatus(VcsUtil.getVirtualFile(file), expectedStatus);
|
||||
}
|
||||
|
||||
private void assertFileStatus(FilePath path, FileStatus expectedStatus) {
|
||||
assertFileStatus(path.getIOFile().getPath(), expectedStatus);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Change getAddChange(final FilePath file) {
|
||||
return ChangeHelper.getAddChange(getChanges(), file);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Change getDeleteChange(final FilePath file) {
|
||||
return ChangeHelper.getDeleteChange(getChanges(), file);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,582 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral", "UnusedDeclaration"})
|
||||
public class TestComplexOperations extends TFSTestCase {
|
||||
|
||||
// none -> create structure, don't schedule -> unversioned
|
||||
@Test
|
||||
public void testNoneToUnversioned() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
|
||||
final String folderName = "folderA";
|
||||
final String subfolderName1 = "subfolder1";
|
||||
final String subfolderName2 = "subfolder2";
|
||||
final String subfolderName3 = "subfolder3";
|
||||
final String filename1 = "file1.txt";
|
||||
final String filename2 = "file2.txt";
|
||||
final String filename3 = "file3.txt";
|
||||
final String filename4 = "file4.txt";
|
||||
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, folderName);
|
||||
VirtualFile subfolder1 = createDirInCommand(folder, subfolderName1);
|
||||
VirtualFile subfolder2 = createDirInCommand(folder, subfolderName2);
|
||||
VirtualFile subfolder3 = createDirInCommand(folder, subfolderName3);
|
||||
VirtualFile file1 = createFileInCommand(subfolder1, filename1, "");
|
||||
VirtualFile file2 = createFileInCommand(subfolder1, filename2, "");
|
||||
VirtualFile file3 = createFileInCommand(subfolder2, filename3, "");
|
||||
VirtualFile file4 = createFileInCommand(subfolder2, filename4, "");
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(8);
|
||||
changes.assertUnversioned(folder);
|
||||
changes.assertUnversioned(subfolder1);
|
||||
changes.assertUnversioned(subfolder2);
|
||||
changes.assertUnversioned(subfolder3);
|
||||
changes.assertUnversioned(file1);
|
||||
changes.assertUnversioned(file2);
|
||||
changes.assertUnversioned(file3);
|
||||
changes.assertUnversioned(file4);
|
||||
}
|
||||
|
||||
// unversioned -> delete root -> none
|
||||
@Test
|
||||
public void testUnversionedToNoneDeleteRoot() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
|
||||
final String folderName = "folderA";
|
||||
final String subfolderName1 = "subfolder1";
|
||||
final String subfolderName2 = "subfolder2";
|
||||
final String subfolderName3 = "subfolder3";
|
||||
final String filename1 = "file1.txt";
|
||||
final String filename2 = "file2.txt";
|
||||
final String filename3 = "file3.txt";
|
||||
final String filename4 = "file4.txt";
|
||||
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, folderName);
|
||||
VirtualFile subfolder1 = createDirInCommand(folder, subfolderName1);
|
||||
VirtualFile subfolder2 = createDirInCommand(folder, subfolderName2);
|
||||
VirtualFile subfolder3 = createDirInCommand(folder, subfolderName3);
|
||||
VirtualFile file1 = createFileInCommand(subfolder1, filename1, "");
|
||||
VirtualFile file2 = createFileInCommand(subfolder1, filename2, "");
|
||||
VirtualFile file3 = createFileInCommand(subfolder2, filename3, "");
|
||||
VirtualFile file4 = createFileInCommand(subfolder2, filename4, "");
|
||||
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(0);
|
||||
}
|
||||
|
||||
// unversioned -> external delete root -> none
|
||||
@Test
|
||||
public void testUnversionedToNoneExternalDeleteRoot() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String folderName = "folderA";
|
||||
final String subfolderName1 = "subfolder1";
|
||||
final String subfolderName2 = "subfolder2";
|
||||
final String subfolderName3 = "subfolder3";
|
||||
final String filename1 = "file1.txt";
|
||||
final String filename2 = "file2.txt";
|
||||
final String filename3 = "file3.txt";
|
||||
final String filename4 = "file4.txt";
|
||||
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, folderName);
|
||||
VirtualFile subfolder1 = createDirInCommand(folder, subfolderName1);
|
||||
VirtualFile subfolder2 = createDirInCommand(folder, subfolderName2);
|
||||
VirtualFile subfolder3 = createDirInCommand(folder, subfolderName3);
|
||||
VirtualFile file1 = createFileInCommand(subfolder1, filename1, "");
|
||||
VirtualFile file2 = createFileInCommand(subfolder1, filename2, "");
|
||||
VirtualFile file3 = createFileInCommand(subfolder2, filename3, "");
|
||||
VirtualFile file4 = createFileInCommand(subfolder2, filename4, "");
|
||||
|
||||
deleteFileExternally(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(0);
|
||||
}
|
||||
|
||||
// none -> create structure, schedule for addition -> scheduled for addition
|
||||
@Test
|
||||
public void testNoneToScheduledForAddition() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String folderName = "folderA";
|
||||
final String subfolderName1 = "subfolder1";
|
||||
final String subfolderName2 = "subfolder2";
|
||||
final String subfolderName3 = "subfolder3";
|
||||
final String filename1 = "file1.txt";
|
||||
final String filename2 = "file2.txt";
|
||||
final String filename3 = "file3.txt";
|
||||
final String filename4 = "file4.txt";
|
||||
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, folderName);
|
||||
VirtualFile subfolder1 = createDirInCommand(folder, subfolderName1);
|
||||
VirtualFile subfolder2 = createDirInCommand(folder, subfolderName2);
|
||||
VirtualFile subfolder3 = createDirInCommand(folder, subfolderName3);
|
||||
VirtualFile file1 = createFileInCommand(subfolder1, filename1, "");
|
||||
VirtualFile file2 = createFileInCommand(subfolder1, filename2, "");
|
||||
VirtualFile file3 = createFileInCommand(subfolder2, filename3, "");
|
||||
VirtualFile file4 = createFileInCommand(subfolder2, filename4, "");
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(8);
|
||||
changes.assertScheduledForAddition(TfsFileUtil.getFilePath(folder));
|
||||
changes.assertScheduledForAddition(TfsFileUtil.getFilePath(subfolder1));
|
||||
changes.assertScheduledForAddition(TfsFileUtil.getFilePath(subfolder2));
|
||||
changes.assertScheduledForAddition(TfsFileUtil.getFilePath(subfolder3));
|
||||
changes.assertScheduledForAddition(TfsFileUtil.getFilePath(file1));
|
||||
changes.assertScheduledForAddition(TfsFileUtil.getFilePath(file2));
|
||||
changes.assertScheduledForAddition(TfsFileUtil.getFilePath(file3));
|
||||
changes.assertScheduledForAddition(TfsFileUtil.getFilePath(file4));
|
||||
}
|
||||
|
||||
// scheduled for addition -> delete root -> none
|
||||
@Test
|
||||
public void testScheduledForAdditionToNoneDeleteRoot() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String folderName = "folderA";
|
||||
final String subfolderName1 = "subfolder1";
|
||||
final String subfolderName2 = "subfolder2";
|
||||
final String subfolderName3 = "subfolder3";
|
||||
final String filename1 = "file1.txt";
|
||||
final String filename2 = "file2.txt";
|
||||
final String filename3 = "file3.txt";
|
||||
final String filename4 = "file4.txt";
|
||||
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, folderName);
|
||||
VirtualFile subfolder1 = createDirInCommand(folder, subfolderName1);
|
||||
VirtualFile subfolder2 = createDirInCommand(folder, subfolderName2);
|
||||
VirtualFile subfolder3 = createDirInCommand(folder, subfolderName3);
|
||||
VirtualFile file1 = createFileInCommand(subfolder1, filename1, "");
|
||||
VirtualFile file2 = createFileInCommand(subfolder1, filename2, "");
|
||||
VirtualFile file3 = createFileInCommand(subfolder2, filename3, "");
|
||||
VirtualFile file4 = createFileInCommand(subfolder2, filename4, "");
|
||||
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(0);
|
||||
}
|
||||
|
||||
// scheduled for addition -> external delete -> locally deleted
|
||||
@Test
|
||||
public void testScheduledForAdditionToLocallyDeleted() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String folderName = "folderA";
|
||||
final String subfolderName1 = "subfolder1";
|
||||
final String subfolderName2 = "subfolder2";
|
||||
final String subfolderName3 = "subfolder3";
|
||||
final String filename1 = "file1.txt";
|
||||
final String filename2 = "file2.txt";
|
||||
final String filename3 = "file3.txt";
|
||||
final String filename4 = "file4.txt";
|
||||
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, folderName);
|
||||
VirtualFile subfolder1 = createDirInCommand(folder, subfolderName1);
|
||||
VirtualFile subfolder2 = createDirInCommand(folder, subfolderName2);
|
||||
VirtualFile subfolder3 = createDirInCommand(folder, subfolderName3);
|
||||
VirtualFile file1 = createFileInCommand(subfolder1, filename1, "");
|
||||
VirtualFile file2 = createFileInCommand(subfolder1, filename2, "");
|
||||
VirtualFile file3 = createFileInCommand(subfolder2, filename3, "");
|
||||
VirtualFile file4 = createFileInCommand(subfolder2, filename4, "");
|
||||
|
||||
deleteFileExternally(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(8);
|
||||
changes.assertLocallyDeleted(TfsFileUtil.getFilePath(folder));
|
||||
changes.assertLocallyDeleted(TfsFileUtil.getFilePath(subfolder1));
|
||||
changes.assertLocallyDeleted(TfsFileUtil.getFilePath(subfolder2));
|
||||
changes.assertLocallyDeleted(TfsFileUtil.getFilePath(subfolder3));
|
||||
changes.assertLocallyDeleted(TfsFileUtil.getFilePath(file1));
|
||||
changes.assertLocallyDeleted(TfsFileUtil.getFilePath(file2));
|
||||
changes.assertLocallyDeleted(TfsFileUtil.getFilePath(file3));
|
||||
changes.assertLocallyDeleted(TfsFileUtil.getFilePath(file4));
|
||||
}
|
||||
|
||||
// pending changes -> delete root externally, don't schedule for deletion -> locally missing
|
||||
@Test
|
||||
public void testPendingChangesToLocallyMissing() throws Exception {
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
deleteFileExternally(pendingChanges.rootfolder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
|
||||
changes.assertTotalItems(14);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileCheckedOut);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileCheckedOutAndRenamed);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileHijacked);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileMissing);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileRenamed);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileToAdd);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileUpToDate);
|
||||
changes.assertLocallyDeleted(pendingChanges.folderMissing);
|
||||
changes.assertLocallyDeleted(pendingChanges.folderRenamed);
|
||||
changes.assertLocallyDeleted(pendingChanges.folderToAdd);
|
||||
changes.assertLocallyDeleted(pendingChanges.folderUpToDate);
|
||||
|
||||
changes.assertScheduledForDeletion(pendingChanges.fileToDelete);
|
||||
changes.assertScheduledForDeletion(pendingChanges.folderToDelete);
|
||||
}
|
||||
|
||||
// pending changes -> delete root externally, don't schedule for deletion -> locally missing -> revert
|
||||
@Test
|
||||
public void testPendingChangesToLocallyMissingToNone() throws Exception {
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
deleteFileExternally(pendingChanges.rootfolder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
|
||||
changes.assertTotalItems(14);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileCheckedOut);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileCheckedOutAndRenamed);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileHijacked);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileMissing);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileRenamed);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileToAdd);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileUpToDate);
|
||||
changes.assertScheduledForDeletion(pendingChanges.fileToDelete);
|
||||
|
||||
changes.assertLocallyDeleted(pendingChanges.folderMissing);
|
||||
changes.assertLocallyDeleted(pendingChanges.folderRenamed);
|
||||
changes.assertLocallyDeleted(pendingChanges.folderToAdd);
|
||||
changes.assertLocallyDeleted(pendingChanges.folderUpToDate);
|
||||
changes.assertScheduledForDeletion(pendingChanges.folderToDelete);
|
||||
|
||||
rollbackAll(changes);
|
||||
|
||||
changes = getChanges();
|
||||
changes.assertTotalItems(0);
|
||||
}
|
||||
|
||||
// pending changes -> commit
|
||||
@Test
|
||||
public void testCommitPendingChanges() throws Exception {
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
|
||||
commit();
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
|
||||
changes.assertTotalItems(5);
|
||||
changes.assertLocallyDeleted(pendingChanges.folderMissing);
|
||||
changes.assertLocallyDeleted(pendingChanges.fileMissing);
|
||||
changes.assertHijacked(pendingChanges.fileHijacked);
|
||||
changes.assertUnversioned(pendingChanges.folderUnversioned);
|
||||
changes.assertUnversioned(pendingChanges.fileUnversioned);
|
||||
}
|
||||
|
||||
// pending changes -> revert
|
||||
@Test
|
||||
public void testPendingChangesRevert() throws Exception {
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
|
||||
rollbackAll(getChanges());
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
|
||||
changes.assertTotalItems(4);
|
||||
changes.assertUnversioned(pendingChanges.folderUnversioned);
|
||||
changes.assertUnversioned(pendingChanges.fileUnversioned);
|
||||
changes.assertUnversioned(pendingChanges.fileToAdd);
|
||||
changes.assertUnversioned(pendingChanges.folderToAdd);
|
||||
}
|
||||
|
||||
// pending changes -> delete, schedule for deletion
|
||||
@Test
|
||||
public void testPendingChangesDeleteRoot() throws Exception {
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
deleteFileInCommand(pendingChanges.rootfolder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(pendingChanges.rootfolder);
|
||||
}
|
||||
|
||||
// pending changes -> delete, schedule for deletion -> revert
|
||||
@Test
|
||||
public void testPendingChangesDeleteRootRevert() throws Exception {
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
deleteFileInCommand(pendingChanges.rootfolder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(pendingChanges.rootfolder);
|
||||
|
||||
rollback(changes.getChanges());
|
||||
changes = getChanges();
|
||||
changes.assertTotalItems(0);
|
||||
}
|
||||
|
||||
// pending changes -> rename root -> revert root only
|
||||
@Test
|
||||
public void testPendingChangesRenameRootRevert() throws Exception {
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
FilePath rootBefore = pendingChanges.rootfolder;
|
||||
final String newName = pendingChanges.rootfolder.getName() + "_Renamed";
|
||||
renameFileInCommand(pendingChanges.rootfolder, newName);
|
||||
final FilePath rootAfter = getChildPath(rootBefore.getParentPath(), newName);
|
||||
pendingChanges.assertChanges(getChanges(), rootAfter, true);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
rollback(changes.getMoveChange(rootBefore, rootAfter));
|
||||
pendingChanges.assertChanges(getChanges());
|
||||
}
|
||||
|
||||
// pending changes -> rename root -> commit root
|
||||
@Test
|
||||
public void testPendingChangesRenameRootCommit() throws Exception {
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
FilePath rootBefore = pendingChanges.rootfolder;
|
||||
final String newName = pendingChanges.rootfolder.getName() + "_Renamed";
|
||||
renameFileInCommand(pendingChanges.rootfolder, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
|
||||
final FilePath rootAfter = getChildPath(rootBefore.getParentPath(), newName);
|
||||
|
||||
commit(changes.getMoveChange(rootBefore, rootAfter), "test");
|
||||
|
||||
pendingChanges.assertChanges(getChanges(), rootAfter, false);
|
||||
}
|
||||
|
||||
// package.subpackage.Class -> rename package, modify Class -> revert changes
|
||||
@Test
|
||||
public void testRenamePackageRevert() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
|
||||
final String rootPackageName = "rootpackage";
|
||||
final VirtualFile rootPackage = createDirInCommand(mySandboxRoot, rootPackageName);
|
||||
|
||||
final String subPackageName = "subpackage";
|
||||
final VirtualFile subPackage = createDirInCommand(mySandboxRoot, subPackageName);
|
||||
|
||||
final String fileName = "ClassA.java";
|
||||
final VirtualFile file = createFileInCommand(subPackage, fileName, "content");
|
||||
|
||||
commit();
|
||||
|
||||
assertFileStatus(rootPackage, FileStatus.NOT_CHANGED);
|
||||
assertFileStatus(subPackage, FileStatus.NOT_CHANGED);
|
||||
assertFileStatus(file, FileStatus.NOT_CHANGED);
|
||||
|
||||
FilePath rootPackageOriginal = TfsFileUtil.getFilePath(rootPackage);
|
||||
final String rootPackageRenamedName = rootPackageName + "_renamed";
|
||||
rename(rootPackage, rootPackageRenamedName);
|
||||
editFiles(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
|
||||
changes.assertTotalItems(2);
|
||||
changes.assertModified(file);
|
||||
changes.assertRenamedOrMoved(rootPackageOriginal, TfsFileUtil.getFilePath(rootPackage));
|
||||
|
||||
final FilePath rootPackageRenamed = TfsFileUtil.getFilePath(rootPackage);
|
||||
rollback(getChanges().getMoveChange(rootPackageOriginal, rootPackageRenamed));
|
||||
|
||||
changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertModified(file);
|
||||
}
|
||||
|
||||
// pending changes -> move root -> revert
|
||||
@Test
|
||||
public void testPendingChangesMoveRootRevert() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "anotherfolder");
|
||||
final VirtualFile subfolder = createDirInCommand(folder, "subfolder");
|
||||
commit(getChanges().getChanges(), "test - folders created");
|
||||
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
FilePath rootBefore = pendingChanges.rootfolder;
|
||||
|
||||
moveFileInCommand(pendingChanges.rootfolder.getVirtualFile(), subfolder);
|
||||
|
||||
final FilePath rootAfter = getChildPath(subfolder, pendingChanges.rootfolder.getName());
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
pendingChanges.assertChanges(changes, rootAfter, true);
|
||||
|
||||
rollback(changes.getMoveChange(rootBefore, rootAfter));
|
||||
pendingChanges.assertChanges(getChanges());
|
||||
}
|
||||
|
||||
// pending changes -> move root -> commit
|
||||
@Test
|
||||
public void testPendingChangesMoveRootCommit() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "anotherfolder");
|
||||
final VirtualFile subfolder = createDirInCommand(folder, "subfolder");
|
||||
commit(getChanges().getChanges(), "test - folders created");
|
||||
|
||||
final PendingChanges pendingChanges = new PendingChanges();
|
||||
FilePath rootBefore = pendingChanges.rootfolder;
|
||||
|
||||
moveFileInCommand(pendingChanges.rootfolder.getVirtualFile(), subfolder);
|
||||
|
||||
final FilePath rootAfter = getChildPath(subfolder, pendingChanges.rootfolder.getName());
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
pendingChanges.assertChanges(changes, rootAfter, true);
|
||||
|
||||
commit(changes.getMoveChange(rootBefore, rootAfter), "test");
|
||||
pendingChanges.assertChanges(getChanges(), rootAfter, false);
|
||||
}
|
||||
|
||||
private class PendingChanges {
|
||||
public final FilePath rootfolder;
|
||||
public final FilePath fileUnversioned;
|
||||
public final FilePath fileUpToDate;
|
||||
public final FilePath fileRenamedOriginal;
|
||||
public final FilePath fileToDelete;
|
||||
public final FilePath fileCheckedOut;
|
||||
public final FilePath fileHijacked;
|
||||
public final FilePath fileCheckedOutAndRenamedOriginal;
|
||||
public final FilePath fileMissing;
|
||||
public final FilePath fileToAdd;
|
||||
public final FilePath fileCheckedOutAndRenamed;
|
||||
public final FilePath folderUpToDate;
|
||||
public final FilePath folderToAdd;
|
||||
public final FilePath folderToDelete;
|
||||
public final FilePath folderRenamedOriginal;
|
||||
public final FilePath folderRenamed;
|
||||
public final FilePath folderMissing;
|
||||
public final FilePath folderUnversioned;
|
||||
public final FilePath fileRenamed;
|
||||
|
||||
PendingChanges() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String filenameUpToDate = "upToDate.txt";
|
||||
final String filenameToAdd = "ScheduledForAddition.txt";
|
||||
final String filenameRenamedOriginalName = "renamed_original.txt";
|
||||
final String filenameToDelete = "scheduledForDeletion.txt";
|
||||
final String filenameCheckedOut = "checkedOut.txt";
|
||||
final String filenameHijacked = "hijacked.txt";
|
||||
final String filenameCheckedOutAndRenamed = "checkedOutAndRenamed_original.txt";
|
||||
final String filenameMissing = "missing.txt";
|
||||
final String filenameUnversioned = "unversioned.txt";
|
||||
|
||||
final String rootFolderName = "rootFolder";
|
||||
final String foldernameToAdd = "ScheduledForAddition";
|
||||
final String foldernameUpToDate = "UpToDate";
|
||||
final String foldernameToDelete = "ScheduledForDeletion";
|
||||
final String foldernameRenamedOriginalName = "Renamed_original";
|
||||
final String foldernameMissing = "Missing";
|
||||
final String foldernameUnversioned = "Unversioned";
|
||||
|
||||
rootfolder = TfsFileUtil.getFilePath(createDirInCommand(mySandboxRoot, rootFolderName));
|
||||
commit();
|
||||
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
fileUnversioned = TfsFileUtil.getFilePath(createFileInCommand(rootfolder, filenameUnversioned, ""));
|
||||
folderUnversioned = TfsFileUtil.getFilePath(createDirInCommand(rootfolder, foldernameUnversioned));
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
fileUpToDate = TfsFileUtil.getFilePath(createFileInCommand(rootfolder, filenameUpToDate, ""));
|
||||
fileRenamedOriginal = TfsFileUtil.getFilePath(createFileInCommand(rootfolder, filenameRenamedOriginalName, ""));
|
||||
fileToDelete = TfsFileUtil.getFilePath(createFileInCommand(rootfolder, filenameToDelete, ""));
|
||||
fileCheckedOut = TfsFileUtil.getFilePath(createFileInCommand(rootfolder, filenameCheckedOut, ""));
|
||||
fileHijacked = TfsFileUtil.getFilePath(createFileInCommand(rootfolder, filenameHijacked, ""));
|
||||
fileCheckedOutAndRenamedOriginal = TfsFileUtil.getFilePath(createFileInCommand(rootfolder, filenameCheckedOutAndRenamed, ""));
|
||||
fileMissing = TfsFileUtil.getFilePath(createFileInCommand(rootfolder, filenameMissing, ""));
|
||||
|
||||
folderUpToDate = TfsFileUtil.getFilePath(createDirInCommand(rootfolder, foldernameUpToDate));
|
||||
folderToDelete = TfsFileUtil.getFilePath(createDirInCommand(rootfolder, foldernameToDelete));
|
||||
folderRenamedOriginal = TfsFileUtil.getFilePath(createDirInCommand(rootfolder, foldernameRenamedOriginalName));
|
||||
folderMissing = TfsFileUtil.getFilePath(createDirInCommand(rootfolder, foldernameMissing));
|
||||
commit();
|
||||
|
||||
folderToAdd = TfsFileUtil.getFilePath(createDirInCommand(rootfolder, foldernameToAdd));
|
||||
|
||||
fileToAdd = TfsFileUtil.getFilePath(createFileInCommand(rootfolder, filenameToAdd, ""));
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(fileToDelete);
|
||||
deleteFileInCommand(folderToDelete);
|
||||
|
||||
clearReadonlyStatusExternally(fileHijacked, fileRenamedOriginal);
|
||||
|
||||
final String fileRenamedNewName = "renamed.txt";
|
||||
rename(fileRenamedOriginal, fileRenamedNewName);
|
||||
fileRenamed = getChildPath(rootfolder, fileRenamedNewName);
|
||||
|
||||
final String folderRenamedNewName = "Renamed";
|
||||
rename(folderRenamedOriginal, folderRenamedNewName);
|
||||
folderRenamed = getChildPath(rootfolder, folderRenamedNewName);
|
||||
|
||||
editFiles(fileCheckedOut);
|
||||
editFiles(fileCheckedOutAndRenamedOriginal);
|
||||
|
||||
final String fileCheckedOutAndRenamedNewName = "checkedOutAndRenamed.txt";
|
||||
rename(fileCheckedOutAndRenamedOriginal, fileCheckedOutAndRenamedNewName);
|
||||
fileCheckedOutAndRenamed = getChildPath(rootfolder, fileCheckedOutAndRenamedNewName);
|
||||
|
||||
deleteFileExternally(fileMissing);
|
||||
deleteFileExternally(folderMissing);
|
||||
|
||||
assertChanges(getChanges());
|
||||
}
|
||||
|
||||
public void assertChanges(TestChangeListBuilder changes) {
|
||||
assertChanges(changes, rootfolder, false);
|
||||
}
|
||||
|
||||
public void assertChanges(TestChangeListBuilder changes, FilePath newRootFolder, boolean pending) {
|
||||
if (!newRootFolder.equals(rootfolder) && pending) {
|
||||
changes.assertTotalItems(14);
|
||||
changes.assertRenamedOrMoved(rootfolder, newRootFolder);
|
||||
}
|
||||
else {
|
||||
changes.assertTotalItems(13);
|
||||
}
|
||||
|
||||
changes.assertLocallyDeleted(replaceInPath(fileMissing, rootfolder, newRootFolder));
|
||||
changes.assertLocallyDeleted(replaceInPath(folderMissing, rootfolder, newRootFolder));
|
||||
changes.assertUnversioned(replaceInPath(fileUnversioned, rootfolder, newRootFolder));
|
||||
changes.assertUnversioned(replaceInPath(folderUnversioned, rootfolder, newRootFolder));
|
||||
changes.assertModified(replaceInPath(fileCheckedOut, rootfolder, newRootFolder));
|
||||
changes.assertHijacked(replaceInPath(fileHijacked, rootfolder, newRootFolder));
|
||||
changes.assertScheduledForAddition(replaceInPath(fileToAdd, rootfolder, newRootFolder));
|
||||
changes.assertScheduledForDeletion(replaceInPath(fileToDelete, rootfolder, newRootFolder));
|
||||
changes.assertScheduledForAddition(replaceInPath(folderToAdd, rootfolder, newRootFolder));
|
||||
changes.assertScheduledForDeletion(replaceInPath(folderToDelete, rootfolder, newRootFolder));
|
||||
|
||||
if (pending) {
|
||||
changes.assertRenamedOrMoved(fileRenamedOriginal, replaceInPath(fileRenamed, rootfolder, newRootFolder));
|
||||
changes.assertRenamedOrMoved(fileCheckedOutAndRenamedOriginal, replaceInPath(fileCheckedOutAndRenamed, rootfolder, newRootFolder));
|
||||
changes.assertRenamedOrMoved(folderRenamedOriginal, replaceInPath(folderRenamed, rootfolder, newRootFolder));
|
||||
}
|
||||
else {
|
||||
changes.assertRenamedOrMoved(replaceInPath(fileRenamedOriginal, rootfolder, newRootFolder),
|
||||
replaceInPath(fileRenamed, rootfolder, newRootFolder));
|
||||
changes.assertRenamedOrMoved(replaceInPath(fileCheckedOutAndRenamedOriginal, rootfolder, newRootFolder),
|
||||
replaceInPath(fileCheckedOutAndRenamed, rootfolder, newRootFolder));
|
||||
changes.assertRenamedOrMoved(replaceInPath(folderRenamedOriginal, rootfolder, newRootFolder),
|
||||
replaceInPath(folderRenamed, rootfolder, newRootFolder));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestComplexResolveConflicts extends TFSTestCase {
|
||||
private static final String CONTENT_1 = "Content 1";
|
||||
private static final String CONTENT_2 = "Content 2";
|
||||
private static final String CONTENT_3 = "Content 3";
|
||||
private static final String CONTENT_4 = "Content 4";
|
||||
|
||||
private static final String FOLDER_NAME_1 = "Folder1";
|
||||
private static final String FOLDER_NAME_2 = "Folder2";
|
||||
private static final String FOLDER_NAME_3 = "Folder3";
|
||||
private static final String FOLDER_NAME_4 = "Folder4";
|
||||
|
||||
private static final String FILE_NAME_1 = "file1.txt";
|
||||
private static final String FILE_NAME_2 = "file2.txt";
|
||||
private static final String FILE_NAME_3 = "file3.txt";
|
||||
private static final String FILE_NAME_4 = "file4.txt";
|
||||
|
||||
/**
|
||||
* prepare revisions:
|
||||
* 1. Create Folder1 with File1.txt in it (rev 1)
|
||||
* 2. Create File1.txt in Folder1 (rev 2)
|
||||
* 3. Folder 1 -> Folder 2 (rev 3)
|
||||
* 4. File1.txt -> File2.txt (rev 4)
|
||||
* 5. File2.txt (Content 1) -> File2.txt (Content 2) (rev 5)
|
||||
*/
|
||||
|
||||
private void prepareRevisions() throws VcsException, IOException {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
FilePath folder = getChildPath(mySandboxRoot, FOLDER_NAME_1);
|
||||
createDirInCommand(folder);
|
||||
commit(getChanges().getChanges(), "rev. 1");
|
||||
assertFolder(folder, 0);
|
||||
|
||||
FilePath file = getChildPath(folder, FILE_NAME_1);
|
||||
createFileInCommand(file, CONTENT_1);
|
||||
|
||||
commit(getChanges().getChanges(), "rev. 2");
|
||||
assertFolder(folder, 1);
|
||||
assertFile(file, CONTENT_1, false);
|
||||
|
||||
rename(folder, FOLDER_NAME_2);
|
||||
folder = getChildPath(mySandboxRoot, FOLDER_NAME_2);
|
||||
commit(getChanges().getChanges(), "rev. 3");
|
||||
assertFolder(folder, 1);
|
||||
|
||||
file = getChildPath(folder, FILE_NAME_1);
|
||||
rename(file, FILE_NAME_2);
|
||||
commit(getChanges().getChanges(), "rev. 4");
|
||||
file = getChildPath(folder, FILE_NAME_2);
|
||||
assertFile(file, CONTENT_1, false);
|
||||
|
||||
editFiles(file);
|
||||
setFileContent(file, CONTENT_2);
|
||||
commit(getChanges().getChanges(), "rev. 5");
|
||||
assertFile(file, CONTENT_2, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Folder 2 -> Folder 3
|
||||
*/
|
||||
private void renameFolder() {
|
||||
FilePath folder = getChildPath(mySandboxRoot, FOLDER_NAME_2);
|
||||
rename(folder, FOLDER_NAME_3);
|
||||
folder = getChildPath(mySandboxRoot, FOLDER_NAME_3);
|
||||
assertFolder(folder, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* File2.txt -> File3.txt
|
||||
*/
|
||||
private void renameFile() {
|
||||
FilePath folder = getChildPath(mySandboxRoot, FOLDER_NAME_1);
|
||||
FilePath file = getChildPath(folder, FILE_NAME_3);
|
||||
rename(file, FILE_NAME_3);
|
||||
file = getChildPath(folder, FILE_NAME_3);
|
||||
assertFile(file, CONTENT_2, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* file (Content 2) -> file (Content 3)
|
||||
*/
|
||||
private void editFile(FilePath file) throws VcsException, IOException {
|
||||
editFiles(file);
|
||||
setFileContent(file, CONTENT_3);
|
||||
assertFile(file, CONTENT_3, true);
|
||||
}
|
||||
|
||||
//@Test
|
||||
//public void testRenameFolderAcceptYours() throws VcsException, IOException {
|
||||
// prepareRevisions();
|
||||
// renameFolder();
|
||||
//
|
||||
// //ConflictsEnvironment.setConflictsHandler(new AcceptYoursConflictsHandler(1));
|
||||
// updateTo(4);
|
||||
// FilePath folderFrom = getChildPath(mySandboxRoot, FOLDER_NAME_2);
|
||||
// FilePath folderTo = getChildPath(mySandboxRoot, FOLDER_NAME_3);
|
||||
//
|
||||
// // TODO: write correct asserts
|
||||
// //assertFolder(folderTo, 1);
|
||||
// //getChanges().assertTotalItems(1);
|
||||
// //getChanges().assertRenamedOrMoved(folderFrom, folderTo);
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsHistorySession;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.tfsIntegration.core.TFSChangeList;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestHistoryProvider extends TFSTestCase {
|
||||
|
||||
@Test
|
||||
public void testUpdate() throws VcsException, IOException {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
final VirtualFile root = createDirInCommand(mySandboxRoot, "root");
|
||||
final VirtualFile folder1 = createDirInCommand(root, "folder1");
|
||||
final String fileModifiedContent1 = "fileModifiedRev1";
|
||||
final VirtualFile fileModified = createFileInCommand(folder1, "fileModified", fileModifiedContent1);
|
||||
final FilePath fileModified_original = TfsFileUtil.getFilePath(fileModified);
|
||||
final String fileRenamedContent = "fileRenamedRev1";
|
||||
final VirtualFile fileRenamed = createFileInCommand(folder1, "filepathRenamed_original", fileRenamedContent);
|
||||
final FilePath filepathRenamed_original = TfsFileUtil.getFilePath(fileRenamed);
|
||||
final String fileRenamedModifiedContent1 = "fileRenamedModifiedRev1";
|
||||
final VirtualFile fileRenamedModified = createFileInCommand(folder1, "filepathRenamedModified_original", fileRenamedModifiedContent1);
|
||||
final FilePath filepathRenamedModified_original = TfsFileUtil.getFilePath(fileRenamedModified);
|
||||
final VirtualFile fileDeleted = createFileInCommand(folder1, "fileDeleted", "fileDeletedRev1");
|
||||
final FilePath filepathDeleted = TfsFileUtil.getFilePath(fileDeleted);
|
||||
final VirtualFile subfolderRenamed = createDirInCommand(folder1, "subfolderRenamed_original");
|
||||
final FilePath filepathSubfolderRenamedOriginal = TfsFileUtil.getFilePath(subfolderRenamed);
|
||||
final VirtualFile subfolderDeleted = createDirInCommand(folder1, "subfolderRenamedDeleted");
|
||||
final FilePath filepathSubfolderDeleted = TfsFileUtil.getFilePath(subfolderDeleted);
|
||||
final VirtualFile subfolderMoved = createDirInCommand(folder1, "subfolderMoved");
|
||||
final FilePath filepathSubfolderMovedOriginal = TfsFileUtil.getFilePath(subfolderMoved);
|
||||
|
||||
final String comment1 = "test rev1 committed";
|
||||
commit(getChanges().getChanges(), comment1);
|
||||
|
||||
editFiles(fileModified, fileRenamedModified);
|
||||
final String fileModifiedContent2 = "fileModifiedRev2";
|
||||
setFileContent(fileModified, fileModifiedContent2);
|
||||
rename(fileRenamed, "fileRenamed_renamed");
|
||||
rename(fileRenamedModified, "fileRenamedModified_renamed");
|
||||
final String fileRenamedModifiedContent2 = "fileRenamedModifiedRev2";
|
||||
setFileContent(fileRenamedModified, fileRenamedModifiedContent2);
|
||||
|
||||
final VirtualFile fileCreated = createFileInCommand(root, "fileCreated", "fileCreatedContent");
|
||||
deleteFileInCommand(fileDeleted);
|
||||
|
||||
deleteFileInCommand(subfolderDeleted);
|
||||
rename(subfolderRenamed, "subfolderRenamed_newname");
|
||||
|
||||
VirtualFile subfolderA = createDirInCommand(root, "subfolderA");
|
||||
VirtualFile subfolderB = createDirInCommand(subfolderA, "subfolderB");
|
||||
moveFileInCommand(subfolderMoved, subfolderB);
|
||||
|
||||
final String comment2 = "test rev2 committed";
|
||||
commit(getChanges().getChanges(), comment2);
|
||||
|
||||
final RepositoryLocation location = getVcs().getCommittedChangesProvider().getLocationFor(TfsFileUtil.getFilePath(root));
|
||||
ChangeBrowserSettings settings = new ChangeBrowserSettings();
|
||||
final List<TFSChangeList> historyList = getVcs().getCommittedChangesProvider().getCommittedChanges(settings, location, 0);
|
||||
|
||||
Assert.assertEquals(historyList.size(), 2);
|
||||
{
|
||||
final TFSChangeList changelist1 = historyList.get(1);
|
||||
|
||||
Assert.assertEquals(comment1, changelist1.getComment());
|
||||
assertUserNameEqual(changelist1.getCommitterName());
|
||||
|
||||
String dump = ChangeHelper.toString(changelist1.getChanges(), mySandboxRoot);
|
||||
Assert.assertEquals(dump, 9, changelist1.getChanges().size());
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist1.getChanges(), root));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist1.getChanges(), folder1));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist1.getChanges(), fileModified_original));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist1.getChanges(), filepathRenamed_original));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist1.getChanges(), filepathRenamedModified_original));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist1.getChanges(), filepathDeleted));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist1.getChanges(), filepathSubfolderRenamedOriginal));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist1.getChanges(), filepathSubfolderDeleted));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist1.getChanges(), filepathSubfolderMovedOriginal));
|
||||
}
|
||||
|
||||
{
|
||||
final TFSChangeList changelist2 = historyList.get(0);
|
||||
Assert.assertEquals(comment2, changelist2.getComment());
|
||||
assertUserNameEqual(changelist2.getCommitterName());
|
||||
|
||||
String dump = ChangeHelper.toString(changelist2.getChanges(), mySandboxRoot);
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist2.getChanges(), fileCreated));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsDeleted(changelist2.getChanges(), filepathDeleted));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsModified(changelist2.getChanges(), fileModified));
|
||||
ChangeHelper
|
||||
.assertModified(changelist2.getChanges(), TfsFileUtil.getFilePath(fileModified), fileModifiedContent1, fileModifiedContent2);
|
||||
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist2.getChanges(), subfolderA));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist2.getChanges(), subfolderB));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsDeleted(changelist2.getChanges(), filepathSubfolderDeleted));
|
||||
|
||||
if (TFSChangeList.IDEADEV_29451_WORKAROUND) {
|
||||
Assert.assertEquals(dump, 14, changelist2.getChanges().size());
|
||||
Assert.assertTrue(dump, ChangeHelper.containsDeleted(changelist2.getChanges(), filepathRenamed_original, fileRenamedContent));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist2.getChanges(), fileRenamed, fileRenamedContent));
|
||||
|
||||
Assert.assertTrue(dump, ChangeHelper.containsDeleted(changelist2.getChanges(), filepathRenamedModified_original,
|
||||
fileRenamedModifiedContent1));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist2.getChanges(), fileRenamedModified, fileRenamedModifiedContent2));
|
||||
|
||||
Assert.assertTrue(dump, ChangeHelper.containsDeleted(changelist2.getChanges(), filepathSubfolderRenamedOriginal));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist2.getChanges(), subfolderRenamed));
|
||||
|
||||
Assert.assertTrue(dump, ChangeHelper.containsDeleted(changelist2.getChanges(), filepathSubfolderMovedOriginal));
|
||||
Assert.assertTrue(dump, ChangeHelper.containsAdded(changelist2.getChanges(), subfolderMoved));
|
||||
}
|
||||
else {
|
||||
Assert.assertEquals(dump, 10, changelist2.getChanges().size());
|
||||
|
||||
Change renamedChange = ChangeHelper.getMoveChange(changelist2.getChanges(), filepathRenamed_original, fileRenamed);
|
||||
Assert.assertNotNull(renamedChange);
|
||||
ChangeHelper.assertContent(renamedChange, fileRenamedContent, fileRenamedContent);
|
||||
|
||||
Change renamedModifiedChange = ChangeHelper
|
||||
.getMoveChange(changelist2.getChanges(), filepathRenamedModified_original, fileRenamedModified);
|
||||
Assert.assertNotNull(dump, renamedModifiedChange);
|
||||
ChangeHelper.assertContent(renamedModifiedChange, fileRenamedModifiedContent1, fileRenamedModifiedContent2);
|
||||
|
||||
Assert
|
||||
.assertNotNull(dump, ChangeHelper.getMoveChange(changelist2.getChanges(), filepathSubfolderRenamedOriginal, subfolderRenamed));
|
||||
|
||||
Assert.assertNotNull(dump, ChangeHelper.getMoveChange(changelist2.getChanges(), filepathSubfolderMovedOriginal, subfolderMoved));
|
||||
}
|
||||
}
|
||||
|
||||
final VcsHistorySession session = getVcs().getVcsHistoryProvider().createSessionFor(TfsFileUtil.getFilePath(fileRenamedModified));
|
||||
Assert.assertEquals(2, session.getRevisionList().size());
|
||||
final VcsFileRevision firstRevision = session.getRevisionList().get(1);
|
||||
final VcsFileRevision lastRevision = session.getRevisionList().get(0);
|
||||
Assert.assertEquals(comment1, firstRevision.getCommitMessage());
|
||||
Assert.assertEquals(comment2, lastRevision.getCommitMessage());
|
||||
firstRevision.loadContent();
|
||||
lastRevision.loadContent();
|
||||
Assert.assertArrayEquals(fileRenamedModifiedContent1.getBytes(StandardCharsets.UTF_8), firstRevision.loadContent());
|
||||
Assert.assertArrayEquals(fileRenamedModifiedContent2.getBytes(StandardCharsets.UTF_8), lastRevision.loadContent());
|
||||
}
|
||||
|
||||
}
|
||||
+950
@@ -0,0 +1,950 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.rollback.RollbackProgressListener;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestSimpleFileOperations extends TFSTestCase {
|
||||
|
||||
// none -> create file, don't schedule -> unversioned
|
||||
@Test
|
||||
public void testNoneToUnversioned() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertUnversioned(file);
|
||||
Assert.assertEquals(content, getContent(file));
|
||||
}
|
||||
|
||||
// unversioned -> delete -> none
|
||||
@Test
|
||||
public void testUnversionedToNoneDelete() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// unversioned -> delete -> none
|
||||
@Test
|
||||
public void testUnversionedToNoneExternalDelete() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
deleteFileExternally(file);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// none -> create file, schedule -> scheduled for addition
|
||||
@Test
|
||||
public void testNoneToScheduledForAddition() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForAddition(file);
|
||||
Assert.assertEquals(content, getContent(file));
|
||||
}
|
||||
|
||||
// scheduled for addition -> delete -> none
|
||||
@Test
|
||||
public void testScheduledForAdditionToNoneDelete() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// scheduled for addition -> external delete -> locally deleted
|
||||
@Test
|
||||
public void testScheduledForAdditionToLocallyDeleted() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
deleteFileExternally(file);
|
||||
|
||||
getChanges().assertLocallyDeleted(TfsFileUtil.getFilePath(file));
|
||||
}
|
||||
|
||||
// locally deleted -> removeFromVcs -> none
|
||||
@Test
|
||||
public void testLocallyDeletedToNone() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
deleteFileExternally(file);
|
||||
|
||||
scheduleForDeletion(file);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// locally deleted -> rollback -> none
|
||||
@Test
|
||||
public void testLocallyDeletedRollbackToNone() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
deleteFileExternally(file);
|
||||
|
||||
getVcs().getRollbackEnvironment().rollbackMissingFileDeletion(Collections.singletonList(TfsFileUtil.getFilePath(file)),
|
||||
new ArrayList<>(), RollbackProgressListener.EMPTY);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// scheduled for addition -> rollback -> unversioned
|
||||
@Test
|
||||
public void testScheduledForAdditionToUnversioned() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertUnversioned(file);
|
||||
Assert.assertEquals(content, getContent(file));
|
||||
}
|
||||
|
||||
// unversioned -> schedule for addition -> scheduled for addition
|
||||
@Test
|
||||
public void testUnversionedToScheduledForAddition() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
|
||||
scheduleForAddition(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForAddition(file);
|
||||
}
|
||||
|
||||
// unversioned -> rename -> unversioned
|
||||
@Test
|
||||
public void testUnversionedToUnversionedRename() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
final String newName = "file2.txt";
|
||||
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertUnversioned(getVirtualFile(mySandboxRoot, newName));
|
||||
}
|
||||
|
||||
// unversioned -> external rename -> unversioned
|
||||
@Test
|
||||
public void testUnversionedToUnversionedExternalRename() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
final String newName = "file2.txt";
|
||||
|
||||
clearReadonlyAndRenameExternally(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertUnversioned(getVirtualFile(mySandboxRoot, newName));
|
||||
}
|
||||
|
||||
// scheduled for addition -> rename -> scheduled for addition
|
||||
@Test
|
||||
public void testScheduledForAdditionToScheduledForAdditionRename() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
final String newName = "file2.txt";
|
||||
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForAddition(getVirtualFile(mySandboxRoot, newName));
|
||||
}
|
||||
|
||||
// scheduled for addition -> check in -> up to date
|
||||
@Test
|
||||
public void testScheduledForAdditionToUpToDate() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(0);
|
||||
}
|
||||
|
||||
// up to date -> check out -> modified [edit]
|
||||
@Test
|
||||
public void testUpToDateToCheckedOut() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
editFiles(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertModified(file);
|
||||
}
|
||||
|
||||
// modified [edit] -> rollback -> up to date
|
||||
@Test
|
||||
public void testCheckedOutToUpToDateRollback() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
editFiles(file);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// modified [edit] -> check in -> up to date
|
||||
@Test
|
||||
public void testCheckedOutToUpToDateCheckin() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
editFiles(file);
|
||||
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// up to date -> clear readonly by filesystem -> hijacked
|
||||
@Test
|
||||
public void testUpToDateToHijacked() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertHijacked(file);
|
||||
}
|
||||
|
||||
// hijacked -> rollback -> up to date
|
||||
@Test
|
||||
public void testHijackedToUpToDate() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
rollbackHijacked(getChanges().getHijackedFiles());
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// hijacked -> checkout -> modified [edit]
|
||||
@Test
|
||||
public void testHijackedToCheckedOut() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
editFiles(file);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertModified(file);
|
||||
}
|
||||
|
||||
// hijacked -> rename -> modified [rename]
|
||||
@Test
|
||||
public void testHijackedToRenamedRename() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
rename(file, newName);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
final FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
}
|
||||
|
||||
// modified [rename] -> rename to original name -> hijacked
|
||||
@Test
|
||||
public void testRenamedToHijackedRenameBack() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final String originalName = "file.txt";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, originalName, content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
rename(file, newName);
|
||||
rename(file, originalName);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertHijacked(file);
|
||||
}
|
||||
|
||||
// modified [rename] -> commit -> hijacked
|
||||
@Test
|
||||
public void testRenamedToHijackedCommit() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final String originalName = "file.txt";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, originalName, content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
rename(file, newName);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(0);
|
||||
}
|
||||
|
||||
// modified [rename] -> rename not to original name -> modified [rename]
|
||||
@Test
|
||||
public void testRenamedToRenamedRename() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
rename(file, newName);
|
||||
|
||||
final String otherName = "file3.txt";
|
||||
rename(file, otherName);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
final FilePath after = getChildPath(mySandboxRoot, otherName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
}
|
||||
|
||||
// up to date -> rename externally -> modified [rename]
|
||||
@Test
|
||||
public void testUpToDateToRenamed() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
clearReadonlyStatusExternally(file);
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
}
|
||||
|
||||
// modified [rename] -> revert -> up to date
|
||||
@Test
|
||||
public void testRenamedToUpToDateRevert() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
String originalName = "file.txt";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, originalName, content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
clearReadonlyStatusExternally(file);
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// modified [rename] -> commit -> up to date
|
||||
@Test
|
||||
public void testRenamedToUpToDateCommit() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
clearReadonlyStatusExternally(file);
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// up to date -> rename externally -> modified [rename] -> rename to original name
|
||||
@Test
|
||||
public void testUpToDateToRenamedToHijacked() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final String originalName = "file.txt";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, originalName, content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
clearReadonlyStatusExternally(file);
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
|
||||
rename(file, originalName);
|
||||
changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertHijacked(file);
|
||||
}
|
||||
|
||||
// hijacked -> delete, schedule for deletion -> scheduled for deletion
|
||||
@Test
|
||||
public void testHijackedToScheduledForDeletion() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(path);
|
||||
}
|
||||
|
||||
|
||||
// hijacked -> delete, schedule for deletion -> scheduled for deletion -> rollback -> up to date
|
||||
@Test
|
||||
public void testHijackedToScheduledForDeletionToUpToDateRevert() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(path);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// up to date -> delete, schedule for deletion -> scheduled for deletion
|
||||
@Test
|
||||
public void testUpToDateToScheduledForDeletion() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(path);
|
||||
}
|
||||
|
||||
// scheduled for deletion -> rollback -> up to date
|
||||
@Test
|
||||
public void testScheduledForDeletionToUpToDate() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(path);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// scheduled for deletion -> check in -> none
|
||||
@Test
|
||||
public void testScheduledForDeletionToNoneCheckin() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(path);
|
||||
|
||||
commit(getChanges().getChanges(), "unit test");
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
|
||||
// hijacked -> delete, don't schedule for deletion -> locally missing
|
||||
@Test
|
||||
public void testHijackedToLocallyMissing() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
}
|
||||
|
||||
// up to date -> delete, don't schedule for deletion (modify by VCS) -> locally missing
|
||||
@Test
|
||||
public void testUpToDateToLocallyMissingModifyByVCS() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
editFiles(file);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
}
|
||||
|
||||
// locally missing -> rollback -> up to date
|
||||
@Test
|
||||
public void testLocallyMissingToUpToDate() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
editFiles(file);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
|
||||
getVcs().getRollbackEnvironment().rollbackMissingFileDeletion(Arrays.asList(path), new ArrayList<>(), RollbackProgressListener.EMPTY);
|
||||
refreshAll();
|
||||
getChanges().assertTotalItems(0);
|
||||
Assert.assertEquals(content, getContent(VcsUtil.getVirtualFile(path.getPath())));
|
||||
}
|
||||
|
||||
// locally missing -> remove from vcs -> scheduled for deletion
|
||||
@Test
|
||||
public void testLocallyMissingToScheduledForDeletion() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
editFiles(file);
|
||||
deleteFileInCommand(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
|
||||
getVcs().getCheckinEnvironment().scheduleMissingFileForDeletion(Arrays.asList(path));
|
||||
getChanges().assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
}
|
||||
|
||||
// modified [edit] -> delete, schedule for deletion -> scheduled for deletion
|
||||
@Test
|
||||
public void testCheckedOutToScheduledForDeletion() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
|
||||
editFiles(file);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
deleteFileInCommand(file);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(path);
|
||||
}
|
||||
|
||||
// modified [edit] -> external delete, don't schedule for deletion -> locally missing
|
||||
@Test
|
||||
public void testCheckedOutToLocallyMissing() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath path = TfsFileUtil.getFilePath(file);
|
||||
|
||||
editFiles(file);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
deleteFileExternally(file);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
}
|
||||
|
||||
// modified [edit, rename] -> external delete, don't schedule for deletion -> locally missing (modified name)
|
||||
@Test
|
||||
public void testCheckedOutAndRenamedToLocallyMissing() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
final String newName = "file2.txt";
|
||||
editFiles(file);
|
||||
rename(file, newName);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
deleteFileExternally(file);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertLocallyDeleted(after);
|
||||
}
|
||||
|
||||
// modified [edit, rename] -> delete, schedule for deletion -> scheduled for deletion (original name)
|
||||
@Test
|
||||
public void testCheckedOutAndRenamedToScheduledForDeletion() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
editFiles(file);
|
||||
rename(file, newName);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
deleteFileInCommand(file);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(before);
|
||||
}
|
||||
|
||||
// modified [rename] -> external delete, don't schedule for deletion -> locally missing (modified name)
|
||||
@Test
|
||||
public void testRenamedToLocallyMissing() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
rename(file, newName);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
deleteFileExternally(file);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertLocallyDeleted(after);
|
||||
}
|
||||
|
||||
// modified [rename] -> delete, schedule for deletion -> schedule for deletion (original name)
|
||||
@Test
|
||||
public void testRenamedToScheduledForDeletion() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
clearReadonlyStatusExternally(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
rename(file, newName);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
deleteFileInCommand(file);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(before);
|
||||
}
|
||||
|
||||
// up to date -> rename, modify by VCS -> modified [edit, rename]
|
||||
@Test
|
||||
public void testUpToDateToCheckedOutAndRenamed() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
editFiles(file);
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
}
|
||||
|
||||
// up to date -> rename, modify by VCS -> modified [edit, rename] -> rename to original name -> modified [edit]
|
||||
@Test
|
||||
public void testUpToDateToCheckedOutAndRenamedToModifiedRenameBack() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final String originalName = "file.txt";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, originalName, content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
editFiles(file);
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
|
||||
rename(file, originalName);
|
||||
|
||||
changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertModified(before);
|
||||
}
|
||||
|
||||
// modified [rename, edit] -> rollback -> up to date
|
||||
@Test
|
||||
public void testCheckedOutAndRenamedToUpToDateRollback() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
editFiles(file);
|
||||
rename(file, newName);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// modified [rename, edit] -> check in -> up to date
|
||||
@Test
|
||||
public void testCheckedOutAndRenamedToUpToDateCheckin() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
editFiles(file);
|
||||
rename(file, newName);
|
||||
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// modified [rename, edit] -> rename not to original name -> modified [rename, edit]
|
||||
@Test
|
||||
public void testCheckedOutAndRenamedToCheckedOutAndRenamedRename() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
editFiles(file);
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
|
||||
final String anotherName = "file3.txt";
|
||||
rename(file, anotherName);
|
||||
|
||||
changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath anotherFile = getChildPath(mySandboxRoot, anotherName);
|
||||
changes.assertRenamedOrMoved(before, anotherFile);
|
||||
}
|
||||
|
||||
// modified [rename, edit] -> rename to original name -> modified [edit]
|
||||
@Test
|
||||
public void testCheckedOutAndRenamedToCheckedOutRenameBack() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final String originalName = "file.txt";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, originalName, content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
editFiles(file);
|
||||
rename(file, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
|
||||
rename(file, originalName);
|
||||
|
||||
changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertModified(before);
|
||||
}
|
||||
|
||||
// modified [edit] -> rename -> modified [edit, rename]
|
||||
@Test
|
||||
public void testCheckedOutToCheckedOutRenamed() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String content = "filecontent";
|
||||
final VirtualFile file = createFileInCommand(mySandboxRoot, "file.txt", content);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(file);
|
||||
|
||||
editFiles(file);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertModified(file);
|
||||
|
||||
final String newName = "file2.txt";
|
||||
rename(file, newName);
|
||||
|
||||
changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
}
|
||||
|
||||
}
|
||||
+444
@@ -0,0 +1,444 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.rollback.RollbackProgressListener;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestSimpleFolderOperations extends TFSTestCase {
|
||||
|
||||
// none -> create folder, don't schedule -> unversioned
|
||||
@Test
|
||||
public void testNoneToUnversioned() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertUnversioned(folder);
|
||||
}
|
||||
|
||||
// unversioned -> delete -> none
|
||||
@Test
|
||||
public void testUnversionedToNoneDelete() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// unversioned -> delete -> none
|
||||
@Test
|
||||
public void testUnversionedToNoneExternalDelete() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
deleteFileExternally(folder);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// none -> create folder, schedule -> scheduled for addition
|
||||
@Test
|
||||
public void testNoneToScheduledForAddition() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForAddition(folder);
|
||||
}
|
||||
|
||||
// scheduled for addition -> delete -> none
|
||||
@Test
|
||||
public void testScheduledForAdditionToNoneDelete() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// scheduled for addition -> external delete -> locally deleted
|
||||
@Test
|
||||
public void testScheduledForAdditionToLocallyDeleted() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
deleteFileExternally(folder);
|
||||
|
||||
getChanges().assertLocallyDeleted(TfsFileUtil.getFilePath(folder));
|
||||
}
|
||||
|
||||
// locally deleted -> removeFromVcs -> none
|
||||
@Test
|
||||
public void testLocallyDeletedToNone() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
deleteFileExternally(folder);
|
||||
|
||||
scheduleForDeletion(folder);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// locally deleted -> rollback -> none
|
||||
@Test
|
||||
public void testLocallyDeletedRollbackToNone() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
deleteFileExternally(folder);
|
||||
|
||||
getVcs().getRollbackEnvironment().rollbackMissingFileDeletion(Collections.singletonList(TfsFileUtil.getFilePath(folder)),
|
||||
new ArrayList<>(), RollbackProgressListener.EMPTY);
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// scheduled for addition -> rollback -> unversioned
|
||||
@Test
|
||||
public void testScheduledForAdditionToUnversioned() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertUnversioned(folder);
|
||||
}
|
||||
|
||||
// unversioned -> schedule for addition -> scheduled for addition
|
||||
@Test
|
||||
public void testUnversionedToScheduledForAddition() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
|
||||
scheduleForAddition(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForAddition(folder);
|
||||
}
|
||||
|
||||
// unversioned -> rename -> unversioned
|
||||
@Test
|
||||
public void testUnversionedToUnversionedRename() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
final String newName = "Folder_renamed";
|
||||
|
||||
rename(folder, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertUnversioned(getVirtualFile(mySandboxRoot, newName));
|
||||
}
|
||||
|
||||
// unversioned -> external rename -> unversioned
|
||||
@Test
|
||||
public void testUnversionedToUnversionedExternalRename() throws Exception {
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
final String newName = "Folder_renamed";
|
||||
|
||||
clearReadonlyAndRenameExternally(folder, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertUnversioned(getVirtualFile(mySandboxRoot, newName));
|
||||
}
|
||||
|
||||
// scheduled for addition -> rename -> scheduled for addition
|
||||
@Test
|
||||
public void testScheduledForAdditionToScheduledForAdditionRename() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
final String newName = "Folder_renamed";
|
||||
|
||||
rename(folder, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForAddition(getVirtualFile(mySandboxRoot, newName));
|
||||
}
|
||||
|
||||
// scheduled for addition -> check in -> up to date
|
||||
@Test
|
||||
public void testScheduledForAdditionToUpToDate() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
createDirInCommand(mySandboxRoot, "Folder");
|
||||
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(0);
|
||||
}
|
||||
|
||||
// modified [rename] -> rename to original name -> up to date
|
||||
@Test
|
||||
public void testRenamedToUpToDateRenameBack() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final String originalName = "Folder";
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, originalName);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
final String newName = "Folder_renamed";
|
||||
rename(folder, newName);
|
||||
rename(folder, originalName);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(0);
|
||||
}
|
||||
|
||||
// modified [rename] -> rename not to original name -> modified [rename]
|
||||
@Test
|
||||
public void testRenamedToRenamedRename() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
FilePath before = TfsFileUtil.getFilePath(folder);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
final String newName = "Folder_renamed";
|
||||
rename(folder, newName);
|
||||
|
||||
final String otherName = "Folder_3";
|
||||
rename(folder, otherName);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
final FilePath after = getChildPath(mySandboxRoot, otherName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
}
|
||||
|
||||
// up to date -> rename -> modified [rename]
|
||||
@Test
|
||||
public void testUpToDateToRenamed() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(folder);
|
||||
|
||||
final String newName = "Folder_renamed";
|
||||
rename(folder, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
}
|
||||
|
||||
// modified [rename] -> revert -> up to date
|
||||
@Test
|
||||
public void testRenamedToUpToDateRevert() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(folder);
|
||||
|
||||
final String newName = "Folder_renamed";
|
||||
rename(folder, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// modified [rename] -> commit -> up to date
|
||||
@Test
|
||||
public void testRenamedToUpToDateCommit() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
FilePath before = TfsFileUtil.getFilePath(folder);
|
||||
|
||||
final String newName = "Folder_renamed";
|
||||
rename(folder, newName);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertRenamedOrMoved(before, after);
|
||||
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// up to date -> delete, schedule for deletion -> scheduled for deletion
|
||||
@Test
|
||||
public void testUpToDateToScheduledForDeletion() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
FilePath path = TfsFileUtil.getFilePath(folder);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(path);
|
||||
}
|
||||
|
||||
|
||||
// up to date -> delete, schedule for deletion -> scheduled for deletion -> rollback -> up to date
|
||||
@Test
|
||||
public void testUpToDateToScheduledForDeletionToUpToDateRevert() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
FilePath path = TfsFileUtil.getFilePath(folder);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(path);
|
||||
|
||||
rollback(getChanges().getChanges());
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// scheduled for deletion -> check in -> none
|
||||
@Test
|
||||
public void testScheduledForDeletionToNoneCheckin() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
FilePath path = TfsFileUtil.getFilePath(folder);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(path);
|
||||
|
||||
commit(getChanges().getChanges(), "unit test");
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// up to date -> delete, don't schedule for deletion (modify by VCS) -> locally missing
|
||||
@Test
|
||||
public void testUpToDateToLocallyMissingModifyByVCS() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
FilePath path = TfsFileUtil.getFilePath(folder);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
}
|
||||
|
||||
// locally missing -> rollback -> up to date
|
||||
@Test
|
||||
public void testLocallyMissingToUpToDate() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
FilePath path = TfsFileUtil.getFilePath(folder);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
|
||||
getVcs().getRollbackEnvironment().rollbackMissingFileDeletion(Arrays.asList(path), new ArrayList<>(), RollbackProgressListener.EMPTY);
|
||||
refreshAll();
|
||||
getChanges().assertTotalItems(0);
|
||||
}
|
||||
|
||||
// locally missing -> remove from vcs -> scheduled for deletion
|
||||
@Test
|
||||
public void testLocallyMissingToScheduledForDeletion() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
FilePath path = TfsFileUtil.getFilePath(folder);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
doNothingSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
|
||||
getVcs().getCheckinEnvironment().scheduleMissingFileForDeletion(Arrays.asList(path));
|
||||
getChanges().assertTotalItems(1);
|
||||
changes.assertLocallyDeleted(path);
|
||||
}
|
||||
|
||||
// modified [rename] -> external delete, don't schedule for deletion -> locally missing (modified name)
|
||||
@Test
|
||||
public void testRenamedToLocallyMissing() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
final String newName = "Folder_renamed";
|
||||
rename(folder, newName);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
deleteFileExternally(folder);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
FilePath after = getChildPath(mySandboxRoot, newName);
|
||||
changes.assertLocallyDeleted(after);
|
||||
}
|
||||
|
||||
// modified [rename] -> delete, schedule for deletion -> schedule for deletion (original name)
|
||||
@Test
|
||||
public void testRenamedToScheduledForDeletion() throws Exception {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
final VirtualFile folder = createDirInCommand(mySandboxRoot, "Folder");
|
||||
FilePath before = TfsFileUtil.getFilePath(folder);
|
||||
commit(getChanges().getChanges(), "unittest");
|
||||
|
||||
final String newName = "Folder_renamed";
|
||||
rename(folder, newName);
|
||||
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
|
||||
deleteFileInCommand(folder);
|
||||
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(1);
|
||||
changes.assertScheduledForDeletion(before);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
public class TestUndoUpdateChanges extends TFSTestCase {
|
||||
|
||||
/*
|
||||
Folder and file changes:
|
||||
------------------------
|
||||
|
||||
+ 1. UP TO DATE [CONTENT CHANGED] in
|
||||
(nothing to check) up to date
|
||||
+ renamed
|
||||
+ moved
|
||||
|
||||
2. ADD in
|
||||
up to date
|
||||
added
|
||||
renamed
|
||||
moved
|
||||
|
||||
3. DELETE in
|
||||
up to date
|
||||
renamed
|
||||
moved
|
||||
deleted
|
||||
locally missing
|
||||
|
||||
4. RENAME [CONTENT CHANGED] in
|
||||
+ up to date
|
||||
renamed
|
||||
moved
|
||||
|
||||
5. MOVE [CONTENT CHANGED] in
|
||||
+ up to date -> up to date
|
||||
up to date -> added
|
||||
up to date -> renamed
|
||||
up to date -> moved (target)
|
||||
renamed (source) -> up to date
|
||||
renamed (source) -> added
|
||||
renamed (source) -> other one renamed (target)
|
||||
renamed (source) -> moved (target)
|
||||
moved (source) -> up to date
|
||||
moved (source) -> added
|
||||
moved (source) -> renamed (target)
|
||||
moved (source) -> other one moved (target)
|
||||
deleted (source) -> up to date
|
||||
deleted (source) -> added
|
||||
deleted (source) -> renamed (target)
|
||||
deleted (source) -> moved (target)
|
||||
|
||||
|
||||
|
||||
6. LOCALLY MISSING in
|
||||
added (added and externally deleted)
|
||||
up to date
|
||||
renamed
|
||||
moved
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestUpdate extends TFSTestCase {
|
||||
|
||||
@Test
|
||||
public void testUpdate() throws VcsException, IOException {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
|
||||
final VirtualFile root = createDirInCommand(mySandboxRoot, "root");
|
||||
commit(getChanges().getChanges(), "first one");
|
||||
|
||||
Runnable testRevMinus2 = () -> assertFolder(root, 0);
|
||||
|
||||
final VirtualFile folder1 = createDirInCommand(root, "folder1");
|
||||
final String fileModifiedContent1 = "fileModifiedRev1";
|
||||
final VirtualFile fileModified = createFileInCommand(folder1, "fileModified", fileModifiedContent1);
|
||||
final FilePath fileModified_original = TfsFileUtil.getFilePath(fileModified);
|
||||
final String fileRenamedContent = "fileRenamedRev1";
|
||||
final VirtualFile fileRenamed = createFileInCommand(folder1, "filepathRenamed_original", fileRenamedContent);
|
||||
final FilePath filepathRenamed_original = TfsFileUtil.getFilePath(fileRenamed);
|
||||
final String fileRenamedModifiedContent1 = "fileRenamedModifiedRev1";
|
||||
final VirtualFile fileRenamedModified = createFileInCommand(folder1, "filepathRenamedModified_original", fileRenamedModifiedContent1);
|
||||
final FilePath filepathRenamedModified_original = TfsFileUtil.getFilePath(fileRenamedModified);
|
||||
final String fileDeletedContent = "fileDeletedRev1";
|
||||
final VirtualFile fileDeleted = createFileInCommand(folder1, "fileDeleted", fileDeletedContent);
|
||||
final FilePath filepathDeleted = TfsFileUtil.getFilePath(fileDeleted);
|
||||
final VirtualFile subfolderRenamed = createDirInCommand(folder1, "subfolderRenamed_original");
|
||||
final FilePath filepathSubfolderRenamedOriginal = TfsFileUtil.getFilePath(subfolderRenamed);
|
||||
final VirtualFile subfolderDeleted = createDirInCommand(folder1, "subfolderDeleted");
|
||||
final FilePath filepathSubfolderDeleted = TfsFileUtil.getFilePath(subfolderDeleted);
|
||||
final VirtualFile subfolderMoved = createDirInCommand(folder1, "subfolderMoved");
|
||||
final FilePath filepathSubfolderMovedOriginal = TfsFileUtil.getFilePath(subfolderMoved);
|
||||
|
||||
final String comment2 = "test rev2 committed";
|
||||
commit(getChanges().getChanges(), comment2);
|
||||
|
||||
Runnable testRevMinus1 = () -> {
|
||||
assertFolder(root, 1);
|
||||
assertFolder(folder1, 7);
|
||||
|
||||
assertFolder(filepathSubfolderMovedOriginal, 0);
|
||||
assertFolder(filepathSubfolderRenamedOriginal, 0);
|
||||
assertFolder(filepathSubfolderDeleted, 0);
|
||||
|
||||
assertFile(filepathDeleted, fileDeletedContent, false);
|
||||
assertFile(fileModified_original, fileModifiedContent1, false);
|
||||
assertFile(filepathRenamed_original, fileRenamedContent, false);
|
||||
assertFile(filepathRenamedModified_original, fileRenamedModifiedContent1, false);
|
||||
};
|
||||
|
||||
editFiles(fileModified, fileRenamedModified);
|
||||
final String fileModifiedContent2 = "fileModifiedRev2";
|
||||
setFileContent(fileModified, fileModifiedContent2);
|
||||
rename(fileRenamed, "fileRenamed_renamed");
|
||||
rename(fileRenamedModified, "fileRenamedModified_renamed");
|
||||
final String fileRenamedModifiedContent2 = "fileRenamedModifiedRev2";
|
||||
setFileContent(fileRenamedModified, fileRenamedModifiedContent2);
|
||||
|
||||
final String fileCreatedContent = "fileCreatedContent";
|
||||
final VirtualFile fileCreated = createFileInCommand(root, "fileCreated", fileCreatedContent);
|
||||
deleteFileInCommand(fileDeleted);
|
||||
|
||||
deleteFileInCommand(subfolderDeleted);
|
||||
rename(subfolderRenamed, "subfolderRenamed_newname");
|
||||
|
||||
final VirtualFile subfolderA = createDirInCommand(root, "subfolderA");
|
||||
final VirtualFile subfolderB = createDirInCommand(subfolderA, "subfolderB");
|
||||
moveFileInCommand(subfolderMoved, subfolderB);
|
||||
|
||||
final String comment3 = "test rev3 committed";
|
||||
commit(getChanges().getChanges(), comment3);
|
||||
|
||||
Runnable testLastRev = () -> {
|
||||
assertFolder(root, 3);
|
||||
|
||||
assertFolder(folder1, 4);
|
||||
|
||||
assertFolder(subfolderRenamed, 0);
|
||||
assertFile(fileModified, fileModifiedContent2, false);
|
||||
assertFile(fileRenamed, fileRenamedContent, false);
|
||||
assertFile(fileRenamedModified, fileRenamedModifiedContent2, false);
|
||||
|
||||
assertFolder(subfolderA, 1);
|
||||
assertFolder(subfolderB, 1);
|
||||
assertFolder(subfolderMoved, 0);
|
||||
|
||||
assertFile(fileCreated, fileCreatedContent, false);
|
||||
};
|
||||
|
||||
int latestRevisionNumber = getLatestRevisionNumber(root);
|
||||
|
||||
update(root, latestRevisionNumber - 1);
|
||||
testRevMinus1.run();
|
||||
update(root, latestRevisionNumber - 2);
|
||||
testRevMinus2.run();
|
||||
update(root, latestRevisionNumber - 1);
|
||||
testRevMinus1.run();
|
||||
update(root, latestRevisionNumber);
|
||||
testLastRev.run();
|
||||
update(root, latestRevisionNumber - 2);
|
||||
testRevMinus2.run();
|
||||
update(root, latestRevisionNumber);
|
||||
testLastRev.run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package org.jetbrains.tfsIntegration.tests.annotation;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.openapi.vcs.annotate.LineAnnotationAspect;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.tfsIntegration.core.TFSChangeList;
|
||||
import org.jetbrains.tfsIntegration.tests.TFSTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestAnnotation extends TFSTestCase {
|
||||
|
||||
@Test
|
||||
public void testAnnotations() throws VcsException, IOException {
|
||||
final String[] contents = {"", "1\r1\r1\r1\r1\n", "\r\n2\r\n2\n2\r\n1\r1\n2\n1\r\n\r", "\r\n\n2\r\n2\n2\r\n1\r1\r\n3\r3\n\r\n"};
|
||||
final int[] expectedRevisions = {2, 3, 2, 2, 2, 1, 1, 3, 3, 2};
|
||||
|
||||
FilePath file = getChildPath(mySandboxRoot, "file.txt");
|
||||
createFileInCommand(file, contents[0]);
|
||||
commit();
|
||||
|
||||
for (int i = 1; i < contents.length; i++) {
|
||||
editFiles(file);
|
||||
setFileContent(file, contents[i]);
|
||||
commit();
|
||||
}
|
||||
|
||||
VirtualFile vf = file.getVirtualFile();
|
||||
final FileAnnotation fileAnnotation = createTestAnnotation(getVcs().getAnnotationProvider(), vf);
|
||||
Assert.assertEquals(fileAnnotation.getAnnotatedContent(), contents[contents.length - 1]);
|
||||
|
||||
LineAnnotationAspect[] aspects = fileAnnotation.getAspects();
|
||||
Assert.assertEquals(aspects.length, 3);
|
||||
|
||||
final RepositoryLocation location = getVcs().getCommittedChangesProvider().getLocationFor(file);
|
||||
final List<TFSChangeList> historyList =
|
||||
getVcs().getCommittedChangesProvider().getCommittedChanges(new ChangeBrowserSettings(), location, 0);
|
||||
|
||||
for (int line = 0; line < expectedRevisions.length; line++) {
|
||||
Assert.assertEquals(aspects[0].getValue(line),
|
||||
String.valueOf(historyList.get(contents.length - 1 - expectedRevisions[line]).getNumber()));
|
||||
}
|
||||
Assert.assertEquals(aspects[0].getValue(expectedRevisions.length), "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
public enum Resolution {
|
||||
AcceptYours, AcceptTheirs, Merge
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
abstract class TestFileConflict extends TestSingleConflict {
|
||||
|
||||
protected static final String BASE_FILENAME = "base.txt";
|
||||
protected static final String YOURS_FILENAME = "yours.txt";
|
||||
protected static final String THEIRS_FILENAME = "theirs.txt";
|
||||
protected static final String MERGED_FILENAME = "merged.txt";
|
||||
|
||||
|
||||
protected static final String BASE_CONTENT = "base_content";
|
||||
protected static final String THEIRS_CONTENT = "theirs_content";
|
||||
protected static final String YOURS_CONTENT = "yours_content";
|
||||
protected static final String MERGED_CONTENT = "merged_content";
|
||||
|
||||
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestFileYoursAddedTheirsAdded extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
|
||||
@Override
|
||||
protected boolean updateToThePast() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() throws VcsException {
|
||||
createFileInCommand(myBaseFile, THEIRS_CONTENT);
|
||||
commit(getChanges().getChanges(), "0-th revision");
|
||||
deleteFileInCommand(myBaseFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
Assert.fail("Not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() {
|
||||
Assert.fail("Not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, THEIRS_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("can't merge");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("can't merge");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(
|
||||
new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Add, ChangeType_type0.Edit, ChangeType_type0.Encoding));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.None));
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitemsrc());
|
||||
Assert.assertNull(conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("Not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// don't test, otherwise TF14052: Cannot specify AcceptYours to resolve a namespace conflict.
|
||||
//@Test
|
||||
//public void testAcceptYours() throws VcsException, IOException {
|
||||
// super.testAcceptYours();
|
||||
//}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestFileYoursDeletedTheirsDeleted extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
deleteFileInCommand(myBaseFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
deleteFileInCommand(myBaseFile);
|
||||
// need to try commit to have conflict reported on next Get
|
||||
try {
|
||||
commitThrowException(getChanges().getChanges(), "should fail");
|
||||
Assert.fail("Should fail");
|
||||
}
|
||||
catch (VcsException e) {
|
||||
// exception expected: A newer version of base.txt exists on the server.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
checkResolvedYoursState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertNull(conflict.getSrclitem());
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestFileYoursDeletedTheirsModified extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() throws VcsException, IOException {
|
||||
editFiles(myBaseFile);
|
||||
setFileContent(myBaseFile, THEIRS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
deleteFileInCommand(myBaseFile);
|
||||
// need to try commit to have conflict reported on next Get
|
||||
try {
|
||||
commitThrowException(getChanges().getChanges(), "should fail");
|
||||
Assert.fail("Should fail");
|
||||
}
|
||||
catch (VcsException e) {
|
||||
// exception expected: A newer version of base.txt exists on the server.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myBaseFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, THEIRS_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Edit));
|
||||
Assert.assertNull(conflict.getSrclitem());
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestFileYoursDeletedTheirsRenamed extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myTheirsFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myTheirsFile = getChildPath(mySandboxRoot, THEIRS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
rename(myBaseFile, THEIRS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
deleteFileInCommand(myBaseFile);
|
||||
// need to try commit to have conflict reported on next Get
|
||||
try {
|
||||
commitThrowException(getChanges().getChanges(), "should fail");
|
||||
Assert.fail("Should fail");
|
||||
}
|
||||
catch (VcsException e) {
|
||||
// exception expected: A newer version of base.txt exists on the server.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myTheirsFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, BASE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertNull(conflict.getSrclitem());
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestFileYoursDeletedTheirsRenamedModified extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myTheirsFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myTheirsFile = getChildPath(mySandboxRoot, THEIRS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() throws VcsException, IOException {
|
||||
rename(myBaseFile, THEIRS_FILENAME);
|
||||
editFiles(myTheirsFile);
|
||||
setFileContent(myTheirsFile, THEIRS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
deleteFileInCommand(myBaseFile);
|
||||
// need to try commit to have conflict reported on next Get
|
||||
try {
|
||||
commitThrowException(getChanges().getChanges(), "should fail");
|
||||
Assert.fail("Should fail");
|
||||
}
|
||||
catch (VcsException e) {
|
||||
// exception expected: A newer version of base.txt exists on the server.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myTheirsFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, THEIRS_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Edit, ChangeType_type0.Rename));
|
||||
Assert.assertNull(conflict.getSrclitem());
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursModifiedTheirsMissing extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
deleteFileInCommand(myBaseFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() throws IOException, VcsException {
|
||||
editFiles(myBaseFile);
|
||||
setFileContent(myBaseFile, YOURS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myBaseFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, YOURS_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("can't merge");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("can't merge");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Edit));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertNull(conflict.getTgtlitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("Not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursModifiedTheirsModified extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() throws VcsException, IOException {
|
||||
editFiles(myBaseFile);
|
||||
setFileContent(myBaseFile, THEIRS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() throws IOException, VcsException {
|
||||
editFiles(myBaseFile);
|
||||
setFileContent(myBaseFile, YOURS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myBaseFile, THEIRS_CONTENT, YOURS_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, YOURS_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, THEIRS_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
|
||||
getChanges().assertModified(myBaseFile, THEIRS_CONTENT, MERGED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, MERGED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Edit));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Edit));
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("can't merge");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
return MERGED_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// Notes
|
||||
// 1. When choosing 'AcceptYours' solution, TFS 2005 SP1 and TFS 2008 server return GetOperation to rename local file to 'theirs' name.
|
||||
// In the same time TFS 2005 RTM server does not return any get operation
|
||||
//
|
||||
|
||||
public class TestFileYoursModifiedTheirsRenamed extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myTheirsFile;
|
||||
private FilePath myMergedFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myTheirsFile = getChildPath(mySandboxRoot, THEIRS_FILENAME);
|
||||
myMergedFile = getChildPath(mySandboxRoot, MERGED_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
rename(myBaseFile, myTheirsFile.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() throws IOException, VcsException {
|
||||
editFiles(myBaseFile);
|
||||
setFileContent(myBaseFile, YOURS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
if (SERVER_VERSION == TfsServerVersion.TFS_2005_RTM) {
|
||||
// see also Note 1
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myBaseFile, BASE_CONTENT, YOURS_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, YOURS_CONTENT, true);
|
||||
}
|
||||
else {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myTheirsFile, BASE_CONTENT, YOURS_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, YOURS_CONTENT, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, BASE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myMergedFile, BASE_CONTENT, MERGED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myMergedFile, MERGED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Edit));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myTheirsFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() throws TfsException {
|
||||
return findServerPath(myMergedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
return MERGED_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursModifiedTheirsRenamedModified extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myTheirsFile;
|
||||
private FilePath myMergedFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myTheirsFile = getChildPath(mySandboxRoot, THEIRS_FILENAME);
|
||||
myMergedFile = getChildPath(mySandboxRoot, MERGED_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() throws VcsException, IOException {
|
||||
rename(myBaseFile, THEIRS_FILENAME);
|
||||
editFiles(myTheirsFile);
|
||||
setFileContent(myTheirsFile, THEIRS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() throws IOException, VcsException {
|
||||
editFiles(myBaseFile);
|
||||
setFileContent(myBaseFile, YOURS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
if (SERVER_VERSION == TfsServerVersion.TFS_2005_RTM) {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myBaseFile, THEIRS_CONTENT, YOURS_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, YOURS_CONTENT, true);
|
||||
}
|
||||
else {
|
||||
// see also Note 1 in TestFileYoursModifiedTheirsRenamed
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myTheirsFile, THEIRS_CONTENT, YOURS_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, YOURS_CONTENT, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, THEIRS_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myMergedFile, THEIRS_CONTENT, MERGED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myMergedFile, MERGED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Edit));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Edit, ChangeType_type0.Rename));
|
||||
Assert.assertEquals(myBaseFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myTheirsFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() throws TfsException {
|
||||
return findServerPath(myMergedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
return MERGED_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursRenamedModifiedTheirsMissing extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myYoursFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myYoursFile = getChildPath(mySandboxRoot, YOURS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
deleteFileInCommand(myBaseFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() throws IOException, VcsException {
|
||||
editFiles(myBaseFile);
|
||||
rename(myBaseFile, YOURS_FILENAME);
|
||||
setFileContent(myYoursFile, YOURS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myBaseFile, myYoursFile, BASE_CONTENT, YOURS_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myYoursFile, YOURS_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("can't merge");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Edit, ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertNull(conflict.getTgtlitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursRenamedModifiedTheirsModified extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myYoursFile;
|
||||
private FilePath myMergedFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myYoursFile = getChildPath(mySandboxRoot, YOURS_FILENAME);
|
||||
myMergedFile = getChildPath(mySandboxRoot, MERGED_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() throws VcsException, IOException {
|
||||
editFiles(myBaseFile);
|
||||
setFileContent(myBaseFile, THEIRS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() throws IOException, VcsException {
|
||||
rename(myBaseFile, YOURS_FILENAME);
|
||||
editFiles(myYoursFile);
|
||||
setFileContent(myYoursFile, YOURS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myBaseFile, myYoursFile, THEIRS_CONTENT, YOURS_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myYoursFile, YOURS_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, THEIRS_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
|
||||
getChanges().assertRenamedOrMoved(myBaseFile, myMergedFile, THEIRS_CONTENT, MERGED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myMergedFile, MERGED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Edit, ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Edit));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() throws TfsException {
|
||||
return findServerPath(myMergedFile);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
return MERGED_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursRenamedModifiedTheirsRenamed extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myYoursFile;
|
||||
private FilePath myTheirsFile;
|
||||
private FilePath myMergedFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myYoursFile = getChildPath(mySandboxRoot, YOURS_FILENAME);
|
||||
myTheirsFile = getChildPath(mySandboxRoot, THEIRS_FILENAME);
|
||||
myMergedFile = getChildPath(mySandboxRoot, MERGED_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
rename(myBaseFile, THEIRS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() throws IOException, VcsException {
|
||||
rename(myBaseFile, YOURS_FILENAME);
|
||||
editFiles(myYoursFile);
|
||||
setFileContent(myYoursFile, YOURS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myYoursFile, BASE_CONTENT, YOURS_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myYoursFile, YOURS_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, BASE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myMergedFile, BASE_CONTENT, MERGED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myMergedFile, MERGED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Edit, ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() throws TfsException {
|
||||
return findServerPath(myMergedFile);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
return MERGED_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursRenamedModifiedTheirsRenamedModified extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myYoursFile;
|
||||
private FilePath myTheirsFile;
|
||||
private FilePath myMergedFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myYoursFile = getChildPath(mySandboxRoot, YOURS_FILENAME);
|
||||
myTheirsFile = getChildPath(mySandboxRoot, THEIRS_FILENAME);
|
||||
myMergedFile = getChildPath(mySandboxRoot, MERGED_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() throws VcsException, IOException {
|
||||
rename(myBaseFile, THEIRS_FILENAME);
|
||||
editFiles(myTheirsFile);
|
||||
setFileContent(myTheirsFile, THEIRS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() throws IOException, VcsException {
|
||||
rename(myBaseFile, YOURS_FILENAME);
|
||||
editFiles(myYoursFile);
|
||||
setFileContent(myYoursFile, YOURS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myYoursFile, THEIRS_CONTENT, YOURS_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myYoursFile, YOURS_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, THEIRS_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myMergedFile, THEIRS_CONTENT, MERGED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myMergedFile, MERGED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Edit, ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Edit, ChangeType_type0.Rename));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() throws TfsException {
|
||||
return findServerPath(myMergedFile);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
return MERGED_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return YOURS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursRenamedTheirsMissing extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myYoursFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myYoursFile = getChildPath(mySandboxRoot, YOURS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
deleteFileInCommand(myBaseFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
rename(myBaseFile, YOURS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myBaseFile, myYoursFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myYoursFile, BASE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("can't merge");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertNull(conflict.getTgtlitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursRenamedTheirsModified extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myYoursFile;
|
||||
private FilePath myMergedFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myYoursFile = getChildPath(mySandboxRoot, YOURS_FILENAME);
|
||||
myMergedFile = getChildPath(mySandboxRoot, MERGED_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() throws VcsException, IOException {
|
||||
editFiles(myBaseFile);
|
||||
setFileContent(myBaseFile, THEIRS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
rename(myBaseFile, YOURS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myBaseFile, myYoursFile, THEIRS_CONTENT, BASE_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myYoursFile, BASE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myBaseFile, THEIRS_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myBaseFile, myMergedFile, THEIRS_CONTENT, MERGED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myMergedFile, MERGED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Edit));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() throws TfsException {
|
||||
return findServerPath(myMergedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
return MERGED_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursRenamedTheirsRenamed extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myYoursFile;
|
||||
private FilePath myTheirsFile;
|
||||
private FilePath myMergedFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myYoursFile = getChildPath(mySandboxRoot, YOURS_FILENAME);
|
||||
myTheirsFile = getChildPath(mySandboxRoot, THEIRS_FILENAME);
|
||||
myMergedFile = getChildPath(mySandboxRoot, MERGED_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
rename(myBaseFile, THEIRS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
rename(myBaseFile, YOURS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myYoursFile, BASE_CONTENT, BASE_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myYoursFile, BASE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, BASE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myMergedFile, BASE_CONTENT, BASE_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myMergedFile, BASE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() throws TfsException {
|
||||
return findServerPath(myMergedFile);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileYoursRenamedTheirsRenamedModified extends TestFileConflict {
|
||||
|
||||
private FilePath myBaseFile;
|
||||
private FilePath myYoursFile;
|
||||
private FilePath myTheirsFile;
|
||||
private FilePath myMergedFile;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFile = getChildPath(mySandboxRoot, BASE_FILENAME);
|
||||
myYoursFile = getChildPath(mySandboxRoot, YOURS_FILENAME);
|
||||
myTheirsFile = getChildPath(mySandboxRoot, THEIRS_FILENAME);
|
||||
myMergedFile = getChildPath(mySandboxRoot, MERGED_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createFileInCommand(myBaseFile, BASE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() throws VcsException, IOException {
|
||||
rename(myBaseFile, THEIRS_FILENAME);
|
||||
editFiles(myTheirsFile);
|
||||
setFileContent(myTheirsFile, THEIRS_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
rename(myBaseFile, YOURS_FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myYoursFile, THEIRS_CONTENT, BASE_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myYoursFile, BASE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myTheirsFile, THEIRS_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
|
||||
getChanges().assertRenamedOrMoved(myTheirsFile, myMergedFile, THEIRS_CONTENT, MERGED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myMergedFile, MERGED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Edit, ChangeType_type0.Rename));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getSrclitem(), false));
|
||||
Assert.assertEquals(myYoursFile, VersionControlPath.getFilePath(conflict.getTgtlitem(), false));
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFile), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFile), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFile), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() throws TfsException {
|
||||
return findServerPath(myMergedFile);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
return MERGED_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
return BASE_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
return THEIRS_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
abstract class TestFolderConflict extends TestSingleConflict {
|
||||
|
||||
protected static final String BASE_FOLDERNAME = "Base";
|
||||
protected static final String YOURS_FOLDERNAME = "Yours";
|
||||
protected static final String THEIRS_FOLDERNAME = "Theirs";
|
||||
protected static final String MERGED_FOLDERNAME = "Merged";
|
||||
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestFolderYoursAddedTheirsAdded extends TestFolderConflict {
|
||||
|
||||
private FilePath myBaseFolder;
|
||||
|
||||
@Override
|
||||
protected boolean updateToThePast() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFolder = getChildPath(mySandboxRoot, BASE_FOLDERNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() throws VcsException {
|
||||
createDirInCommand(myBaseFolder);
|
||||
commit(getChanges().getChanges(), "0-th revision");
|
||||
deleteFileInCommand(myBaseFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
Assert.fail("Not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
createDirInCommand(myBaseFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() {
|
||||
Assert.fail("Not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myBaseFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("can't merge");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("can't merge");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(
|
||||
new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Add, ChangeType_type0.Encoding));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.None));
|
||||
Assert.assertEquals(myBaseFolder, VersionControlPath.getFilePath(conflict.getSrclitem(), true));
|
||||
Assert.assertEquals(myBaseFolder, VersionControlPath.getFilePath(conflict.getTgtlitem(), true));
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getYsitemsrc());
|
||||
Assert.assertNull(conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("Not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// don't test, otherwise TF14052: Cannot specify AcceptYours to resolve a namespace conflict.
|
||||
//@Test
|
||||
//public void testAcceptYours() throws VcsException, IOException {
|
||||
// super.testAcceptYours();
|
||||
//}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestFolderYoursDeletedTheirsDeleted extends TestFolderConflict {
|
||||
|
||||
private FilePath myBaseFolder;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFolder = getChildPath(mySandboxRoot, BASE_FOLDERNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createDirInCommand(myBaseFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
deleteFileInCommand(myBaseFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
deleteFileInCommand(myBaseFolder);
|
||||
// need to try commit to have conflict reported on next Get
|
||||
try {
|
||||
commitThrowException(getChanges().getChanges(), "should fail");
|
||||
Assert.fail("Should fail");
|
||||
}
|
||||
catch (VcsException e) {
|
||||
// exception expected: A newer version of base.txt exists on the server.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
checkResolvedYoursState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertNull(conflict.getSrclitem());
|
||||
Assert.assertEquals(myBaseFolder, VersionControlPath.getFilePath(conflict.getTgtlitem(), true));
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestFolderYoursDeletedTheirsRenamed extends TestFolderConflict {
|
||||
|
||||
private FilePath myBaseFolder;
|
||||
private FilePath myTheirsFolder;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFolder = getChildPath(mySandboxRoot, BASE_FOLDERNAME);
|
||||
myTheirsFolder = getChildPath(mySandboxRoot, THEIRS_FOLDERNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createDirInCommand(myBaseFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
rename(myBaseFolder, THEIRS_FOLDERNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
deleteFileInCommand(myBaseFolder);
|
||||
// need to try commit to have conflict reported on next Get
|
||||
try {
|
||||
commitThrowException(getChanges().getChanges(), "should fail");
|
||||
Assert.fail("Should fail");
|
||||
}
|
||||
catch (VcsException e) {
|
||||
// exception expected: A newer version of base.txt exists on the server.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myTheirsFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myTheirsFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertNull(conflict.getSrclitem());
|
||||
Assert.assertEquals(myBaseFolder, VersionControlPath.getFilePath(conflict.getTgtlitem(), true));
|
||||
Assert.assertEquals(findServerPath(myTheirsFolder), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFolder), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFolderYoursRenamedTheirsMissing extends TestFolderConflict {
|
||||
|
||||
private FilePath myBaseFolder;
|
||||
private FilePath myYoursFolder;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFolder = getChildPath(mySandboxRoot, BASE_FOLDERNAME);
|
||||
myYoursFolder = getChildPath(mySandboxRoot, YOURS_FOLDERNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createDirInCommand(myBaseFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
deleteFileInCommand(myBaseFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
rename(myBaseFolder, YOURS_FOLDERNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myBaseFolder, myYoursFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myYoursFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() {
|
||||
Assert.fail("can't merge");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Delete));
|
||||
Assert.assertEquals(myYoursFolder, VersionControlPath.getFilePath(conflict.getSrclitem(), true));
|
||||
Assert.assertNull(conflict.getTgtlitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFolder), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFolder), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.ChangeType_type0;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.ChangeTypeMask;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.VersionControlPath;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFolderYoursRenamedTheirsRenamed extends TestFolderConflict {
|
||||
|
||||
private FilePath myBaseFolder;
|
||||
private FilePath myYoursFolder;
|
||||
private FilePath myTheirsFolder;
|
||||
private FilePath myMergedFolder;
|
||||
|
||||
@Override
|
||||
protected boolean canMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseFolder = getChildPath(mySandboxRoot, BASE_FOLDERNAME);
|
||||
myYoursFolder = getChildPath(mySandboxRoot, YOURS_FOLDERNAME);
|
||||
myTheirsFolder = getChildPath(mySandboxRoot, THEIRS_FOLDERNAME);
|
||||
myMergedFolder = getChildPath(mySandboxRoot, MERGED_FOLDERNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createDirInCommand(myBaseFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
rename(myBaseFolder, THEIRS_FOLDERNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
rename(myBaseFolder, YOURS_FOLDERNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedYoursState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myTheirsFolder, myYoursFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myYoursFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedTheirsState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myTheirsFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedMergeState() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myTheirsFolder, myMergedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myMergedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkConflictProperties(final Conflict conflict) throws TfsException {
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getYchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertTrue(new ChangeTypeMask(conflict.getBchg()).containsOnly(ChangeType_type0.Rename));
|
||||
Assert.assertEquals(myYoursFolder, VersionControlPath.getFilePath(conflict.getSrclitem(), true));
|
||||
Assert.assertEquals(myYoursFolder, VersionControlPath.getFilePath(conflict.getTgtlitem(), true));
|
||||
|
||||
Assert.assertEquals(findServerPath(myYoursFolder), conflict.getYsitem());
|
||||
Assert.assertEquals(findServerPath(myYoursFolder), conflict.getYsitemsrc());
|
||||
Assert.assertEquals(findServerPath(myBaseFolder), conflict.getBsitem());
|
||||
Assert.assertEquals(findServerPath(myTheirsFolder), conflict.getTsitem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName() throws TfsException {
|
||||
return findServerPath(myMergedFolder);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException, IOException {
|
||||
super.testAcceptYours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException, IOException {
|
||||
super.testAcceptTheirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAcceptMerge() throws VcsException, IOException {
|
||||
super.testAcceptMerge();
|
||||
}
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.io.ReadOnlyAttributeUtil;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.WorkspaceInfo;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.conflicts.*;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.jetbrains.tfsIntegration.tests.TFSTestCase;
|
||||
import org.jetbrains.tfsIntegration.ui.ContentTriplet;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
abstract class TestSingleConflict extends TFSTestCase {
|
||||
|
||||
protected abstract boolean canMerge();
|
||||
|
||||
protected boolean updateToThePast() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void preparePaths();
|
||||
|
||||
protected abstract void prepareBaseRevision() throws VcsException;
|
||||
|
||||
protected abstract void prepareTargetRevision() throws VcsException, IOException;
|
||||
|
||||
protected abstract void makeLocalChanges() throws IOException, VcsException;
|
||||
|
||||
protected abstract void checkConflictProperties(Conflict conflict) throws TfsException;
|
||||
|
||||
protected abstract void checkResolvedYoursState() throws VcsException;
|
||||
|
||||
protected abstract void checkResolvedTheirsState() throws VcsException;
|
||||
|
||||
protected abstract void checkResolvedMergeState() throws VcsException;
|
||||
|
||||
@Nullable
|
||||
protected String getExpectedBaseContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getExpectedYoursContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getExpectedTheirsContent() {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract String mergeContent();
|
||||
|
||||
@Nullable
|
||||
protected abstract String mergeName() throws TfsException;
|
||||
|
||||
private void doTest(final Resolution resolution) throws VcsException, IOException {
|
||||
ConflictsEnvironment.setConflictsHandler(new ConflictsHandlerImpl(resolution));
|
||||
ConflictsEnvironment.setNameMerger(new NameMergerImpl());
|
||||
ConflictsEnvironment.setContentMerger(new ContentMergerImpl());
|
||||
|
||||
try {
|
||||
preparePaths();
|
||||
prepareBaseRevision();
|
||||
commit(getChanges().getChanges(), "Base revision");
|
||||
if (updateToThePast()) {
|
||||
makeLocalChanges();
|
||||
updateTo(1);
|
||||
}
|
||||
else {
|
||||
prepareTargetRevision();
|
||||
commit(getChanges().getChanges(), "Target revision");
|
||||
updateTo(1);
|
||||
makeLocalChanges();
|
||||
updateTo(0);
|
||||
}
|
||||
|
||||
if (resolution == Resolution.AcceptYours) {
|
||||
checkResolvedYoursState();
|
||||
}
|
||||
else if (resolution == Resolution.AcceptTheirs) {
|
||||
checkResolvedTheirsState();
|
||||
}
|
||||
else {
|
||||
if (canMerge()) {
|
||||
checkResolvedMergeState();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
finally {
|
||||
ConflictsEnvironment.setConflictsHandler(null);
|
||||
ConflictsEnvironment.setNameMerger(null);
|
||||
ConflictsEnvironment.setContentMerger(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void testAcceptYours() throws VcsException, IOException {
|
||||
doTest(Resolution.AcceptYours);
|
||||
}
|
||||
|
||||
protected void testAcceptTheirs() throws VcsException, IOException {
|
||||
doTest(Resolution.AcceptTheirs);
|
||||
}
|
||||
|
||||
protected void testAcceptMerge() throws VcsException, IOException {
|
||||
doTest(Resolution.Merge);
|
||||
}
|
||||
|
||||
private class ConflictsHandlerImpl implements ConflictsHandler {
|
||||
private final Resolution myResolution;
|
||||
|
||||
ConflictsHandlerImpl(final Resolution resolution) {
|
||||
myResolution = resolution;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolveConflicts(final ResolveConflictHelper resolveConflictHelper) throws TfsException {
|
||||
Collection<Conflict> conflicts = resolveConflictHelper.getConflicts();
|
||||
Assert.assertEquals("Expected conflicts count differs: ", 1, conflicts.size());
|
||||
for (Conflict conflict : conflicts) {
|
||||
checkConflictProperties(conflict);
|
||||
try {
|
||||
if (myResolution == Resolution.AcceptYours) {
|
||||
resolveConflictHelper.acceptYours(conflict);
|
||||
}
|
||||
else if (myResolution == Resolution.AcceptTheirs) {
|
||||
resolveConflictHelper.acceptTheirs(conflict);
|
||||
}
|
||||
else {
|
||||
Assert.assertEquals(canMerge(), ResolveConflictHelper.canMerge(conflict));
|
||||
if (canMerge()) {
|
||||
resolveConflictHelper.acceptMerge(conflict);
|
||||
}
|
||||
else {
|
||||
resolveConflictHelper.skip(conflict);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (VcsException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
catch (IOException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class NameMergerImpl implements NameMerger {
|
||||
@Override
|
||||
@Nullable
|
||||
public String mergeName(final WorkspaceInfo workspace, final Conflict conflict, Project project) {
|
||||
try {
|
||||
return TestSingleConflict.this.mergeName();
|
||||
}
|
||||
catch (TfsException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ContentMergerImpl implements ContentMerger {
|
||||
@Override
|
||||
public boolean mergeContent(final Conflict conflict,
|
||||
final ContentTriplet contentTriplet,
|
||||
final Project project,
|
||||
final VirtualFile targetFile,
|
||||
final String localPathToDisplay,
|
||||
final VcsRevisionNumber serverVersion) throws IOException {
|
||||
Assert.assertEquals(getExpectedBaseContent(), new String(contentTriplet.baseContent, StandardCharsets.UTF_8));
|
||||
Assert.assertEquals(getExpectedYoursContent(), new String(contentTriplet.localContent, StandardCharsets.UTF_8));
|
||||
Assert.assertEquals(getExpectedTheirsContent(), new String(contentTriplet.serverContent, StandardCharsets.UTF_8));
|
||||
|
||||
ReadOnlyAttributeUtil.setReadOnlyAttribute(targetFile, false);
|
||||
setFileContent(targetFile, TestSingleConflict.this.mergeContent());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts.multiple;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.io.ReadOnlyAttributeUtil;
|
||||
import com.microsoft.schemas.teamfoundation._2005._06.versioncontrol.clientservices._03.Conflict;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.WorkspaceInfo;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.conflicts.*;
|
||||
import org.jetbrains.tfsIntegration.exceptions.TfsException;
|
||||
import org.jetbrains.tfsIntegration.tests.TFSTestCase;
|
||||
import org.jetbrains.tfsIntegration.tests.conflicts.Resolution;
|
||||
import org.jetbrains.tfsIntegration.ui.ContentTriplet;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral", "AutoUnboxing"})
|
||||
abstract class TestMultipleConflicts extends TFSTestCase {
|
||||
|
||||
interface ConflictingItem {
|
||||
}
|
||||
|
||||
protected abstract void preparePaths();
|
||||
|
||||
protected abstract void prepareBaseRevision();
|
||||
|
||||
protected abstract void prepareTargetRevision();
|
||||
|
||||
protected abstract void makeLocalChanges();
|
||||
|
||||
protected abstract void checkResolvedState(Map<ConflictingItem, Resolution> resolution) throws VcsException;
|
||||
|
||||
@Nullable
|
||||
protected abstract String mergeContent(ConflictingItem conflictingItem);
|
||||
|
||||
@Nullable
|
||||
protected abstract String mergeName(ConflictingItem conflictingItem);
|
||||
|
||||
protected abstract FilePath getPath(ConflictingItem conflictingItem);
|
||||
|
||||
@Nullable
|
||||
protected abstract byte[] getExpectedTheirsContent(final ConflictingItem conflictingItem);
|
||||
|
||||
@Nullable
|
||||
protected abstract byte[] getExpectedBaseContent(final ConflictingItem conflictingItem);
|
||||
|
||||
@Nullable
|
||||
protected abstract byte[] getExpectedYoursContent(final ConflictingItem conflictingItem);
|
||||
|
||||
|
||||
protected void doTest(List<Pair<ConflictingItem, Resolution>> resolutionPath) throws VcsException {
|
||||
try {
|
||||
preparePaths();
|
||||
prepareBaseRevision();
|
||||
|
||||
List<Pair<Integer/*item id*/, Resolution>> itemId2Resolution = new ArrayList<>(resolutionPath.size());
|
||||
final Map<Integer, ConflictingItem> id2item = new HashMap<>();
|
||||
for (Pair<ConflictingItem, Resolution> pair : resolutionPath) {
|
||||
final int itemId = getItemId(getPath(pair.first));
|
||||
itemId2Resolution.add(Pair.create(itemId, pair.second));
|
||||
id2item.put(itemId, pair.first);
|
||||
}
|
||||
|
||||
final ConflictsHandlerImpl conflictsHandler = new ConflictsHandlerImpl(itemId2Resolution);
|
||||
ConflictsEnvironment.setConflictsHandler(conflictsHandler);
|
||||
ConflictsEnvironment.setNameMerger(new NameMergerImpl(id2item));
|
||||
ConflictsEnvironment.setContentMerger(new ContentMergerImpl(id2item));
|
||||
|
||||
|
||||
commit(getChanges().getChanges(), "Base revision");
|
||||
prepareTargetRevision();
|
||||
commit(getChanges().getChanges(), "Target revision");
|
||||
updateTo(1);
|
||||
makeLocalChanges();
|
||||
updateTo(0);
|
||||
|
||||
checkResolvedState(toMap(resolutionPath));
|
||||
}
|
||||
catch (TfsException e) {
|
||||
throw new VcsException(e);
|
||||
}
|
||||
finally {
|
||||
ConflictsEnvironment.setConflictsHandler(null);
|
||||
ConflictsEnvironment.setNameMerger(null);
|
||||
ConflictsEnvironment.setContentMerger(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConflictsHandlerImpl implements ConflictsHandler {
|
||||
private final List<Pair<Integer, Resolution>> myResolution;
|
||||
|
||||
ConflictsHandlerImpl(final List<Pair<Integer, Resolution>> resolution) {
|
||||
myResolution = resolution;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolveConflicts(final ResolveConflictHelper resolveConflictHelper) throws TfsException {
|
||||
Assert.assertEquals("Expected conflicts count differs: ", myResolution.size(), resolveConflictHelper.getConflicts().size());
|
||||
for (Pair<Integer, Resolution> resolutionPair : myResolution) {
|
||||
Conflict conflict = findConflict(resolveConflictHelper.getConflicts(), resolutionPair.first);
|
||||
try {
|
||||
if (resolutionPair.second == Resolution.AcceptYours) {
|
||||
resolveConflictHelper.acceptYours(conflict);
|
||||
}
|
||||
else if (resolutionPair.second == Resolution.AcceptTheirs) {
|
||||
resolveConflictHelper.acceptTheirs(conflict);
|
||||
}
|
||||
else {
|
||||
resolveConflictHelper.acceptMerge(conflict);
|
||||
}
|
||||
}
|
||||
catch (VcsException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
catch (IOException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
Assert.assertEquals("All conflicts should have been resolved", 0, resolveConflictHelper.getConflicts().size());
|
||||
}
|
||||
|
||||
private static Conflict findConflict(Collection<Conflict> conflicts, int itemId) {
|
||||
for (Conflict conflict : conflicts) {
|
||||
if (conflict.getBitemid() == itemId) {
|
||||
return conflict;
|
||||
}
|
||||
}
|
||||
Assert.fail("Conflict with item id " + itemId + " not found");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class NameMergerImpl implements NameMerger {
|
||||
private final Map<Integer /*itemId*/, ConflictingItem> myId2item;
|
||||
|
||||
NameMergerImpl(final Map<Integer, ConflictingItem> id2item) {
|
||||
myId2item = id2item;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String mergeName(final WorkspaceInfo workspace, final Conflict conflict, Project project) {
|
||||
return TestMultipleConflicts.this.mergeName(myId2item.get(conflict.getBitemid()));
|
||||
}
|
||||
}
|
||||
|
||||
private class ContentMergerImpl implements ContentMerger {
|
||||
private final Map<Integer /*itemId*/, ConflictingItem> myId2item;
|
||||
|
||||
ContentMergerImpl(final Map<Integer, ConflictingItem> id2item) {
|
||||
myId2item = id2item;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mergeContent(final Conflict conflict,
|
||||
final ContentTriplet contentTriplet,
|
||||
final Project project,
|
||||
final VirtualFile targetFile,
|
||||
final String localPathToDisplay,
|
||||
final VcsRevisionNumber serverVersion) throws IOException {
|
||||
Assert.assertEquals(getExpectedBaseContent(myId2item.get(conflict.getBitemid())), contentTriplet.baseContent);
|
||||
Assert.assertEquals(getExpectedYoursContent(myId2item.get(conflict.getBitemid())), contentTriplet.localContent);
|
||||
Assert.assertEquals(getExpectedTheirsContent(myId2item.get(conflict.getBitemid())), contentTriplet.serverContent);
|
||||
|
||||
ReadOnlyAttributeUtil.setReadOnlyAttribute(targetFile, false);
|
||||
setFileContent(targetFile, TestMultipleConflicts.this.mergeContent(myId2item.get(conflict.getBitemid())));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static <K, V> Map<K, V> toMap(List<Pair<K, V>> list) {
|
||||
Map<K, V> map = new HashMap<>(list.size());
|
||||
for (Pair<K, V> pair : list) {
|
||||
map.put(pair.first, pair.second);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.conflicts.multiple;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.tests.conflicts.Resolution;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
// Notes
|
||||
// 1. On update server sends get operation to rename BaseParent -> TheirsParent. After this operation was performed and ULV(TheirsFolder)
|
||||
// sent to server conflict.srclitem = BaseParent\YoursChild, not TheirsParent\YoursChild, so TheirsParent\YoursChild is preserved
|
||||
//
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class TestTheirsParentFolderRenamedYoursChildFolderRenamed extends TestMultipleConflicts {
|
||||
|
||||
private static final ConflictingItem CHILD = new ConflictingItem() {
|
||||
};
|
||||
|
||||
private FilePath myBaseParentFolder;
|
||||
private FilePath myTheirsParentFolder;
|
||||
private FilePath myMergedParentFolder;
|
||||
private FilePath myBaseChildFolderInBaseParent;
|
||||
private FilePath myBaseChildFolderInTheirsParent;
|
||||
private FilePath myBaseChildFolderInMergedParent;
|
||||
private FilePath myYoursChildFolderInBaseParent;
|
||||
private FilePath myYoursChildFolderInTheirsParent;
|
||||
private FilePath myYoursChildFolderInMergedParent;
|
||||
private FilePath myMergedChildFolderInBaseParent;
|
||||
private FilePath myMergedChildFolderInTheirsParent;
|
||||
private FilePath myMergedChildFolderInMergedParent;
|
||||
|
||||
private static final String BASE_PARENT_NAME = "BaseParent";
|
||||
private static final String THEIRS_PARENT_NAME = "TheirsParent";
|
||||
private static final String MERGED_PARENT_NAME = "MergedParent";
|
||||
|
||||
private static final String BASE_CHILD_NAME = "BaseChild";
|
||||
private static final String YOURS_CHILD_NAME = "YoursChild";
|
||||
private static final String MERGED_CHILD_NAME = "MergedChild";
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myBaseParentFolder = getChildPath(mySandboxRoot, BASE_PARENT_NAME);
|
||||
myTheirsParentFolder = getChildPath(mySandboxRoot, THEIRS_PARENT_NAME);
|
||||
myMergedParentFolder = getChildPath(mySandboxRoot, MERGED_PARENT_NAME);
|
||||
|
||||
myBaseChildFolderInBaseParent = getChildPath(myBaseParentFolder, BASE_CHILD_NAME);
|
||||
myBaseChildFolderInTheirsParent = getChildPath(myTheirsParentFolder, BASE_CHILD_NAME);
|
||||
myBaseChildFolderInMergedParent = getChildPath(myMergedParentFolder, BASE_CHILD_NAME);
|
||||
|
||||
myYoursChildFolderInBaseParent = getChildPath(myBaseParentFolder, YOURS_CHILD_NAME);
|
||||
myYoursChildFolderInTheirsParent = getChildPath(myTheirsParentFolder, YOURS_CHILD_NAME);
|
||||
myYoursChildFolderInMergedParent = getChildPath(myMergedParentFolder, YOURS_CHILD_NAME);
|
||||
|
||||
myMergedChildFolderInBaseParent = getChildPath(myBaseParentFolder, MERGED_CHILD_NAME);
|
||||
myMergedChildFolderInTheirsParent = getChildPath(myTheirsParentFolder, MERGED_CHILD_NAME);
|
||||
myMergedChildFolderInMergedParent = getChildPath(myMergedParentFolder, MERGED_CHILD_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareBaseRevision() {
|
||||
createDirInCommand(myBaseParentFolder);
|
||||
createDirInCommand(myBaseChildFolderInBaseParent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTargetRevision() {
|
||||
renameFileInCommand(myBaseParentFolder, THEIRS_PARENT_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeLocalChanges() {
|
||||
renameFileInCommand(myBaseChildFolderInBaseParent, YOURS_CHILD_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResolvedState(final Map<ConflictingItem, Resolution> resolution) throws VcsException {
|
||||
if (resolution.get(CHILD) == Resolution.AcceptTheirs) {
|
||||
// see Note1
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertUnversioned(myYoursChildFolderInTheirsParent);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myTheirsParentFolder, 2);
|
||||
assertFolder(myBaseChildFolderInTheirsParent, 0);
|
||||
assertFolder(myYoursChildFolderInTheirsParent, 0);
|
||||
}
|
||||
else if (resolution.get(CHILD) == Resolution.AcceptYours) {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myBaseChildFolderInBaseParent, myYoursChildFolderInTheirsParent);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myTheirsParentFolder, 1);
|
||||
assertFolder(myYoursChildFolderInTheirsParent, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeContent(final ConflictingItem conflictingItem) {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String mergeName(final ConflictingItem conflictingItem) {
|
||||
return MERGED_CHILD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FilePath getPath(final ConflictingItem conflictingItem) {
|
||||
if (CHILD.equals(conflictingItem)) {
|
||||
return myBaseChildFolderInBaseParent;
|
||||
}
|
||||
throw new IllegalArgumentException(conflictingItem.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected byte[] getExpectedTheirsContent(final ConflictingItem conflictingItem) {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected byte[] getExpectedBaseContent(final ConflictingItem conflictingItem) {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected byte[] getExpectedYoursContent(final ConflictingItem conflictingItem) {
|
||||
Assert.fail("not supported");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptTheirs() throws VcsException {
|
||||
doTest(Arrays.asList(Pair.create(CHILD, Resolution.AcceptTheirs)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptYours() throws VcsException {
|
||||
doTest(Arrays.asList(Pair.create(CHILD, Resolution.AcceptYours)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
package org.jetbrains.tfsIntegration.tests.memento;
|
||||
|
||||
import com.intellij.openapi.util.ClassLoaderUtil;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import junit.framework.TestCase;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.tfsIntegration.checkin.Memento;
|
||||
import org.jetbrains.tfsIntegration.checkin.XMLMemento;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
||||
// this test checks that IDEA's Memento implementation is identical to the Teamprise' one,
|
||||
// so that checkin policy definitions have the same storage format
|
||||
|
||||
public class MementoTest extends TestCase {
|
||||
|
||||
// TODO same code for XMLEntities as in JSUmlDataModelDump
|
||||
|
||||
// there's no access to XmlEntities.properties file (rt.jar) from com.intellij.util.lang.UrlClassLoader that is used in tests
|
||||
private static final String XML_ENTITIES_URL = "com.sun.org.apache.xml.internal.serializer.XMLEntities";
|
||||
private static final String XML_ENTITIES_CONTENT = "lt 60\ngt 62\nquot 34\namp 38";
|
||||
|
||||
|
||||
private Memento ideaMemento;
|
||||
private com.teamprise.core.memento.Memento teampriseMemento;
|
||||
|
||||
@Test
|
||||
public void testInitial() {
|
||||
Assert.assertEquals(ideaMemento.getBoolean("b"), teampriseMemento.getBoolean("b"));
|
||||
Assert.assertEquals(ideaMemento.getInteger("b"), teampriseMemento.getInteger("b"));
|
||||
Assert.assertEquals(ideaMemento.getFloat("b"), teampriseMemento.getFloat("b"));
|
||||
Assert.assertEquals(ideaMemento.getDouble("b"), teampriseMemento.getDouble("b"));
|
||||
Assert.assertEquals(ideaMemento.getString("b"), teampriseMemento.getString("b"));
|
||||
Assert.assertEquals(ideaMemento.getTextData(), teampriseMemento.getTextData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoolean() {
|
||||
ideaMemento.putBoolean("foo", Boolean.TRUE);
|
||||
teampriseMemento.putBoolean("foo", Boolean.TRUE);
|
||||
|
||||
Assert.assertEquals(Boolean.TRUE, ideaMemento.getBoolean("foo"));
|
||||
Assert.assertEquals(Boolean.TRUE, teampriseMemento.getBoolean("foo"));
|
||||
|
||||
ideaMemento.putBoolean("bar", Boolean.FALSE);
|
||||
teampriseMemento.putBoolean("bar", Boolean.FALSE);
|
||||
|
||||
Assert.assertEquals(Boolean.FALSE, ideaMemento.getBoolean("bar"));
|
||||
Assert.assertEquals(Boolean.FALSE, teampriseMemento.getBoolean("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDouble() {
|
||||
final Double doubleValue = 1.3445;
|
||||
ideaMemento.putDouble("d", doubleValue);
|
||||
teampriseMemento.putDouble("d", doubleValue);
|
||||
Assert.assertEquals(doubleValue, ideaMemento.getDouble("d"));
|
||||
Assert.assertEquals(doubleValue, teampriseMemento.getDouble("d"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFloat() {
|
||||
final Float floatValue = 34.5e3f;
|
||||
ideaMemento.putFloat("f", floatValue);
|
||||
teampriseMemento.putFloat("f", floatValue);
|
||||
|
||||
Assert.assertEquals(floatValue, ideaMemento.getFloat("f"));
|
||||
Assert.assertEquals(floatValue, teampriseMemento.getFloat("f"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInteger() throws Exception {
|
||||
final Integer intValue = 345346;
|
||||
ideaMemento.putInteger("i", intValue);
|
||||
teampriseMemento.putInteger("i", intValue);
|
||||
|
||||
Assert.assertEquals(intValue, ideaMemento.getInteger("i"));
|
||||
Assert.assertEquals(intValue, teampriseMemento.getInteger("i"));
|
||||
|
||||
checkEqual();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testString() throws Exception {
|
||||
final String value = "sdklfjsdf+3450395634657234+}{<?_)(@+_~@`3-!@#@!#$$%^%$^&(*&<>><";
|
||||
ideaMemento.putString("s", value);
|
||||
teampriseMemento.putString("s", value);
|
||||
|
||||
Assert.assertEquals(value, ideaMemento.getString("s"));
|
||||
Assert.assertEquals(value, teampriseMemento.getString("s"));
|
||||
|
||||
checkEqual();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextData() throws Exception {
|
||||
ideaMemento.putTextData("abcde la la<>3t5465$^#$^&U$%2344[]';?>><");
|
||||
teampriseMemento.putTextData("abcde la la<>3t5465$^#$^&U$%2344[]';?>><");
|
||||
checkEqual();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChild() throws Exception {
|
||||
final String name = "foobar";
|
||||
Memento ideaChild = ideaMemento.createChild(name);
|
||||
Assert.assertEquals(ideaChild.getName(), name);
|
||||
|
||||
teampriseMemento.createChild(name);
|
||||
checkEqual();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChildren() throws Exception {
|
||||
final String name = "foobar";
|
||||
ideaMemento.createChild(name).putInteger("i", 132);
|
||||
ideaMemento.createChild(name).putString("s", "abc");
|
||||
final Memento ideaLastChild = ideaMemento.createChild(name);
|
||||
ideaLastChild.putFloat("foo", 12345);
|
||||
ideaLastChild.putTextData("zz");
|
||||
|
||||
teampriseMemento.createChild(name).putInteger("i", 132);
|
||||
teampriseMemento.createChild(name).putString("s", "abc");
|
||||
final com.teamprise.core.memento.Memento teampriseLastChild = teampriseMemento.createChild(name);
|
||||
teampriseLastChild.putFloat("foo", 12345);
|
||||
teampriseLastChild.putTextData("zz");
|
||||
|
||||
Assert.assertEquals(ideaMemento.getChildren(name).length, teampriseMemento.getChildren(name).length);
|
||||
checkEqual();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyChild() throws Exception {
|
||||
final Memento ideaChild = ideaMemento.createChild("asd");
|
||||
ideaChild.putString("cc", "vv");
|
||||
ideaChild.putTextData("qqq");
|
||||
ideaMemento.copyChild(ideaChild);
|
||||
|
||||
final com.teamprise.core.memento.Memento teampriseChild = teampriseMemento.createChild("asd");
|
||||
teampriseChild.putString("cc", "vv");
|
||||
teampriseChild.putTextData("qqq");
|
||||
teampriseMemento.copyChild(teampriseChild);
|
||||
|
||||
checkEqual();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
ideaMemento = createIdeaMemento();
|
||||
teampriseMemento = createTeampriseMemento();
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
ideaMemento = null;
|
||||
teampriseMemento = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected static Memento createIdeaMemento() {
|
||||
return new XMLMemento(new Element("root"));
|
||||
}
|
||||
|
||||
protected void checkEqual() throws Exception {
|
||||
final String s1 = serialize(ideaMemento);
|
||||
final String s2 = serialize(teampriseMemento);
|
||||
compareXml(s1, s2);
|
||||
|
||||
final Memento idea = deserializeIdeaMemento(s1);
|
||||
final com.teamprise.core.memento.Memento teamprise = deserializeTeampriseMemento(s2);
|
||||
|
||||
compareXml(serialize(idea), serialize(teamprise));
|
||||
}
|
||||
|
||||
private static void compareXml(String s1, String s2) throws Exception {
|
||||
Element d1 = JDOMUtil.load(s1);
|
||||
Element d2 = JDOMUtil.load(s2);
|
||||
assert((d2).equals(d1));
|
||||
}
|
||||
|
||||
protected static com.teamprise.core.memento.Memento createTeampriseMemento() {
|
||||
return com.teamprise.core.memento.XMLMemento.createWriteRoot("root");
|
||||
}
|
||||
|
||||
protected static String serialize(Memento ideaMemento) {
|
||||
Document doc = new Document(((XMLMemento)ideaMemento).getElement().clone());
|
||||
return JDOMUtil.writeDocument(doc, "");
|
||||
}
|
||||
|
||||
protected static Memento deserializeIdeaMemento(String s) throws JDOMException, IOException {
|
||||
return new XMLMemento(JDOMUtil.load(s));
|
||||
}
|
||||
|
||||
protected static com.teamprise.core.memento.Memento deserializeTeampriseMemento(final String s) throws Exception {
|
||||
return runWithPatchedClassloader((ThrowableComputable<com.teamprise.core.memento.Memento, Exception>)() -> {
|
||||
// the same way as Teamprise does
|
||||
return com.teamprise.core.memento.XMLMemento.createReadRoot(new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8)));
|
||||
});
|
||||
}
|
||||
|
||||
protected static String serialize(final com.teamprise.core.memento.Memento teampriseMemento) throws Exception {
|
||||
// the same way as Teamprise does
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
runWithPatchedClassloader((ThrowableComputable<Void, Exception>)() -> {
|
||||
((com.teamprise.core.memento.XMLMemento)teampriseMemento).save(os);
|
||||
return null;
|
||||
});
|
||||
return os.toString("UTF-8");
|
||||
}
|
||||
|
||||
private static <T> T runWithPatchedClassloader(ThrowableComputable<T, Exception> computable) throws Exception {
|
||||
return ClassLoaderUtil.computeWithClassLoader(new URLClassLoader(new URL[0], Thread.currentThread().getContextClassLoader()) {
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String name) {
|
||||
if (XML_ENTITIES_URL.equals(name)) {
|
||||
return new ByteArrayInputStream(XML_ENTITIES_CONTENT.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return super.getResourceAsStream(name);
|
||||
}
|
||||
}, computable);
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.movechange;
|
||||
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.tests.TFSTestCase;
|
||||
import org.jetbrains.tfsIntegration.tests.TestChangeListBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class MoveChangeTestCase extends TFSTestCase {
|
||||
|
||||
protected enum ChangeStatus {
|
||||
NotDone,
|
||||
Pending,
|
||||
Committed,
|
||||
RolledBack
|
||||
}
|
||||
|
||||
protected abstract void preparePaths();
|
||||
|
||||
protected abstract void makeOriginalState();
|
||||
|
||||
protected abstract void makeChange(String changeId);
|
||||
|
||||
@Nullable
|
||||
protected abstract Change getChange(TestChangeListBuilder changes, String changeId);
|
||||
|
||||
protected abstract void checkChangesStatus(Map<String, ChangeStatus> changesStatus);
|
||||
|
||||
protected void testPendRollback(String[] changesSequence) throws VcsException {
|
||||
preparePaths();
|
||||
makeOriginalState();
|
||||
Map<String, ChangeStatus> changesStatus = new HashMap<>(changesSequence.length);
|
||||
for (String changeId : changesSequence) {
|
||||
changesStatus.put(changeId, ChangeStatus.NotDone);
|
||||
}
|
||||
checkChangesStatus(changesStatus);
|
||||
|
||||
// pend one by one
|
||||
for (String changeId : changesSequence) {
|
||||
makeChange(changeId);
|
||||
changesStatus.put(changeId, ChangeStatus.Pending);
|
||||
checkChangesStatus(changesStatus);
|
||||
updateTo(0);
|
||||
checkChangesStatus(changesStatus);
|
||||
}
|
||||
|
||||
// rollback one by one
|
||||
for (int i = changesSequence.length - 1; i >= 0; i--) {
|
||||
rollback(getChange(getChanges(), changesSequence[i]));
|
||||
changesStatus.put(changesSequence[i], ChangeStatus.RolledBack);
|
||||
checkChangesStatus(changesStatus);
|
||||
updateTo(0);
|
||||
checkChangesStatus(changesStatus);
|
||||
}
|
||||
}
|
||||
|
||||
protected void testCommit(String[] changesSequence) throws VcsException {
|
||||
preparePaths();
|
||||
makeOriginalState();
|
||||
|
||||
Map<String, ChangeStatus> changesStatus = new HashMap<>(changesSequence.length);
|
||||
// commit one by one
|
||||
for (String changeId : changesSequence) {
|
||||
makeChange(changeId);
|
||||
commit(getChange(getChanges(), changeId), changeId);
|
||||
changesStatus.put(changeId, ChangeStatus.Committed);
|
||||
checkChangesStatus(changesStatus);
|
||||
updateTo(0);
|
||||
checkChangesStatus(changesStatus);
|
||||
}
|
||||
|
||||
for (String changeId : changesSequence) {
|
||||
changesStatus.put(changeId, ChangeStatus.NotDone);
|
||||
}
|
||||
|
||||
for (int i = 0; i < changesSequence.length; i++) {
|
||||
updateTo(changesSequence.length - i);
|
||||
checkChangesStatus(changesStatus);
|
||||
changesStatus.put(changesSequence[i], ChangeStatus.Committed);
|
||||
}
|
||||
|
||||
updateTo(0);
|
||||
checkChangesStatus(changesStatus);
|
||||
}
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchange;
|
||||
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.tfsIntegration.tests.TFSTestCase;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public abstract class ParentChangeTestCase extends TFSTestCase {
|
||||
|
||||
protected abstract void preparePaths();
|
||||
|
||||
protected abstract void checkParentChangesPending() throws VcsException;
|
||||
|
||||
protected abstract void checkOriginalState() throws VcsException;
|
||||
|
||||
protected abstract void checkParentChangesCommitted() throws VcsException;
|
||||
|
||||
protected abstract void makeOriginalState() throws VcsException;
|
||||
|
||||
protected abstract void makeParentChanges();
|
||||
|
||||
protected abstract Collection<Change> getPendingParentChanges() throws VcsException;
|
||||
|
||||
|
||||
protected void doTest() throws VcsException {
|
||||
preparePaths();
|
||||
|
||||
makeOriginalState();
|
||||
checkOriginalState();
|
||||
|
||||
// check parent changes
|
||||
makeParentChanges();
|
||||
checkParentChangesPending();
|
||||
updateTo(0);
|
||||
checkParentChangesPending();
|
||||
rollback(getPendingParentChanges());
|
||||
checkOriginalState();
|
||||
|
||||
makeParentChanges();
|
||||
commit(getPendingParentChanges(), "parent changes");
|
||||
updateTo(1);
|
||||
checkOriginalState();
|
||||
updateTo(0);
|
||||
checkParentChangesCommitted();
|
||||
}
|
||||
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class UpToDateFileInMoved extends ParentChangeTestCase {
|
||||
private static final String FILE_CONTENT = "file content";
|
||||
|
||||
private FilePath myParentFolderOriginal;
|
||||
private FilePath myChildFileOriginal;
|
||||
private FilePath myParentFolderMoved;
|
||||
private FilePath myChildFileInMovedFolder;
|
||||
private FilePath mySubfolder;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
final String filename = "up_to_date.txt";
|
||||
final String foldernameOriginal = "Folder_Original";
|
||||
|
||||
myParentFolderOriginal = getChildPath(mySandboxRoot, foldernameOriginal);
|
||||
myChildFileOriginal = getChildPath(myParentFolderOriginal, filename);
|
||||
mySubfolder = getChildPath(mySandboxRoot, "Subfolder");
|
||||
mySubfolder2 = getChildPath(mySubfolder, "Subfolder2");
|
||||
myParentFolderMoved = getChildPath(mySubfolder2, foldernameOriginal);
|
||||
myChildFileInMovedFolder = getChildPath(myParentFolderMoved, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() throws VcsException {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
createDirInCommand(myParentFolderOriginal);
|
||||
createFileInCommand(myChildFileOriginal, FILE_CONTENT);
|
||||
createDirInCommand(mySubfolder);
|
||||
createDirInCommand(mySubfolder2);
|
||||
commit(getChanges().getChanges(), "original state");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentFolderOriginal, 1);
|
||||
assertFile(myChildFileOriginal, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChanges() {
|
||||
moveFileInCommand(myParentFolderOriginal, VcsUtil.getVirtualFile(mySubfolder2.getIOFile()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentFolderOriginal, myParentFolderMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentFolderMoved, 1);
|
||||
assertFile(myChildFileInMovedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentFolderMoved, 1);
|
||||
assertFile(myChildFileInMovedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Change> getPendingParentChanges() throws VcsException {
|
||||
return Collections.singletonList(getChanges().getMoveChange(myParentFolderOriginal, myParentFolderMoved));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException {
|
||||
super.doTest();
|
||||
}
|
||||
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class UpToDateFileInRenamed extends ParentChangeTestCase {
|
||||
|
||||
private static final String FILE_CONTENT = "file content";
|
||||
private static final String FOLDERNAME_RENAMED = "Folder_Renamed";
|
||||
|
||||
private FilePath myParentFolderOriginal;
|
||||
private FilePath myChildFileOriginal;
|
||||
private FilePath myParentFolderRenamed;
|
||||
private FilePath mychildFileInRenamedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
final String filename = "up_to_date.txt";
|
||||
final String foldernameOriginal = "Folder_Original";
|
||||
|
||||
myParentFolderOriginal = getChildPath(mySandboxRoot, foldernameOriginal);
|
||||
myChildFileOriginal = getChildPath(myParentFolderOriginal, filename);
|
||||
myParentFolderRenamed = getChildPath(mySandboxRoot, FOLDERNAME_RENAMED);
|
||||
mychildFileInRenamedFolder = getChildPath(myParentFolderRenamed, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() throws VcsException {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
createDirInCommand(myParentFolderOriginal);
|
||||
createFileInCommand(myChildFileOriginal, FILE_CONTENT);
|
||||
commit(getChanges().getChanges(), "original state");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolderOriginal, 1);
|
||||
assertFile(myChildFileOriginal, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChanges() {
|
||||
rename(myParentFolderOriginal, FOLDERNAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentFolderOriginal, myParentFolderRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolderRenamed, 1);
|
||||
assertFile(mychildFileInRenamedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolderRenamed, 1);
|
||||
assertFile(mychildFileInRenamedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Change> getPendingParentChanges() throws VcsException {
|
||||
return Collections.singletonList(getChanges().getMoveChange(myParentFolderOriginal, myParentFolderRenamed));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException {
|
||||
super.doTest();
|
||||
}
|
||||
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class UpToDateFolderInMoved extends ParentChangeTestCase {
|
||||
private static final String FILE_CONTENT = "file content";
|
||||
|
||||
private FilePath myParentFolderOriginal;
|
||||
private FilePath myChildFolderOriginal;
|
||||
private FilePath myParentFolderMoved;
|
||||
private FilePath myChildFolderInMovedFolder;
|
||||
private FilePath mySubfolder;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
final String filename = "up_to_date.txt";
|
||||
final String foldernameOriginal = "Folder_Original";
|
||||
|
||||
myParentFolderOriginal = getChildPath(mySandboxRoot, foldernameOriginal);
|
||||
myChildFolderOriginal = getChildPath(myParentFolderOriginal, filename);
|
||||
mySubfolder = getChildPath(mySandboxRoot, "Subfolder");
|
||||
mySubfolder2 = getChildPath(mySubfolder, "Subfolder2");
|
||||
myParentFolderMoved = getChildPath(mySubfolder2, foldernameOriginal);
|
||||
myChildFolderInMovedFolder = getChildPath(myParentFolderMoved, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() throws VcsException {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
createDirInCommand(myParentFolderOriginal);
|
||||
createDirInCommand(myChildFolderOriginal);
|
||||
createDirInCommand(mySubfolder);
|
||||
createDirInCommand(mySubfolder2);
|
||||
commit(getChanges().getChanges(), "original state");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentFolderOriginal, 1);
|
||||
assertFolder(myChildFolderOriginal, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChanges() {
|
||||
moveFileInCommand(myParentFolderOriginal, VcsUtil.getVirtualFile(mySubfolder2.getIOFile()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentFolderOriginal, myParentFolderMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentFolderMoved, 1);
|
||||
assertFolder(myChildFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentFolderMoved, 1);
|
||||
assertFolder(myChildFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Change> getPendingParentChanges() throws VcsException {
|
||||
return Collections.singletonList(getChanges().getMoveChange(myParentFolderOriginal, myParentFolderMoved));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException {
|
||||
super.doTest();
|
||||
}
|
||||
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class UpToDateFolderInRenamed extends ParentChangeTestCase {
|
||||
|
||||
private static final String FOLDERNAME_RENAMED = "Folder_Renamed";
|
||||
|
||||
private FilePath myParentFolderOriginal;
|
||||
private FilePath myChildFolderOriginal;
|
||||
private FilePath myParentFolderRenamed;
|
||||
private FilePath myChildFolderInRenamedParentFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
final String filename = "up_to_date.txt";
|
||||
final String foldernameOriginal = "Folder_Original";
|
||||
|
||||
myParentFolderOriginal = getChildPath(mySandboxRoot, foldernameOriginal);
|
||||
myChildFolderOriginal = getChildPath(myParentFolderOriginal, filename);
|
||||
myParentFolderRenamed = getChildPath(mySandboxRoot, FOLDERNAME_RENAMED);
|
||||
myChildFolderInRenamedParentFolder = getChildPath(myParentFolderRenamed, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() throws VcsException {
|
||||
doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
|
||||
createDirInCommand(myParentFolderOriginal);
|
||||
createDirInCommand(myChildFolderOriginal);
|
||||
commit(getChanges().getChanges(), "original state");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolderOriginal, 1);
|
||||
assertFolder(myChildFolderOriginal, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChanges() {
|
||||
rename(myParentFolderOriginal, FOLDERNAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentFolderOriginal, myParentFolderRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolderRenamed, 1);
|
||||
assertFolder(myChildFolderInRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolderRenamed, 1);
|
||||
assertFolder(myChildFolderInRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Change> getPendingParentChanges() throws VcsException {
|
||||
return Collections.singletonList(getChanges().getMoveChange(myParentFolderOriginal, myParentFolderRenamed));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException {
|
||||
super.doTest();
|
||||
}
|
||||
|
||||
}
|
||||
+224
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// REMARKS:
|
||||
// 1. add file without parent folder -> only file sheduled for addition, not pending change for parent,
|
||||
// but TFC shows folder as added too
|
||||
// 2. when commiting son's addition parent folder is not mentioned, but it appeares as up to date after commit and in commit details
|
||||
// 3. when parent and child added, and pending change for parent reverted, in TFC after refresh it looks like case 1
|
||||
|
||||
// TODO show parent report unversioned folder as added if some of its children is added (remark 1) ?
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class AddedFileInAdded extends ParentChildChangeTestCase {
|
||||
private FilePath myAddedParentFolder;
|
||||
private FilePath myAddedChildFile;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myAddedParentFolder = getChildPath(mySandboxRoot, "AddedFolder");
|
||||
myAddedChildFile = getChildPath(myAddedParentFolder, "added_file.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertScheduledForAddition(myAddedParentFolder);
|
||||
getChanges().assertUnversioned(myAddedChildFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFile(myAddedChildFile, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertUnversioned(myAddedParentFolder); // see remark 1
|
||||
getChanges().assertScheduledForAddition(myAddedChildFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFile(myAddedChildFile, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertScheduledForAddition(myAddedParentFolder);
|
||||
getChanges().assertScheduledForAddition(myAddedChildFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFile(myAddedChildFile, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertUnversioned(myAddedParentFolder);
|
||||
getChanges().assertUnversioned(myAddedChildFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFile(myAddedChildFile, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedChildFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFile(myAddedChildFile, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
checkParentAndChildChangesCommitted(); // see remark 2
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedParentFolder);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertUnversioned(myAddedParentFolder); // see remark 1
|
||||
getChanges().assertScheduledForAddition(myAddedChildFile);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFile(myAddedChildFile, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
checkParentAndChildChangesCommitted(); // see remark 2
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFile(myAddedChildFile, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() throws VcsException {
|
||||
if (myAddedParentFolder.getIOFile().exists()) {
|
||||
// parent folder can be already added, see remark 2
|
||||
if (getChanges().isUnversioned(myAddedParentFolder)) {
|
||||
scheduleForAddition(myAddedParentFolder);
|
||||
}
|
||||
}
|
||||
else {
|
||||
createDirInCommand(myAddedParentFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
myAddedParentFolder.getIOFile().mkdirs();
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
if (myAddedChildFile.getIOFile().exists()) {
|
||||
scheduleForAddition(myAddedChildFile);
|
||||
}
|
||||
else {
|
||||
createFileInCommand(myAddedChildFile, FILE_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getAddChange(myAddedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges().getAddChange(myAddedChildFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class AddedFileInMoved extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myMovedParentFolder;
|
||||
private FilePath myAddedFileInOriginalFolder;
|
||||
private FilePath myAddedFileInMovedFolder;
|
||||
|
||||
private FilePath mySubfolder1;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
mySubfolder1 = getChildPath(mySandboxRoot, "Subfolder1");
|
||||
mySubfolder2 = getChildPath(mySubfolder1, "Subfolder2");
|
||||
|
||||
final String folderName = "Folder";
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, folderName);
|
||||
myMovedParentFolder = getChildPath(mySubfolder2, folderName);
|
||||
|
||||
final String filename = "added_file.txt";
|
||||
myAddedFileInOriginalFolder = getChildPath(myOriginalParentFolder, filename);
|
||||
myAddedFileInMovedFolder = getChildPath(myMovedParentFolder, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
getChanges().assertUnversioned(myAddedFileInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myAddedFileInMovedFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myAddedFileInOriginalFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
getChanges().assertScheduledForAddition(myAddedFileInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myAddedFileInMovedFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertUnversioned(myAddedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myAddedFileInOriginalFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFileInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myAddedFileInMovedFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myAddedFileInMovedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myAddedFileInOriginalFolder, FILE_CONTENT, true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myAddedFileInOriginalFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myAddedFileInMovedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
createDirInCommand(mySubfolder1);
|
||||
createDirInCommand(mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
moveFileInCommand(myOriginalParentFolder, mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
FilePath file = parentChangeState == ParentChangeState.NotDone ? myAddedFileInOriginalFolder : myAddedFileInMovedFolder;
|
||||
if (file.getIOFile().exists()) {
|
||||
scheduleForAddition(file);
|
||||
}
|
||||
else {
|
||||
createFileInCommand(file, FILE_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myMovedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getAddChange(parentChangeState == ParentChangeState.NotDone ? myAddedFileInOriginalFolder : myAddedFileInMovedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
// don't test this, see remark 1 in AddedFolderInRenamed
|
||||
//@Test
|
||||
//public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
// super.testCommitChildChangesParentPending();
|
||||
//}
|
||||
|
||||
}
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class AddedFileInRenamed extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myRenamedParentFolder;
|
||||
private FilePath myAddedFileInOriginalFolder;
|
||||
private FilePath myAddedFileInRenamedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, "OriginalFolder");
|
||||
myRenamedParentFolder = getChildPath(mySandboxRoot, "RenamedFolder");
|
||||
|
||||
final String filename = "added_file.txt";
|
||||
myAddedFileInOriginalFolder = getChildPath(myOriginalParentFolder, filename);
|
||||
myAddedFileInRenamedFolder = getChildPath(myRenamedParentFolder, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
getChanges().assertUnversioned(myAddedFileInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myAddedFileInRenamedFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myAddedFileInOriginalFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
getChanges().assertScheduledForAddition(myAddedFileInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myAddedFileInRenamedFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertUnversioned(myAddedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myAddedFileInOriginalFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFileInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myAddedFileInRenamedFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myAddedFileInRenamedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myAddedFileInOriginalFolder, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myAddedFileInOriginalFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myAddedFileInRenamedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
renameFileInCommand(myOriginalParentFolder, myRenamedParentFolder.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
FilePath file = parentChangeState == ParentChangeState.NotDone ? myAddedFileInOriginalFolder : myAddedFileInRenamedFolder;
|
||||
if (file.getIOFile().exists()) {
|
||||
scheduleForAddition(file);
|
||||
}
|
||||
else {
|
||||
createFileInCommand(file, FILE_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myRenamedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getAddChange(parentChangeState == ParentChangeState.NotDone ? myAddedFileInOriginalFolder : myAddedFileInRenamedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
// don't test this, see remark 1 in AddedFolderInRenamed
|
||||
//@Test
|
||||
//public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
// super.testCommitChildChangesParentPending();
|
||||
//}
|
||||
|
||||
}
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// see remarks for AddedFileInAdded test case
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class AddedFolderInAdded extends ParentChildChangeTestCase {
|
||||
private FilePath myAddedParentFolder;
|
||||
private FilePath myAddedChildFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myAddedParentFolder = getChildPath(mySandboxRoot, "AddedFolder");
|
||||
myAddedChildFolder = getChildPath(myAddedParentFolder, "AddedSubfolder");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertScheduledForAddition(myAddedParentFolder);
|
||||
getChanges().assertUnversioned(myAddedChildFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFolder(myAddedChildFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertUnversioned(myAddedParentFolder);
|
||||
getChanges().assertScheduledForAddition(myAddedChildFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFolder(myAddedChildFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertScheduledForAddition(myAddedParentFolder);
|
||||
getChanges().assertScheduledForAddition(myAddedChildFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFolder(myAddedChildFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertUnversioned(myAddedParentFolder);
|
||||
getChanges().assertUnversioned(myAddedChildFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFolder(myAddedChildFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedChildFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFolder(myAddedChildFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
checkParentAndChildChangesCommitted(); // see remark 2
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedParentFolder);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertUnversioned(myAddedParentFolder); // see remark 1
|
||||
getChanges().assertScheduledForAddition(myAddedChildFolder);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFolder(myAddedChildFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
checkParentAndChildChangesCommitted(); // see remark 2
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedParentFolder, 1);
|
||||
assertFolder(myAddedChildFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() throws VcsException {
|
||||
if (myAddedParentFolder.getIOFile().exists()) {
|
||||
if (getChanges().isUnversioned(myAddedParentFolder)) {
|
||||
scheduleForAddition(myAddedParentFolder);
|
||||
}
|
||||
}
|
||||
else {
|
||||
createDirInCommand(myAddedParentFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
myAddedParentFolder.getIOFile().mkdirs();
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
if (myAddedChildFolder.getIOFile().exists()) {
|
||||
scheduleForAddition(myAddedChildFolder);
|
||||
}
|
||||
else {
|
||||
createDirInCommand(myAddedChildFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getAddChange(myAddedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges().getAddChange(myAddedChildFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class AddedFolderInMoved extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myMovedParentFolder;
|
||||
private FilePath myAddedFolderInOriginalFolder;
|
||||
private FilePath myAddedFolderInMovedFolder;
|
||||
|
||||
private FilePath mySubfolder1;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
mySubfolder1 = getChildPath(mySandboxRoot, "Subfolder1");
|
||||
mySubfolder2 = getChildPath(mySubfolder1, "Subfolder2");
|
||||
|
||||
final String folderName = "Folder";
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, folderName);
|
||||
myMovedParentFolder = getChildPath(mySubfolder2, folderName);
|
||||
|
||||
final String filename = "AddedFolder";
|
||||
myAddedFolderInOriginalFolder = getChildPath(myOriginalParentFolder, filename);
|
||||
myAddedFolderInMovedFolder = getChildPath(myMovedParentFolder, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
getChanges().assertUnversioned(myAddedFolderInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFolderInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myAddedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
getChanges().assertScheduledForAddition(myAddedFolderInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertUnversioned(myAddedFolderInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myAddedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFolderInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFolderInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myAddedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myAddedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
createDirInCommand(mySubfolder1);
|
||||
createDirInCommand(mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
moveFileInCommand(myOriginalParentFolder, mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
FilePath folder = parentChangeState == ParentChangeState.NotDone ? myAddedFolderInOriginalFolder : myAddedFolderInMovedFolder;
|
||||
if (folder.getIOFile().exists()) {
|
||||
scheduleForAddition(folder);
|
||||
}
|
||||
else {
|
||||
createDirInCommand(folder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myMovedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getAddChange(parentChangeState == ParentChangeState.NotDone ? myAddedFolderInOriginalFolder : myAddedFolderInMovedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
// don't test this, see remark 1 in AddedFolderInRenamed
|
||||
//@Test
|
||||
//public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
// super.testCommitChildChangesParentPending();
|
||||
//}
|
||||
|
||||
}
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// REMARKS
|
||||
// 1. Attempt to commit add change for file/folder in pending renamed/moved folder fails with
|
||||
// TF14088: '<parent folder>' must be checked in because it is a rename or an undelete.
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class AddedFolderInRenamed extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myRenamedParentFolder;
|
||||
private FilePath myAddedFolderInOriginalFolder;
|
||||
private FilePath myAddedFolderInRenamedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, "OriginalFolder");
|
||||
myRenamedParentFolder = getChildPath(mySandboxRoot, "RenamedFolder");
|
||||
|
||||
final String foldername = "AddedFolder";
|
||||
myAddedFolderInOriginalFolder = getChildPath(myOriginalParentFolder, foldername);
|
||||
myAddedFolderInRenamedFolder = getChildPath(myRenamedParentFolder, foldername);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
getChanges().assertUnversioned(myAddedFolderInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFolderInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myAddedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
getChanges().assertScheduledForAddition(myAddedFolderInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertUnversioned(myAddedFolderInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myAddedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFolderInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFolderInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myAddedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myAddedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFolder(myAddedFolderInRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
renameFileInCommand(myOriginalParentFolder, myRenamedParentFolder.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
FilePath folder = parentChangeState == ParentChangeState.NotDone ? myAddedFolderInOriginalFolder : myAddedFolderInRenamedFolder;
|
||||
if (folder.getIOFile().exists()) {
|
||||
scheduleForAddition(folder);
|
||||
}
|
||||
else {
|
||||
createDirInCommand(folder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myRenamedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getAddChange(parentChangeState == ParentChangeState.NotDone ? myAddedFolderInOriginalFolder : myAddedFolderInRenamedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
// don't test this, see remark 1 in AddedFileInRenamed
|
||||
// @Test
|
||||
// public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
// super.testCommitChildChangesParentPending();
|
||||
// }
|
||||
|
||||
}
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// REMARKS:
|
||||
// 1. when parent item is scheduled for deletion after its child was, child is reported as not downloaded and having no pending changes
|
||||
//
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DeletedFileInDeleted extends ParentChildChangeTestCase {
|
||||
private FilePath myParentFolder;
|
||||
private FilePath myChildFile;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myParentFolder = getChildPath(mySandboxRoot, "Folder");
|
||||
myChildFile = getChildPath(myParentFolder, "file.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() {
|
||||
Assert.fail("Can't happen"); // see remark 1
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
checkParentChangePending(); // see remark 1
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolder, 1);
|
||||
assertFile(myChildFile, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() {
|
||||
Assert.fail("Can't happen"); // see remark 1
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
checkParentAndChildChangesPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
// see remark 1
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myChildFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
checkParentAndChildChangesCommitted();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myParentFolder);
|
||||
createFileInCommand(myChildFile, FILE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
deleteFileInCommand(myParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
deleteFileInCommand(myChildFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getDeleteChange(myParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return parentChangeState == ParentChangeState.NotDone ? getChanges().getDeleteChange(myChildFile) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
// don't test it, see remark 1
|
||||
//@Test
|
||||
//public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
// super.testCommitParentThenChildChanges();
|
||||
//}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
// don't test it, see remark 1
|
||||
//@Test
|
||||
//public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
// super.testCommitParentChangesChildPending();
|
||||
//}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DeletedFileInMoved extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myMovedParentFolder;
|
||||
private FilePath myDeletedFileInOriginalFolder;
|
||||
private FilePath myDeletedFileInMovedFolder;
|
||||
|
||||
private FilePath mySubfolder1;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
mySubfolder1 = getChildPath(mySandboxRoot, "Subfolder1");
|
||||
mySubfolder2 = getChildPath(mySubfolder1, "Subfolder2");
|
||||
|
||||
final String folderName = "Folder";
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, folderName);
|
||||
myMovedParentFolder = getChildPath(mySubfolder2, folderName);
|
||||
|
||||
final String filename = "deleted_file.txt";
|
||||
myDeletedFileInOriginalFolder = getChildPath(myOriginalParentFolder, filename);
|
||||
myDeletedFileInMovedFolder = getChildPath(myMovedParentFolder, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myDeletedFileInMovedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFileInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myDeletedFileInOriginalFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myDeletedFileInOriginalFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFileInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myDeletedFileInMovedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myDeletedFileInMovedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
createFileInCommand(myDeletedFileInOriginalFolder, FILE_CONTENT);
|
||||
|
||||
createDirInCommand(mySubfolder1);
|
||||
createDirInCommand(mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
moveFileInCommand(myOriginalParentFolder, mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
deleteFileInCommand(parentChangeState == ParentChangeState.NotDone ? myDeletedFileInOriginalFolder : myDeletedFileInMovedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myMovedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getDeleteChange(parentChangeState == ParentChangeState.NotDone ? myDeletedFileInOriginalFolder : myDeletedFileInMovedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DeletedFileInRenamed extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myRenamedParentFolder;
|
||||
private FilePath myDeletedFileInOriginalFolder;
|
||||
private FilePath myDeletedFileInRenamedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, "OriginalFolder");
|
||||
myRenamedParentFolder = getChildPath(mySandboxRoot, "RenamedFolder");
|
||||
|
||||
final String filename = "deleted_file.txt";
|
||||
myDeletedFileInOriginalFolder = getChildPath(myOriginalParentFolder, filename);
|
||||
myDeletedFileInRenamedFolder = getChildPath(myRenamedParentFolder, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myDeletedFileInRenamedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFileInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myDeletedFileInOriginalFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myDeletedFileInOriginalFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFileInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myDeletedFileInRenamedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myDeletedFileInRenamedFolder, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
createFileInCommand(myDeletedFileInOriginalFolder, FILE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
renameFileInCommand(myOriginalParentFolder, myRenamedParentFolder.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
deleteFileInCommand(parentChangeState == ParentChangeState.NotDone ? myDeletedFileInOriginalFolder : myDeletedFileInRenamedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myRenamedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getDeleteChange(parentChangeState == ParentChangeState.NotDone ? myDeletedFileInOriginalFolder : myDeletedFileInRenamedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// REMARKS:
|
||||
// 1. when parent item is scheduled for deletion after its child was, child is reported as not downloaded and having no pending changes
|
||||
//
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DeletedFolderInDeleted extends ParentChildChangeTestCase {
|
||||
private FilePath myParentFolder;
|
||||
private FilePath myChildFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myParentFolder = getChildPath(mySandboxRoot, "ParentFolder");
|
||||
myChildFolder = getChildPath(myParentFolder, "ChildFolder");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() {
|
||||
Assert.fail("Can't happen"); // see remark 1
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
checkParentChangePending(); // see remark 1
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolder, 1);
|
||||
assertFolder(myChildFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() {
|
||||
Assert.fail("Can't happen"); // see remark 1
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
checkParentAndChildChangesPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
// see remark 1
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myChildFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
checkParentAndChildChangesCommitted();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myParentFolder);
|
||||
createDirInCommand(myChildFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
deleteFileInCommand(myParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
deleteFileInCommand(myChildFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getDeleteChange(myParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return parentChangeState == ParentChangeState.NotDone ? getChanges().getDeleteChange(myChildFolder) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
// don't test it, see remark 1
|
||||
//@Test
|
||||
//public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
// super.testCommitParentThenChildChanges();
|
||||
//}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
// don't test it, see remark 1
|
||||
//@Test
|
||||
//public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
// super.testCommitParentChangesChildPending();
|
||||
//}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DeletedFolderInMoved extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myMovedParentFolder;
|
||||
private FilePath myDeletedFolderInOriginalFolder;
|
||||
private FilePath myDeletedFolderInMovedFolder;
|
||||
|
||||
private FilePath mySubfolder1;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
mySubfolder1 = getChildPath(mySandboxRoot, "Subfolder1");
|
||||
mySubfolder2 = getChildPath(mySubfolder1, "Subfolder2");
|
||||
|
||||
final String folderName = "Folder";
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, folderName);
|
||||
myMovedParentFolder = getChildPath(mySubfolder2, folderName);
|
||||
|
||||
final String filename = "DeletedFolder";
|
||||
myDeletedFolderInOriginalFolder = getChildPath(myOriginalParentFolder, filename);
|
||||
myDeletedFolderInMovedFolder = getChildPath(myMovedParentFolder, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFolder(myDeletedFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFolderInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFolderInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myDeletedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myDeletedFolderInOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFolderInMovedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFolder(myDeletedFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFolderInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFolder(myDeletedFolderInMovedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
createDirInCommand(myDeletedFolderInOriginalFolder);
|
||||
|
||||
createDirInCommand(mySubfolder1);
|
||||
createDirInCommand(mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
moveFileInCommand(myOriginalParentFolder, mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
deleteFileInCommand(parentChangeState == ParentChangeState.NotDone ? myDeletedFolderInOriginalFolder : myDeletedFolderInMovedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myMovedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getDeleteChange(parentChangeState == ParentChangeState.NotDone ? myDeletedFolderInOriginalFolder : myDeletedFolderInMovedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DeletedFolderInRenamed extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myRenamedParentFolder;
|
||||
private FilePath myDeletedFolderOriginalFolder;
|
||||
private FilePath myDeletedFolderInRenamedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, "OriginalFolder");
|
||||
myRenamedParentFolder = getChildPath(mySandboxRoot, "RenamedFolder");
|
||||
|
||||
final String filename = "DeletedSubfolder";
|
||||
myDeletedFolderOriginalFolder = getChildPath(myOriginalParentFolder, filename);
|
||||
myDeletedFolderInRenamedFolder = getChildPath(myRenamedParentFolder, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFolder(myDeletedFolderInRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFolderOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFolderInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myDeletedFolderOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFolder(myDeletedFolderOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFolderInRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFolder(myDeletedFolderInRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFolderOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFolder(myDeletedFolderInRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
createDirInCommand(myDeletedFolderOriginalFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
renameFileInCommand(myOriginalParentFolder, myRenamedParentFolder.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
deleteFileInCommand(parentChangeState == ParentChangeState.NotDone ? myDeletedFolderOriginalFolder : myDeletedFolderInRenamedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myRenamedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getDeleteChange(parentChangeState == ParentChangeState.NotDone ? myDeletedFolderOriginalFolder : myDeletedFolderInRenamedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+246
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class ModifiedFileInMoved extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myMovedParentFolder;
|
||||
|
||||
private FilePath myFileInOriginalFolder;
|
||||
private FilePath myFileInMovedFolder;
|
||||
|
||||
private FilePath mySubfolder1;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
final String folderName = "Folder_Original";
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, folderName);
|
||||
mySubfolder1 = getChildPath(mySandboxRoot, "Subfolder1");
|
||||
mySubfolder2 = getChildPath(mySubfolder1, "Subfolder2");
|
||||
myMovedParentFolder = getChildPath(mySubfolder2, folderName);
|
||||
myFileInOriginalFolder = getChildPath(myOriginalParentFolder, "file.txt");
|
||||
myFileInMovedFolder = getChildPath(myMovedParentFolder, "file.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myFileInMovedFolder, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myFileInOriginalFolder, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myFileInOriginalFolder, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
getChanges().assertModified(myFileInMovedFolder, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myFileInMovedFolder, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
checkOriginalState();
|
||||
}
|
||||
|
||||
private void checkOriginalState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myFileInOriginalFolder, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myFileInMovedFolder, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myFileInOriginalFolder, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myFileInMovedFolder, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myFileInMovedFolder, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myFileInMovedFolder, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myFileInMovedFolder, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myMovedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myMovedParentFolder, 1);
|
||||
assertFile(myFileInMovedFolder, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myFileInOriginalFolder, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
createDirInCommand(mySubfolder1);
|
||||
createDirInCommand(mySubfolder2);
|
||||
createFileInCommand(myFileInOriginalFolder, ORIGINAL_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
moveFileInCommand(myOriginalParentFolder, mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) throws VcsException, IOException {
|
||||
final FilePath file = parentChangeState == ParentChangeState.NotDone ? myFileInOriginalFolder : myFileInMovedFolder;
|
||||
editFiles(file);
|
||||
setFileContent(file, MODIFIED_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myMovedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getModificationChange(parentChangeState == ParentChangeState.NotDone ? myFileInOriginalFolder : myFileInMovedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
}
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class ModifiedFileInRenamed extends ParentChildChangeTestCase {
|
||||
private FilePath myOriginalParentFolder;
|
||||
private FilePath myRenamedParentFolder;
|
||||
|
||||
private FilePath myFileInOriginalFolder;
|
||||
private FilePath myFileInRenamedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myOriginalParentFolder = getChildPath(mySandboxRoot, "Folder_Original");
|
||||
myRenamedParentFolder = getChildPath(mySandboxRoot, "Folder_Renamed");
|
||||
myFileInOriginalFolder = getChildPath(myOriginalParentFolder, "file.txt");
|
||||
myFileInRenamedFolder = getChildPath(myRenamedParentFolder, "file.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myFileInRenamedFolder, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myFileInOriginalFolder, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myFileInOriginalFolder, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
getChanges().assertModified(myFileInRenamedFolder, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myFileInRenamedFolder, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
checkOriginalState();
|
||||
}
|
||||
|
||||
private void checkOriginalState() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myFileInOriginalFolder, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myFileInRenamedFolder, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myFileInOriginalFolder, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myFileInRenamedFolder, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myFileInRenamedFolder, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myFileInRenamedFolder, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myFileInRenamedFolder, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalParentFolder, myRenamedParentFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedParentFolder, 1);
|
||||
assertFile(myFileInRenamedFolder, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myFileInOriginalFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalParentFolder, 1);
|
||||
assertFile(myFileInOriginalFolder, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalParentFolder);
|
||||
createFileInCommand(myFileInOriginalFolder, ORIGINAL_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
renameFileInCommand(myOriginalParentFolder, myRenamedParentFolder.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) throws VcsException, IOException {
|
||||
final FilePath file = parentChangeState == ParentChangeState.NotDone ? myFileInOriginalFolder : myFileInRenamedFolder;
|
||||
editFiles(file);
|
||||
setFileContent(file, MODIFIED_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalParentFolder, myRenamedParentFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges()
|
||||
.getModificationChange(parentChangeState == ParentChangeState.NotDone ? myFileInOriginalFolder : myFileInRenamedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
}
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.tests.TestChangeListBuilder;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// Remark 1: when checking in move change to 'Added' folder, add change is checked in implicitly
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class MovedFileFromUpToDateToAdded extends ParentChildChangeTestCase {
|
||||
|
||||
private static final String FILE_ORIGINAL = "file_original.txt";
|
||||
|
||||
private FilePath myOriginalFile;
|
||||
private FilePath myMovedFile;
|
||||
|
||||
private FilePath mySourceFolder;
|
||||
private FilePath myAddedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
mySourceFolder = getChildPath(mySandboxRoot, "SourceFolder");
|
||||
myAddedFolder = getChildPath(mySandboxRoot, "AddedFolder");
|
||||
myOriginalFile = getChildPath(mySourceFolder, FILE_ORIGINAL);
|
||||
myMovedFile = getChildPath(myAddedFolder, FILE_ORIGINAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 1);
|
||||
assertFolder(myAddedFolder, 0);
|
||||
assertFile(myOriginalFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
// added folder on rollback becomes unversioned
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertUnversioned(myAddedFolder);
|
||||
getChanges().assertRenamedOrMoved(myOriginalFile, myMovedFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 0);
|
||||
assertFolder(myAddedFolder, 1);
|
||||
assertFile(myMovedFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertScheduledForAddition(myAddedFolder);
|
||||
getChanges().assertRenamedOrMoved(myOriginalFile, myMovedFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 0);
|
||||
assertFolder(myAddedFolder, 1);
|
||||
assertFile(myMovedFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertUnversioned(myAddedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 1);
|
||||
assertFolder(myAddedFolder, 0);
|
||||
assertFile(myOriginalFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySourceFolder, 1);
|
||||
assertFile(myOriginalFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 1);
|
||||
assertFolder(myAddedFolder, 0);
|
||||
assertFile(myOriginalFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
checkParentAndChildChangesCommitted(); // see remark 1
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 0);
|
||||
assertFolder(myAddedFolder, 1);
|
||||
assertFile(myMovedFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalFile, myMovedFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 0);
|
||||
assertFolder(myAddedFolder, 1);
|
||||
assertFile(myMovedFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
checkParentAndChildChangesCommitted(); // see remark 1
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 1);
|
||||
assertFolder(myAddedFolder, 0);
|
||||
assertFile(myOriginalFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
final TestChangeListBuilder changes = getChanges();
|
||||
changes.assertTotalItems(2);
|
||||
changes.assertUnversioned(myAddedFolder);
|
||||
changes.assertRenamedOrMoved(myOriginalFile, myMovedFile);
|
||||
assertFile(myMovedFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(mySourceFolder);
|
||||
createFileInCommand(myOriginalFile, ORIGINAL_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() throws VcsException {
|
||||
if (myAddedFolder.getIOFile().exists()) {
|
||||
if (getChanges().isUnversioned(myAddedFolder)) {
|
||||
scheduleForAddition(myAddedFolder);
|
||||
}
|
||||
}
|
||||
else {
|
||||
createDirInCommand(myAddedFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
moveFileInCommand(myOriginalFile, myAddedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getAddChange(myAddedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalFile, myMovedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
// don't test: can't move file to non-existing folder
|
||||
//@Test
|
||||
//public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
// super.testCommitChildThenParentChanges();
|
||||
//}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
// don't test: can't move file to non-existing folder
|
||||
//@Test
|
||||
//public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
// super.testCommitChildChangesParentPending();
|
||||
//}
|
||||
|
||||
}
|
||||
+336
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.TFSChangeList;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.jetbrains.tfsIntegration.tests.ChangeHelper;
|
||||
import org.jetbrains.tfsIntegration.tests.TFSTestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public abstract class ParentChildChangeTestCase extends TFSTestCase {
|
||||
|
||||
protected enum ParentChangeState {
|
||||
NotDone,
|
||||
Pending,
|
||||
Committed
|
||||
}
|
||||
|
||||
protected static final String ORIGINAL_CONTENT = "original content";
|
||||
|
||||
protected static final String MODIFIED_CONTENT = "modified content";
|
||||
|
||||
protected static final String FILE_CONTENT = "file_content";
|
||||
|
||||
private static final String PARENT_CHANGES_COMMIT_COMMENT = "parent changes";
|
||||
|
||||
private static final String CHILD_CHANGES_COMMIT_COMMENT = "child change";
|
||||
|
||||
private static final String INITIAL_STATE_COMMIT_COMMENT = "initial state";
|
||||
|
||||
protected abstract void preparePaths();
|
||||
|
||||
protected abstract void checkParentChangePendingChildRolledBack() throws VcsException;
|
||||
|
||||
protected abstract void checkChildChangePendingParentRolledBack() throws VcsException;
|
||||
|
||||
protected abstract void checkParentAndChildChangesPending() throws VcsException;
|
||||
|
||||
protected abstract void checkOriginalStateAfterRollbackParentChild() throws VcsException;
|
||||
|
||||
protected abstract void checkOriginalStateAfterUpdate() throws VcsException;
|
||||
|
||||
protected abstract void checkParentChangeCommitted() throws VcsException;
|
||||
|
||||
protected abstract void checkChildChangeCommitted() throws VcsException;
|
||||
|
||||
protected abstract void checkParentAndChildChangesCommitted() throws VcsException;
|
||||
|
||||
protected abstract void checkParentChangeCommittedChildPending() throws VcsException;
|
||||
|
||||
protected abstract void checkChildChangeCommittedParentPending() throws VcsException;
|
||||
|
||||
protected abstract void checkParentChangePending() throws VcsException;
|
||||
|
||||
protected abstract void checkChildChangePending() throws VcsException;
|
||||
|
||||
|
||||
protected abstract void makeOriginalState();
|
||||
|
||||
protected abstract void makeParentChange() throws VcsException;
|
||||
|
||||
protected abstract void makeChildChange(ParentChangeState parentChangeState) throws VcsException, IOException;
|
||||
|
||||
protected abstract
|
||||
@Nullable
|
||||
Change getPendingParentChange() throws VcsException;
|
||||
|
||||
@Nullable
|
||||
protected abstract Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException;
|
||||
|
||||
protected boolean shouldTestRollbackChildPendingParent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected void testPendingAndRollback() throws VcsException, IOException {
|
||||
boolean originalStateChangesCommitted = initialize();
|
||||
|
||||
makeParentChange();
|
||||
checkParentChangePending();
|
||||
makeChildChange(ParentChangeState.Pending);
|
||||
checkParentAndChildChangesPending();
|
||||
updateTo(0);
|
||||
checkParentAndChildChangesPending();
|
||||
rollback(getPendingParentChange());
|
||||
checkChildChangePendingParentRolledBack();
|
||||
final Change childChange = getPendingChildChange(ParentChangeState.NotDone);
|
||||
if (childChange != null) {
|
||||
rollback(childChange);
|
||||
}
|
||||
checkOriginalStateAfterRollbackParentChild();
|
||||
|
||||
if (shouldTestRollbackChildPendingParent()) {
|
||||
makeChildChange(ParentChangeState.NotDone);
|
||||
checkChildChangePending();
|
||||
makeParentChange();
|
||||
checkParentAndChildChangesPending();
|
||||
final Change childChange2 = getPendingChildChange(ParentChangeState.Pending);
|
||||
if (childChange2 != null) {
|
||||
rollback(childChange2);
|
||||
checkParentChangePendingChildRolledBack();
|
||||
}
|
||||
rollback(getPendingParentChange());
|
||||
checkOriginalStateAfterRollbackParentChild();
|
||||
}
|
||||
|
||||
makeParentChange();
|
||||
makeChildChange(ParentChangeState.Pending);
|
||||
Collection<Change> parentAndChildChanges = new ArrayList<>();
|
||||
final Change pendingParentChange = getPendingParentChange();
|
||||
if (pendingParentChange != null) {
|
||||
parentAndChildChanges.add(pendingParentChange);
|
||||
}
|
||||
final Change pendingChildChange = getPendingChildChange(ParentChangeState.Pending);
|
||||
if (pendingChildChange != null) {
|
||||
parentAndChildChanges.add(pendingChildChange);
|
||||
}
|
||||
rollback(parentAndChildChanges);
|
||||
checkOriginalStateAfterRollbackParentChild();
|
||||
}
|
||||
|
||||
|
||||
protected void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
boolean originalStateChangesCommitted = initialize();
|
||||
|
||||
makeParentChange();
|
||||
Change parentChange = getPendingParentChange();
|
||||
if (parentChange != null) {
|
||||
commit(parentChange, PARENT_CHANGES_COMMIT_COMMENT);
|
||||
checkParentChangeCommitted();
|
||||
}
|
||||
makeChildChange(ParentChangeState.Committed);
|
||||
final Change childChange = getPendingChildChange(ParentChangeState.Committed);
|
||||
final Change childChangeToCheck = ChangeHelper.getChangeWithCachedContent(childChange);
|
||||
commit(childChange, CHILD_CHANGES_COMMIT_COMMENT);
|
||||
checkParentAndChildChangesCommitted();
|
||||
|
||||
updateTo(2);
|
||||
checkOriginalStateAfterUpdate();
|
||||
updateTo(1);
|
||||
checkParentChangeCommitted();
|
||||
updateTo(0);
|
||||
checkParentAndChildChangesCommitted();
|
||||
|
||||
assertHistory(parentChange, childChangeToCheck, true, originalStateChangesCommitted);
|
||||
}
|
||||
|
||||
protected void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
boolean originalStateChangesCommitted = initialize();
|
||||
|
||||
makeChildChange(ParentChangeState.NotDone);
|
||||
final Change childChange = getPendingChildChange(ParentChangeState.NotDone);
|
||||
final Change childChangeToCheck = ChangeHelper.getChangeWithCachedContent(childChange);
|
||||
commit(childChange, CHILD_CHANGES_COMMIT_COMMENT);
|
||||
checkChildChangeCommitted();
|
||||
makeParentChange();
|
||||
|
||||
Change parentChange = getPendingParentChange();
|
||||
if (parentChange != null) {
|
||||
commit(parentChange, PARENT_CHANGES_COMMIT_COMMENT);
|
||||
checkParentAndChildChangesCommitted();
|
||||
}
|
||||
|
||||
if (parentChange == null) {
|
||||
updateTo(1);
|
||||
checkOriginalStateAfterUpdate();
|
||||
updateTo(0);
|
||||
checkParentAndChildChangesCommitted();
|
||||
}
|
||||
else {
|
||||
updateTo(2);
|
||||
checkOriginalStateAfterUpdate();
|
||||
updateTo(1);
|
||||
checkChildChangeCommitted();
|
||||
updateTo(0);
|
||||
checkParentAndChildChangesCommitted();
|
||||
}
|
||||
|
||||
assertHistory(parentChange, childChangeToCheck, false, originalStateChangesCommitted);
|
||||
}
|
||||
|
||||
protected void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
boolean originalStateChangesCommitted = initialize();
|
||||
|
||||
makeParentChange();
|
||||
makeChildChange(ParentChangeState.Pending);
|
||||
Change parentChange = getPendingParentChange();
|
||||
if (parentChange != null) {
|
||||
commit(parentChange, PARENT_CHANGES_COMMIT_COMMENT);
|
||||
}
|
||||
checkParentChangeCommittedChildPending();
|
||||
final Change childChange = getPendingChildChange(ParentChangeState.Committed);
|
||||
final Change childChangeToCheck = ChangeHelper.getChangeWithCachedContent(childChange);
|
||||
commit(childChange, CHILD_CHANGES_COMMIT_COMMENT);
|
||||
checkParentAndChildChangesCommitted();
|
||||
|
||||
updateTo(2);
|
||||
checkOriginalStateAfterUpdate();
|
||||
updateTo(1);
|
||||
checkParentChangeCommitted();
|
||||
updateTo(0);
|
||||
checkParentAndChildChangesCommitted();
|
||||
|
||||
assertHistory(parentChange, childChangeToCheck, true, originalStateChangesCommitted);
|
||||
}
|
||||
|
||||
protected void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
boolean originalStateChangesCommitted = initialize();
|
||||
|
||||
makeChildChange(ParentChangeState.NotDone);
|
||||
final Change childChange = getPendingChildChange(ParentChangeState.NotDone);
|
||||
final Change childChangeToCheck = ChangeHelper.getChangeWithCachedContent(childChange);
|
||||
rollback(childChange);
|
||||
checkOriginalStateAfterRollbackParentChild();
|
||||
|
||||
makeParentChange();
|
||||
makeChildChange(ParentChangeState.Pending);
|
||||
|
||||
final Change childChangeToCommit = getPendingChildChange(ParentChangeState.Pending);
|
||||
if (childChangeToCommit != null) {
|
||||
commit(childChangeToCommit, CHILD_CHANGES_COMMIT_COMMENT);
|
||||
checkChildChangeCommittedParentPending();
|
||||
}
|
||||
|
||||
Change parentChange = getPendingParentChange();
|
||||
if (parentChange != null) {
|
||||
commit(parentChange, PARENT_CHANGES_COMMIT_COMMENT);
|
||||
}
|
||||
checkParentAndChildChangesCommitted();
|
||||
|
||||
if (parentChange == null) {
|
||||
if (childChangeToCommit != null) {
|
||||
updateTo(1);
|
||||
checkOriginalStateAfterUpdate();
|
||||
updateTo(0);
|
||||
checkParentAndChildChangesCommitted();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (childChangeToCommit != null) {
|
||||
updateTo(2);
|
||||
checkOriginalStateAfterUpdate();
|
||||
updateTo(1);
|
||||
checkChildChangeCommitted();
|
||||
updateTo(0);
|
||||
checkParentAndChildChangesCommitted();
|
||||
}
|
||||
else {
|
||||
updateTo(1);
|
||||
checkOriginalStateAfterUpdate();
|
||||
updateTo(0);
|
||||
checkParentChangeCommitted();
|
||||
}
|
||||
}
|
||||
|
||||
assertHistory(parentChange, childChangeToCommit != null ? childChangeToCheck : null, false, originalStateChangesCommitted);
|
||||
}
|
||||
|
||||
private void assertHistory(Change parentChangeCommitted,
|
||||
Change childChangeCommitted,
|
||||
boolean parentThenChild,
|
||||
boolean originalStateCommited) throws VcsException {
|
||||
final RepositoryLocation location = getVcs().getCommittedChangesProvider().getLocationFor(TfsFileUtil.getFilePath(mySandboxRoot));
|
||||
final List<TFSChangeList> historyList =
|
||||
getVcs().getCommittedChangesProvider().getCommittedChanges(new ChangeBrowserSettings(), location, 0);
|
||||
|
||||
final TFSChangeList childChangelist;
|
||||
if (parentChangeCommitted != null) {
|
||||
if (originalStateCommited) {
|
||||
Assert.assertEquals(childChangeCommitted != null ? 4 : 3, historyList.size());
|
||||
}
|
||||
else {
|
||||
Assert.assertEquals(childChangeCommitted != null ? 3 : 2, historyList.size());
|
||||
}
|
||||
childChangelist = childChangeCommitted != null ? historyList.get(parentThenChild ? 0 : 1) : null;
|
||||
|
||||
TFSChangeList parentChangelist = historyList.get(parentThenChild ? 1 : 0);
|
||||
Assert.assertEquals(PARENT_CHANGES_COMMIT_COMMENT, parentChangelist.getComment());
|
||||
assertUserNameEqual(parentChangelist.getCommitterName());
|
||||
ChangeHelper.assertContains(Collections.singletonList(parentChangeCommitted), parentChangelist.getChanges());
|
||||
}
|
||||
else {
|
||||
Assert.assertEquals(originalStateCommited ? 3 : 2, historyList.size());
|
||||
childChangelist = historyList.get(0);
|
||||
}
|
||||
|
||||
if (childChangeCommitted != null) {
|
||||
Assert.assertEquals(CHILD_CHANGES_COMMIT_COMMENT, childChangelist.getComment());
|
||||
assertUserNameEqual(childChangelist.getCommitterName());
|
||||
ChangeHelper.assertContains(Collections.singletonList(childChangeCommitted), childChangelist.getChanges());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if initial state changes committed
|
||||
*/
|
||||
private boolean initialize() throws VcsException {
|
||||
preparePaths();
|
||||
|
||||
makeOriginalState();
|
||||
final List<Change> originalStateChanges = getChanges().getChanges();
|
||||
if (!originalStateChanges.isEmpty()) {
|
||||
commit(originalStateChanges, INITIAL_STATE_COMMIT_COMMENT);
|
||||
}
|
||||
checkOriginalStateAfterUpdate();
|
||||
return !originalStateChanges.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class RenamedFileInMoved extends ParentChildChangeTestCase {
|
||||
private static final String FILENAME_RENAMED = "renamed.txt";
|
||||
|
||||
private FilePath myParentOriginal;
|
||||
private FilePath myParentMoved;
|
||||
private FilePath myChildOriginalInParentOriginal;
|
||||
private FilePath myChildOriginalInParentMoved;
|
||||
private FilePath myChildRenamedInParentOriginal;
|
||||
private FilePath myChildRenamedInParentMoved;
|
||||
private FilePath mySubfolder1;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
mySubfolder1 = getChildPath(mySandboxRoot, "Subfolder1");
|
||||
mySubfolder2 = getChildPath(mySubfolder1, "Subfolder2");
|
||||
|
||||
final String parentFolderName = "ParentFolder";
|
||||
myParentOriginal = getChildPath(mySandboxRoot, parentFolderName);
|
||||
myParentMoved = getChildPath(mySubfolder2, parentFolderName);
|
||||
final String filenameOriginal = "original.txt";
|
||||
myChildOriginalInParentOriginal = getChildPath(myParentOriginal, filenameOriginal);
|
||||
myChildOriginalInParentMoved = getChildPath(myParentMoved, filenameOriginal);
|
||||
myChildRenamedInParentOriginal = getChildPath(myParentOriginal, FILENAME_RENAMED);
|
||||
myChildRenamedInParentMoved = getChildPath(myParentMoved, FILENAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
checkParentChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
checkChildChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentMoved);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildRenamedInParentMoved, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildOriginalInParentOriginal, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildOriginalInParentMoved, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildRenamedInParentOriginal, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildRenamedInParentMoved, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentMoved, myChildRenamedInParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildRenamedInParentMoved, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildRenamedInParentMoved, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildOriginalInParentMoved, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildRenamedInParentOriginal, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myParentOriginal);
|
||||
createFileInCommand(myChildOriginalInParentOriginal, FILE_CONTENT);
|
||||
createDirInCommand(mySubfolder1);
|
||||
createDirInCommand(mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
moveFileInCommand(myParentOriginal, mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
rename(parentChangeState == ParentChangeState.NotDone ? myChildOriginalInParentOriginal : myChildOriginalInParentMoved,
|
||||
FILENAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myParentOriginal, myParentMoved);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
}
|
||||
else if (parentChangeState == ParentChangeState.Pending) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentMoved);
|
||||
}
|
||||
else {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentMoved, myChildRenamedInParentMoved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class RenamedFileInRenamed extends ParentChildChangeTestCase {
|
||||
private static final String FILENAME_RENAMED = "renamed.txt";
|
||||
|
||||
private FilePath myParentOriginal;
|
||||
private FilePath myParentRenamed;
|
||||
private FilePath myChildOriginalInParentOriginal;
|
||||
private FilePath myChildOriginalInParentRenamed;
|
||||
private FilePath myChildRenamedInParentOriginal;
|
||||
private FilePath myChildRenamedInParentRenamed;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myParentOriginal = getChildPath(mySandboxRoot, "Original");
|
||||
myParentRenamed = getChildPath(mySandboxRoot, "Renamed");
|
||||
final String filenameOriginal = "original.txt";
|
||||
myChildOriginalInParentOriginal = getChildPath(myParentOriginal, filenameOriginal);
|
||||
myChildOriginalInParentRenamed = getChildPath(myParentRenamed, filenameOriginal);
|
||||
myChildRenamedInParentOriginal = getChildPath(myParentOriginal, FILENAME_RENAMED);
|
||||
myChildRenamedInParentRenamed = getChildPath(myParentRenamed, FILENAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
checkParentChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
checkChildChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentRenamed);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildRenamedInParentRenamed, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildOriginalInParentOriginal, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildOriginalInParentRenamed, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildRenamedInParentOriginal, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildRenamedInParentRenamed, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentRenamed, myChildRenamedInParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildRenamedInParentRenamed, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildRenamedInParentRenamed, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildOriginalInParentRenamed, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildRenamedInParentOriginal, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myParentOriginal);
|
||||
createFileInCommand(myChildOriginalInParentOriginal, FILE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
rename(myParentOriginal, myParentRenamed.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
rename(parentChangeState == ParentChangeState.NotDone ? myChildOriginalInParentOriginal : myChildOriginalInParentRenamed,
|
||||
FILENAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myParentOriginal, myParentRenamed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
}
|
||||
else if (parentChangeState == ParentChangeState.Pending) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentRenamed);
|
||||
}
|
||||
else {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentRenamed, myChildRenamedInParentRenamed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// REMARK 1:
|
||||
// 1. rename child folder
|
||||
// 2. then move parent folder
|
||||
// 3. try to undo file rename
|
||||
// -> TF14059: Unable to process the pending changes requested. The set of pending renames would cause a name collision for <original child folder>
|
||||
// does not repeat if child is file - bug in TFS?
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class RenamedFolderInMoved extends ParentChildChangeTestCase {
|
||||
private static final String FOLDERNAME_RENAMED = "RenamedChild";
|
||||
|
||||
private FilePath myParentOriginal;
|
||||
private FilePath myParentMoved;
|
||||
private FilePath myChildOriginalInParentOriginal;
|
||||
private FilePath myChildOriginalInParentMoved;
|
||||
private FilePath myChildRenamedInParentOriginal;
|
||||
private FilePath myChildRenamedInParentMoved;
|
||||
private FilePath mySubfolder1;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
mySubfolder1 = getChildPath(mySandboxRoot, "Subfolder1");
|
||||
mySubfolder2 = getChildPath(mySubfolder1, "Subfolder2");
|
||||
|
||||
final String parentFolderName = "ParentFolder";
|
||||
myParentOriginal = getChildPath(mySandboxRoot, parentFolderName);
|
||||
myParentMoved = getChildPath(mySubfolder2, parentFolderName);
|
||||
final String foldernameOriginal = "OriginalChild";
|
||||
myChildOriginalInParentOriginal = getChildPath(myParentOriginal, foldernameOriginal);
|
||||
myChildOriginalInParentMoved = getChildPath(myParentMoved, foldernameOriginal);
|
||||
myChildRenamedInParentOriginal = getChildPath(myParentOriginal, FOLDERNAME_RENAMED);
|
||||
myChildRenamedInParentMoved = getChildPath(myParentMoved, FOLDERNAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
checkParentChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
checkChildChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentMoved);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFolder(myChildRenamedInParentMoved, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFolder(myChildOriginalInParentOriginal, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFolder(myChildOriginalInParentMoved, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFolder(myChildRenamedInParentOriginal, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFolder(myChildRenamedInParentMoved, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentMoved, myChildRenamedInParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFolder(myChildRenamedInParentMoved, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFolder(myChildRenamedInParentMoved, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFolder(myChildOriginalInParentMoved, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFolder(myChildRenamedInParentOriginal, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myParentOriginal);
|
||||
createDirInCommand(myChildOriginalInParentOriginal);
|
||||
createDirInCommand(mySubfolder1);
|
||||
createDirInCommand(mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
moveFileInCommand(myParentOriginal, mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
rename(parentChangeState == ParentChangeState.NotDone ? myChildOriginalInParentOriginal : myChildOriginalInParentMoved,
|
||||
FOLDERNAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myParentOriginal, myParentMoved);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
}
|
||||
else if (parentChangeState == ParentChangeState.Pending) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentMoved);
|
||||
}
|
||||
else {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentMoved, myChildRenamedInParentMoved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldTestRollbackChildPendingParent() {
|
||||
return false; // see remark 1
|
||||
}
|
||||
}
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class RenamedFolderInRenamed extends ParentChildChangeTestCase {
|
||||
private static final String CHILDFOLDERNAME_RENAMED = "ChildRenamed";
|
||||
|
||||
private FilePath myParentOriginal;
|
||||
private FilePath myParentRenamed;
|
||||
private FilePath myChildOriginalInParentOriginal;
|
||||
private FilePath myChildOriginalInParentRenamed;
|
||||
private FilePath myChildRenamedInParentOriginal;
|
||||
private FilePath myChildRenamedInParentRenamed;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myParentOriginal = getChildPath(mySandboxRoot, "Original");
|
||||
myParentRenamed = getChildPath(mySandboxRoot, "Renamed");
|
||||
final String filenameOriginal = "ChildOriginal";
|
||||
myChildOriginalInParentOriginal = getChildPath(myParentOriginal, filenameOriginal);
|
||||
myChildOriginalInParentRenamed = getChildPath(myParentRenamed, filenameOriginal);
|
||||
myChildRenamedInParentOriginal = getChildPath(myParentOriginal, CHILDFOLDERNAME_RENAMED);
|
||||
myChildRenamedInParentRenamed = getChildPath(myParentRenamed, CHILDFOLDERNAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
checkParentChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
checkChildChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentRenamed);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFolder(myChildRenamedInParentRenamed, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFolder(myChildOriginalInParentOriginal, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFolder(myChildOriginalInParentRenamed, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFolder(myChildRenamedInParentOriginal, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFolder(myChildRenamedInParentRenamed, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentRenamed, myChildRenamedInParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFolder(myChildRenamedInParentRenamed, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFolder(myChildRenamedInParentRenamed, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFolder(myChildOriginalInParentRenamed, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFolder(myChildRenamedInParentOriginal, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myParentOriginal);
|
||||
createDirInCommand(myChildOriginalInParentOriginal);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
rename(myParentOriginal, myParentRenamed.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) {
|
||||
rename(parentChangeState == ParentChangeState.NotDone ? myChildOriginalInParentOriginal : myChildOriginalInParentRenamed,
|
||||
CHILDFOLDERNAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myParentOriginal, myParentRenamed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
}
|
||||
else if (parentChangeState == ParentChangeState.Pending) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentRenamed);
|
||||
}
|
||||
else {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentRenamed, myChildRenamedInParentRenamed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class RenamedModifiedFileInMoved extends ParentChildChangeTestCase {
|
||||
private static final String FILENAME_RENAMED = "renamed.txt";
|
||||
|
||||
private FilePath myParentOriginal;
|
||||
private FilePath myParentMoved;
|
||||
private FilePath myChildOriginalInParentOriginal;
|
||||
private FilePath myChildOriginalInParentMoved;
|
||||
private FilePath myChildRenamedInParentOriginal;
|
||||
private FilePath myChildRenamedInParentMoved;
|
||||
private FilePath mySubfolder1;
|
||||
private FilePath mySubfolder2;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
mySubfolder1 = getChildPath(mySandboxRoot, "Subfolder1");
|
||||
mySubfolder2 = getChildPath(mySubfolder1, "Subfolder2");
|
||||
|
||||
final String parentFolderName = "ParentFolder";
|
||||
myParentOriginal = getChildPath(mySandboxRoot, parentFolderName);
|
||||
myParentMoved = getChildPath(mySubfolder2, parentFolderName);
|
||||
final String filenameOriginal = "original.txt";
|
||||
|
||||
myChildOriginalInParentOriginal = getChildPath(myParentOriginal, filenameOriginal);
|
||||
myChildOriginalInParentMoved = getChildPath(myParentMoved, filenameOriginal);
|
||||
myChildRenamedInParentOriginal = getChildPath(myParentOriginal, FILENAME_RENAMED);
|
||||
myChildRenamedInParentMoved = getChildPath(myParentMoved, FILENAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
checkParentChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
checkChildChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentMoved);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildRenamedInParentMoved, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildOriginalInParentOriginal, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildOriginalInParentMoved, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildRenamedInParentOriginal, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildRenamedInParentMoved, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentMoved, myChildRenamedInParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildRenamedInParentMoved, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildRenamedInParentMoved, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentMoved);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 1);
|
||||
assertFolder(myParentMoved, 1);
|
||||
assertFile(myChildOriginalInParentMoved, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySubfolder1, 1);
|
||||
assertFolder(mySubfolder2, 0);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildRenamedInParentOriginal, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myParentOriginal);
|
||||
createFileInCommand(myChildOriginalInParentOriginal, ORIGINAL_CONTENT);
|
||||
createDirInCommand(mySubfolder1);
|
||||
createDirInCommand(mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
moveFileInCommand(myParentOriginal, mySubfolder2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) throws VcsException, IOException {
|
||||
rename(parentChangeState == ParentChangeState.NotDone ? myChildOriginalInParentOriginal : myChildOriginalInParentMoved,
|
||||
FILENAME_RENAMED);
|
||||
final FilePath renamedFile =
|
||||
parentChangeState == ParentChangeState.NotDone ? myChildRenamedInParentOriginal : myChildRenamedInParentMoved;
|
||||
editFiles(renamedFile);
|
||||
setFileContent(renamedFile, MODIFIED_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myParentOriginal, myParentMoved);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
}
|
||||
else if (parentChangeState == ParentChangeState.Pending) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentMoved);
|
||||
}
|
||||
else {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentMoved, myChildRenamedInParentMoved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
}
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.parentchildchange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class RenamedModifiedFileInRenamed extends ParentChildChangeTestCase {
|
||||
private static final String FILENAME_RENAMED = "renamed.txt";
|
||||
|
||||
private FilePath myParentOriginal;
|
||||
private FilePath myParentRenamed;
|
||||
|
||||
private FilePath myChildOriginalInParentOriginal;
|
||||
private FilePath myChildOriginalInParentRenamed;
|
||||
private FilePath myChildRenamedInParentOriginal;
|
||||
private FilePath myChildRenamedInParentRenamed;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myParentOriginal = getChildPath(mySandboxRoot, "Original");
|
||||
myParentRenamed = getChildPath(mySandboxRoot, "Renamed");
|
||||
final String filenameOriginal = "ChildOriginal";
|
||||
myChildOriginalInParentOriginal = getChildPath(myParentOriginal, filenameOriginal);
|
||||
myChildOriginalInParentRenamed = getChildPath(myParentRenamed, filenameOriginal);
|
||||
myChildRenamedInParentOriginal = getChildPath(myParentOriginal, FILENAME_RENAMED);
|
||||
myChildRenamedInParentRenamed = getChildPath(myParentRenamed, FILENAME_RENAMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePendingChildRolledBack() throws VcsException {
|
||||
checkParentChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePendingParentRolledBack() throws VcsException {
|
||||
checkChildChangePending();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesPending() throws VcsException {
|
||||
getChanges().assertTotalItems(2);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentRenamed);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentRenamed, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildRenamedInParentRenamed, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollbackParentChild() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildOriginalInParentOriginal, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildOriginalInParentRenamed, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildRenamedInParentOriginal, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentAndChildChangesCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildRenamedInParentRenamed, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangeCommittedChildPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentRenamed, myChildRenamedInParentRenamed, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildRenamedInParentRenamed, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommittedParentPending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildRenamedInParentRenamed, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkParentChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myParentOriginal, myParentRenamed);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentRenamed, 1);
|
||||
assertFile(myChildOriginalInParentRenamed, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myParentOriginal, 1);
|
||||
assertFile(myChildRenamedInParentOriginal, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myParentOriginal);
|
||||
createFileInCommand(myChildOriginalInParentOriginal, ORIGINAL_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeParentChange() {
|
||||
rename(myParentOriginal, myParentRenamed.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange(ParentChangeState parentChangeState) throws VcsException, IOException {
|
||||
rename(parentChangeState == ParentChangeState.NotDone ? myChildOriginalInParentOriginal : myChildOriginalInParentRenamed,
|
||||
FILENAME_RENAMED);
|
||||
|
||||
final FilePath renamedFile =
|
||||
parentChangeState == ParentChangeState.NotDone ? myChildRenamedInParentOriginal : myChildRenamedInParentRenamed;
|
||||
editFiles(renamedFile);
|
||||
setFileContent(renamedFile, MODIFIED_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingParentChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myParentOriginal, myParentRenamed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange(ParentChangeState parentChangeState) throws VcsException {
|
||||
if (parentChangeState == ParentChangeState.NotDone) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentOriginal);
|
||||
}
|
||||
else if (parentChangeState == ParentChangeState.Pending) {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentOriginal, myChildRenamedInParentRenamed);
|
||||
}
|
||||
else {
|
||||
return getChanges().getMoveChange(myChildOriginalInParentRenamed, myChildRenamedInParentRenamed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testPendingAndRollback() throws VcsException, IOException {
|
||||
super.testPendingAndRollback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentThenChildChanges() throws VcsException, IOException {
|
||||
super.testCommitParentThenChildChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildThenParentChanges() throws VcsException, IOException {
|
||||
super.testCommitChildThenParentChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitParentChangesChildPending() throws VcsException, IOException {
|
||||
super.testCommitParentChangesChildPending();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testCommitChildChangesParentPending() throws VcsException, IOException {
|
||||
super.testCommitChildChangesParentPending();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class AddedFileInUpToDate extends SingleChangeTestCase {
|
||||
|
||||
private FilePath myAddedFile;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myAddedFile = getChildPath(mySandboxRoot, "added_file.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myAddedFile, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollback() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertUnversioned(myAddedFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myAddedFile, FILE_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myAddedFile, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange() {
|
||||
if (myAddedFile.getIOFile().exists()) {
|
||||
scheduleForAddition(myAddedFile);
|
||||
}
|
||||
else {
|
||||
createFileInCommand(myAddedFile, FILE_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange() throws VcsException {
|
||||
return getChanges().getAddChange(myAddedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException, IOException {
|
||||
super.doTest();
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class AddedFolderInUpToDate extends SingleChangeTestCase {
|
||||
|
||||
private FilePath myAddedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myAddedFolder = getChildPath(mySandboxRoot, "AddedFolder");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForAddition(myAddedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollback() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertUnversioned(myAddedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myAddedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange() {
|
||||
if (myAddedFolder.getIOFile().exists()) {
|
||||
scheduleForAddition(myAddedFolder);
|
||||
}
|
||||
else {
|
||||
createDirInCommand(myAddedFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange() throws VcsException {
|
||||
return getChanges().getAddChange(myAddedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException, IOException {
|
||||
super.doTest();
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DeletedFileInUpToDate extends SingleChangeTestCase {
|
||||
|
||||
private FilePath myDeletedFile;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myDeletedFile = getChildPath(mySandboxRoot, "deleted_file.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myDeletedFile, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollback() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myDeletedFile, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createFileInCommand(myDeletedFile, FILE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange() {
|
||||
deleteFileInCommand(myDeletedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange() throws VcsException {
|
||||
return getChanges().getDeleteChange(myDeletedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException, IOException {
|
||||
super.doTest();
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DeletedFolderInUpToDate extends SingleChangeTestCase {
|
||||
|
||||
private FilePath myDeletedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myDeletedFolder = getChildPath(mySandboxRoot, "deleted_file.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertScheduledForDeletion(myDeletedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myDeletedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollback() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myDeletedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myDeletedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange() {
|
||||
deleteFileInCommand(myDeletedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change getPendingChildChange() throws VcsException {
|
||||
return getChanges().getDeleteChange(myDeletedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException, IOException {
|
||||
super.doTest();
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class ModifiedFileInUpToDate extends SingleChangeTestCase {
|
||||
|
||||
private FilePath myFile;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myFile = getChildPath(mySandboxRoot, "modified_file.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertModified(myFile, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myFile, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollback() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myFile, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createFileInCommand(myFile, ORIGINAL_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange() throws IOException, VcsException {
|
||||
editFiles(myFile);
|
||||
setFileContent(myFile, MODIFIED_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange() throws VcsException {
|
||||
return getChanges().getModificationChange(myFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException, IOException {
|
||||
super.doTest();
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class MovedFileInUpToDate extends SingleChangeTestCase {
|
||||
|
||||
private static final String FILE_ORIGINAL = "file_original.txt";
|
||||
|
||||
private FilePath myOriginalFile;
|
||||
private FilePath myMovedFile;
|
||||
|
||||
private FilePath mySourceFolder;
|
||||
private FilePath myTargetFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
mySourceFolder = getChildPath(mySandboxRoot, "SourceFolder");
|
||||
myTargetFolder = getChildPath(mySandboxRoot, "TargetFolder");
|
||||
myOriginalFile = getChildPath(mySourceFolder, FILE_ORIGINAL);
|
||||
myMovedFile = getChildPath(myTargetFolder, FILE_ORIGINAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalFile, myMovedFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 0);
|
||||
assertFolder(myTargetFolder, 1);
|
||||
assertFile(myMovedFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 1);
|
||||
assertFolder(myTargetFolder, 0);
|
||||
assertFile(myOriginalFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollback() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 2);
|
||||
assertFolder(mySourceFolder, 0);
|
||||
assertFolder(myTargetFolder, 1);
|
||||
assertFile(myMovedFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(mySourceFolder);
|
||||
createDirInCommand(myTargetFolder);
|
||||
createFileInCommand(myOriginalFile, ORIGINAL_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange() {
|
||||
moveFileInCommand(myOriginalFile, myTargetFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalFile, myMovedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException, IOException {
|
||||
super.doTest();
|
||||
}
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class RenamedFileInUpToDate extends SingleChangeTestCase {
|
||||
|
||||
private FilePath myOriginalFile;
|
||||
private FilePath myRenamedFile;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myOriginalFile = getChildPath(mySandboxRoot, "original.txt");
|
||||
myRenamedFile = getChildPath(mySandboxRoot, "renamed.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalFile, myRenamedFile);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myRenamedFile, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myOriginalFile, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollback() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myRenamedFile, FILE_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createFileInCommand(myOriginalFile, FILE_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange() {
|
||||
rename(myOriginalFile, myRenamedFile.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalFile, myRenamedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException, IOException {
|
||||
super.doTest();
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class RenamedFolderInUpToDate extends SingleChangeTestCase {
|
||||
|
||||
private FilePath myOriginalFolder;
|
||||
private FilePath myRenamedFolder;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myOriginalFolder = getChildPath(mySandboxRoot, "Original");
|
||||
myRenamedFolder = getChildPath(mySandboxRoot, "Renamed");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalFolder, myRenamedFolder);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myOriginalFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollback() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFolder(myRenamedFolder, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createDirInCommand(myOriginalFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange() {
|
||||
rename(myOriginalFolder, myRenamedFolder.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalFolder, myRenamedFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException, IOException {
|
||||
super.doTest();
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class RenamedModifiedFileInUpToDate extends SingleChangeTestCase {
|
||||
|
||||
private FilePath myOriginalFile;
|
||||
private FilePath myRenamedModifiedFile;
|
||||
|
||||
@Override
|
||||
protected void preparePaths() {
|
||||
myOriginalFile = getChildPath(mySandboxRoot, "original.txt");
|
||||
myRenamedModifiedFile = getChildPath(mySandboxRoot, "file_renamed_modified.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangePending() throws VcsException {
|
||||
getChanges().assertTotalItems(1);
|
||||
getChanges().assertRenamedOrMoved(myOriginalFile, myRenamedModifiedFile, ORIGINAL_CONTENT, MODIFIED_CONTENT);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myRenamedModifiedFile, MODIFIED_CONTENT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterUpdate() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myOriginalFile, ORIGINAL_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkOriginalStateAfterRollback() throws VcsException {
|
||||
checkOriginalStateAfterUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkChildChangeCommitted() throws VcsException {
|
||||
getChanges().assertTotalItems(0);
|
||||
|
||||
assertFolder(mySandboxRoot, 1);
|
||||
assertFile(myRenamedModifiedFile, MODIFIED_CONTENT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeOriginalState() {
|
||||
createFileInCommand(myOriginalFile, ORIGINAL_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void makeChildChange() throws IOException, VcsException {
|
||||
rename(myOriginalFile, myRenamedModifiedFile.getName());
|
||||
editFiles(myRenamedModifiedFile);
|
||||
setFileContent(myRenamedModifiedFile, MODIFIED_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Change getPendingChildChange() throws VcsException {
|
||||
return getChanges().getMoveChange(myOriginalFile, myRenamedModifiedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void doTest() throws VcsException, IOException {
|
||||
super.doTest();
|
||||
}
|
||||
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2000-2008 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.tfsIntegration.tests.singlechange;
|
||||
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.tfsIntegration.core.TFSChangeList;
|
||||
import org.jetbrains.tfsIntegration.core.tfs.TfsFileUtil;
|
||||
import org.jetbrains.tfsIntegration.tests.ChangeHelper;
|
||||
import org.jetbrains.tfsIntegration.tests.TFSTestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public abstract class SingleChangeTestCase extends TFSTestCase {
|
||||
|
||||
protected static final String ORIGINAL_CONTENT = "original content";
|
||||
protected static final String MODIFIED_CONTENT = "modified content";
|
||||
protected static final String FILE_CONTENT = "file_content";
|
||||
private static final String CHILD_CHANGE_COMMIT_COMMENT = "child change";
|
||||
private static final String INITIAL_STATE_COMMIT_COMMENT = "initial state";
|
||||
|
||||
|
||||
protected abstract void preparePaths();
|
||||
|
||||
protected abstract void checkChildChangePending() throws VcsException;
|
||||
|
||||
protected abstract void checkOriginalStateAfterUpdate() throws VcsException;
|
||||
|
||||
protected abstract void checkOriginalStateAfterRollback() throws VcsException;
|
||||
|
||||
protected abstract void checkChildChangeCommitted() throws VcsException;
|
||||
|
||||
|
||||
protected abstract void makeOriginalState();
|
||||
|
||||
protected abstract void makeChildChange() throws IOException, VcsException;
|
||||
|
||||
@Nullable
|
||||
protected abstract Change getPendingChildChange() throws VcsException;
|
||||
|
||||
|
||||
protected void doTest() throws VcsException, IOException {
|
||||
preparePaths();
|
||||
|
||||
makeOriginalState();
|
||||
final List<Change> originalStateChanges = getChanges().getChanges();
|
||||
if (!originalStateChanges.isEmpty()) {
|
||||
commit(originalStateChanges, INITIAL_STATE_COMMIT_COMMENT);
|
||||
}
|
||||
checkOriginalStateAfterUpdate();
|
||||
|
||||
// check child change
|
||||
makeChildChange();
|
||||
checkChildChangePending();
|
||||
updateTo(0);
|
||||
checkChildChangePending();
|
||||
rollback(getPendingChildChange());
|
||||
checkOriginalStateAfterRollback();
|
||||
|
||||
makeChildChange();
|
||||
final Change childChange = getPendingChildChange();
|
||||
final Change changeToCheck = ChangeHelper.getChangeWithCachedContent(childChange);
|
||||
commit(childChange, CHILD_CHANGE_COMMIT_COMMENT);
|
||||
updateTo(1);
|
||||
checkOriginalStateAfterUpdate();
|
||||
updateTo(0);
|
||||
checkChildChangeCommitted();
|
||||
|
||||
assertHistory(changeToCheck, !originalStateChanges.isEmpty());
|
||||
}
|
||||
|
||||
private void assertHistory(Change change, boolean originalStateCommited) throws VcsException {
|
||||
final RepositoryLocation location = getVcs().getCommittedChangesProvider().getLocationFor(TfsFileUtil.getFilePath(mySandboxRoot));
|
||||
final List<TFSChangeList> historyList =
|
||||
getVcs().getCommittedChangesProvider().getCommittedChanges(new ChangeBrowserSettings(), location, 0);
|
||||
|
||||
Assert.assertEquals(originalStateCommited ? 3 : 2, historyList.size());
|
||||
TFSChangeList changelist = historyList.get(0);
|
||||
|
||||
Assert.assertEquals(CHILD_CHANGE_COMMIT_COMMENT, changelist.getComment());
|
||||
assertUserNameEqual(changelist.getCommitterName());
|
||||
ChangeHelper.assertContains(Collections.singletonList(change), changelist.getChanges());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user