use of org.jetbrains.idea.svn.treeConflict.SvnTreeConflictResolver in project intellij-community by JetBrains.
the class SvnResolveTreeAcceptVariantsTest method testMineFull.
@Test
public void testMineFull() throws Exception {
int cnt = 0;
myWorkingCopyDir = createDirInCommand(myWorkingCopyDir, "test--");
myTheirs = createDirInCommand(myTheirs, "theirs--");
//final TreeConflictData.Data data = TreeConflictData.FileToFile.MINE_EDIT_THEIRS_MOVE;
for (final TreeConflictData.Data data : TreeConflictData.ourAll) {
if (myTraceClient) {
System.out.println("========= TEST " + getTestName(data) + " =========");
}
((ChangeListManagerImpl) myChangeListManager).stopEveryThingIfInTestMode();
myWorkingCopyDir = createDirInCommand(myWorkingCopyDir.getParent(), "test" + cnt);
myTheirs = createDirInCommand(myTheirs.getParent(), "theirs" + cnt);
mySvnClientRunner.checkout(myRepoUrl, myTheirs);
mySvnClientRunner.checkout(myRepoUrl, myWorkingCopyDir);
sleep(200);
ProjectLevelVcsManager.getInstance(myProject).setDirectoryMappings(Collections.singletonList(new VcsDirectoryMapping(myWorkingCopyDir.getPath(), myVcs.getName())));
createSubTree(data);
myTheirs.refresh(false, true);
final ConflictCreator creator = new ConflictCreator(myProject, myTheirs, myWorkingCopyDir, data, mySvnClientRunner);
creator.create();
sleep(200);
((ChangeListManagerImpl) myChangeListManager).forceGoInTestMode();
myDirtyScopeManager.markEverythingDirty();
myChangeListManager.ensureUpToDate(false);
myDirtyScopeManager.markEverythingDirty();
myChangeListManager.ensureUpToDate(false);
final String conflictFile = data.getConflictFile();
final File conflictIoFile = new File(myWorkingCopyDir.getPath(), conflictFile);
final FilePath filePath = VcsUtil.getFilePath(conflictIoFile);
final Change change = myChangeListManager.getChange(filePath);
Assert.assertNotNull(change);
Assert.assertTrue(change instanceof ConflictedSvnChange);
final SvnRevisionNumber committedRevision = change.getBeforeRevision() != null ? (SvnRevisionNumber) change.getBeforeRevision().getRevisionNumber() : null;
//SvnRevisionNumber committedRevision = new SvnRevisionNumber(SVNRevision.create(cnt * 2 + 1));
final SvnTreeConflictResolver resolver = new SvnTreeConflictResolver(myVcs, filePath, null);
resolver.resolveSelectMineFull();
myTheirs.refresh(false, true);
myWorkingCopyDir.refresh(false, true);
checkStatusesAfterMineFullResolve(data, conflictIoFile);
checkFileContents(data, conflictIoFile);
++cnt;
}
}
use of org.jetbrains.idea.svn.treeConflict.SvnTreeConflictResolver in project intellij-community by JetBrains.
the class SvnResolveTreeAcceptVariantsTest method testTheirsFull.
@Test
public void testTheirsFull() throws Exception {
int cnt = 0;
myWorkingCopyDir = createDirInCommand(myWorkingCopyDir, "test--");
myTheirs = createDirInCommand(myTheirs, "theirs--");
//final TreeConflictData.Data data = TreeConflictData.FileToFile.MINE_MOVE_THEIRS_ADD;
for (final TreeConflictData.Data data : TreeConflictData.ourAll) {
if (myTraceClient) {
System.out.println("========= TEST " + getTestName(data) + " =========");
}
myWorkingCopyDir = createDirInCommand(myWorkingCopyDir.getParent(), "test" + cnt);
myTheirs = createDirInCommand(myTheirs.getParent(), "theirs" + cnt);
mySvnClientRunner.checkout(myRepoUrl, myTheirs);
mySvnClientRunner.checkout(myRepoUrl, myWorkingCopyDir);
createSubTree(data);
final ConflictCreator creator = new ConflictCreator(myProject, myTheirs, myWorkingCopyDir, data, mySvnClientRunner);
creator.create();
myDirtyScopeManager.markEverythingDirty();
myChangeListManager.ensureUpToDate(false);
myDirtyScopeManager.markEverythingDirty();
myChangeListManager.ensureUpToDate(false);
final String conflictFile = data.getConflictFile();
final File conflictIoFile = new File(myWorkingCopyDir.getPath(), conflictFile);
final FilePath filePath = VcsUtil.getFilePath(conflictIoFile);
final Change change = myChangeListManager.getChange(filePath);
Assert.assertNotNull(change);
Assert.assertTrue(change instanceof ConflictedSvnChange);
final SvnRevisionNumber committedRevision = change.getBeforeRevision() != null ? (SvnRevisionNumber) change.getBeforeRevision().getRevisionNumber() : null;
FilePath beforePath = null;
if (change.isMoved() || change.isRenamed()) {
beforePath = change.getBeforeRevision().getFile();
}
//SvnRevisionNumber committedRevision = new SvnRevisionNumber(SVNRevision.create(cnt * 2 + 1));
final SvnTreeConflictResolver resolver = new SvnTreeConflictResolver(myVcs, filePath, beforePath);
resolver.resolveSelectTheirsFull();
myTheirs.refresh(false, true);
myWorkingCopyDir.refresh(false, true);
VfsUtil.processFileRecursivelyWithoutIgnored(myTheirs, file -> {
final String relative = VfsUtil.getRelativePath(file, myTheirs, File.separatorChar);
File workingFile = new File(myWorkingCopyDir.getPath(), relative);
boolean exists = workingFile.exists();
if (!exists) {
String[] excluded = data.getExcludeFromToTheirsCheck();
if (excluded != null && Arrays.asList(excluded).contains(relative)) {
return true;
}
Assert.assertTrue("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath(), exists);
}
final File theirsFile = virtualToIoFile(file);
Info theirsInfo = myVcs.getInfo(theirsFile);
Info thisInfo = myVcs.getInfo(workingFile);
if (theirsInfo != null) {
Assert.assertEquals("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath() + ", theirs: " + theirsInfo.getRevision().getNumber() + ", mine: " + thisInfo.getRevision().getNumber(), theirsInfo.getRevision().getNumber(), thisInfo.getRevision().getNumber());
if (!theirsFile.isDirectory()) {
try {
final String workText = FileUtil.loadFile(workingFile);
final String theirsText = FileUtil.loadFile(theirsFile);
Assert.assertEquals(theirsText, workText);
} catch (IOException e) {
Assert.assertTrue(e.getMessage(), false);
}
}
}
return true;
});
++cnt;
}
}
Aggregations