Search in sources :

Example 1 with SVNPropertyData

use of org.tmatesoft.svn.core.wc.SVNPropertyData in project intellij-community by JetBrains.

the class SvnQuickMergeTest method testSelectRevisions.

@Test
public void testSelectRevisions() throws Exception {
    // get revision #
    final SVNInfo info = myVcs.getSvnKitManager().createWCClient().doInfo(virtualToIoFile(myBranchTree.myS1File), WORKING);
    Assert.assertNotNull(info);
    final long numberBefore = info.getRevision().getNumber();
    final int totalChanges = 10;
    final StringBuilder sb = new StringBuilder(FileUtil.loadFile(virtualToIoFile(myBranchTree.myS1File)));
    for (int i = 0; i < totalChanges; i++) {
        sb.append("\nedited in branch ").append(i);
        VcsTestUtil.editFileInCommand(myProject, myBranchTree.myS1File, sb.toString());
        runInAndVerifyIgnoreOutput(myBranchRoot, "ci", "-m", "change in branch " + i, myBranchTree.myS1File.getPath());
        Thread.sleep(10);
    }
    QuickMergeTestInteraction testInteraction = new QuickMergeTestInteraction(true, lists -> lists.stream().filter(list -> numberBefore + 1 == list.getNumber() || numberBefore + 2 == list.getNumber()).collect(toList()));
    testInteraction.setMergeVariant(QuickMergeContentsVariants.select);
    waitQuickMerge(myBranchUrl, testInteraction);
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    // should have changed svn:mergeinfo on wc root and s1 file
    final Change fileChange = myChangeListManager.getChange(myTree.myS1File);
    Assert.assertNotNull(fileChange);
    Assert.assertEquals(FileStatus.MODIFIED, fileChange.getFileStatus());
    final Change dirChange = myChangeListManager.getChange(myWorkingCopyDir);
    Assert.assertNotNull(dirChange);
    Assert.assertEquals(FileStatus.MODIFIED, dirChange.getFileStatus());
    final SVNPropertyData data = myVcs.getSvnKitManager().createWCClient().doGetProperty(virtualToIoFile(myWorkingCopyDir), "svn:mergeinfo", UNDEFINED, WORKING);
    System.out.println(data.getValue().getString());
    Assert.assertEquals("/branches/b1:" + (numberBefore + 1) + "-" + (numberBefore + 2), data.getValue().getString());
}
Also used : SVNPropertyData(org.tmatesoft.svn.core.wc.SVNPropertyData) SVNInfo(org.tmatesoft.svn.core.wc.SVNInfo) Change(com.intellij.openapi.vcs.changes.Change) Test(org.junit.Test)

Example 2 with SVNPropertyData

use of org.tmatesoft.svn.core.wc.SVNPropertyData in project intellij-community by JetBrains.

the class SvnQuickMergeTest method testSelectRevisionsWithQuickSelectCheckForLocalChanges.

@Test
public void testSelectRevisionsWithQuickSelectCheckForLocalChanges() throws Exception {
    // get revision #
    final SVNInfo info = myVcs.getSvnKitManager().createWCClient().doInfo(virtualToIoFile(myBranchTree.myS1File), WORKING);
    Assert.assertNotNull(info);
    final long numberBefore = info.getRevision().getNumber();
    final int totalChanges = 3;
    final StringBuilder sb = new StringBuilder(FileUtil.loadFile(virtualToIoFile(myBranchTree.myS1File)));
    for (int i = 0; i < totalChanges; i++) {
        sb.append("\nedited in branch ").append(i);
        VcsTestUtil.editFileInCommand(myProject, myBranchTree.myS1File, sb.toString());
        runInAndVerifyIgnoreOutput(myBranchRoot, "ci", "-m", "change in branch " + i, myBranchTree.myS1File.getPath());
        Thread.sleep(10);
    }
    AtomicReference<String> selectionError = new AtomicReference<>();
    QuickMergeTestInteraction testInteraction = new QuickMergeTestInteraction(true, lists -> {
        if (lists.get(3).getNumber() != numberBefore) {
            selectionError.set("wrong revision for copy statement: " + lists.get(3).getNumber());
        }
        return new SmartList<>(lists.get(2));
    });
    testInteraction.setMergeVariant(QuickMergeContentsVariants.showLatest);
    waitQuickMerge(myBranchUrl, testInteraction);
    if (selectionError.get() != null) {
        throw new RuntimeException(selectionError.get());
    }
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    // should have changed svn:mergeinfo on wc root and s1 file
    final Change fileChange = myChangeListManager.getChange(myTree.myS1File);
    Assert.assertNotNull(fileChange);
    Assert.assertEquals(FileStatus.MODIFIED, fileChange.getFileStatus());
    final Change dirChange = myChangeListManager.getChange(myWorkingCopyDir);
    Assert.assertNotNull(dirChange);
    Assert.assertEquals(FileStatus.MODIFIED, dirChange.getFileStatus());
    final SVNPropertyData data = myVcs.getSvnKitManager().createWCClient().doGetProperty(virtualToIoFile(myWorkingCopyDir), "svn:mergeinfo", UNDEFINED, WORKING);
    System.out.println(data.getValue().getString());
    Assert.assertEquals("/branches/b1:" + (numberBefore + 1), data.getValue().getString());
}
Also used : SVNPropertyData(org.tmatesoft.svn.core.wc.SVNPropertyData) SVNInfo(org.tmatesoft.svn.core.wc.SVNInfo) AtomicReference(java.util.concurrent.atomic.AtomicReference) Change(com.intellij.openapi.vcs.changes.Change) SmartList(com.intellij.util.SmartList) Test(org.junit.Test)

Example 3 with SVNPropertyData

use of org.tmatesoft.svn.core.wc.SVNPropertyData in project intellij-community by JetBrains.

the class SvnQuickMergeTest method testSelectRevisionsWithQuickSelect.

// this test is mainly to check revisions selection. at the moment we are not sure whether we support
// trunk->b1->b2 merges between trunk and b2
@Test
public void testSelectRevisionsWithQuickSelect() throws Exception {
    // get revision #
    final SVNInfo info = myVcs.getSvnKitManager().createWCClient().doInfo(virtualToIoFile(myBranchTree.myS1File), WORKING);
    Assert.assertNotNull(info);
    final long numberBefore = info.getRevision().getNumber();
    final int totalChanges = 3;
    final StringBuilder sb = new StringBuilder(FileUtil.loadFile(virtualToIoFile(myBranchTree.myS1File)));
    for (int i = 0; i < totalChanges; i++) {
        sb.append("\nedited in branch ").append(i);
        VcsTestUtil.editFileInCommand(myProject, myBranchTree.myS1File, sb.toString());
        runInAndVerifyIgnoreOutput(myBranchRoot, "ci", "-m", "change in branch " + i, myBranchTree.myS1File.getPath());
        Thread.sleep(10);
    }
    // before copy
    final SVNInfo info2 = myVcs.getSvnKitManager().createWCClient().doInfo(virtualToIoFile(myBranchTree.myS1File), WORKING);
    Assert.assertNotNull(info2);
    final long numberBeforeCopy = info2.getRevision().getNumber();
    runInAndVerifyIgnoreOutput("copy", "-q", "-m", "copy1", myBranchUrl, myRepoUrl + "/branches/b2");
    // switch b1 to b2
    runInAndVerifyIgnoreOutput(myBranchRoot, "switch", myRepoUrl + "/branches/b2", myBranchRoot.getPath());
    //reload
    myBranchTree = new SubTree(myBranchVf);
    // one commit in b2 in s2 file
    VcsTestUtil.editFileInCommand(myProject, myBranchTree.myS2File, "completely changed");
    runInAndVerifyIgnoreOutput(myBranchRoot, "ci", "-m", "change in b2", myBranchTree.myS2File.getPath());
    AtomicReference<String> selectionError = new AtomicReference<>();
    QuickMergeTestInteraction testInteraction = new QuickMergeTestInteraction(true, lists -> {
        if (lists.get(1).getNumber() != numberBeforeCopy + 1) {
            selectionError.set("wrong revision for copy statement: " + lists.get(1).getNumber());
        }
        return new SmartList<>(lists.get(0));
    });
    testInteraction.setMergeVariant(QuickMergeContentsVariants.showLatest);
    waitQuickMerge(myRepoUrl + "/branches/b2", testInteraction);
    if (selectionError.get() != null) {
        throw new RuntimeException(selectionError.get());
    }
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    // should have changed svn:mergeinfo on wc root and s1 file
    final Change fileChange = myChangeListManager.getChange(myTree.myS2File);
    Assert.assertNotNull(fileChange);
    Assert.assertEquals(FileStatus.MODIFIED, fileChange.getFileStatus());
    final Change dirChange = myChangeListManager.getChange(myWorkingCopyDir);
    Assert.assertNotNull(dirChange);
    Assert.assertEquals(FileStatus.MODIFIED, dirChange.getFileStatus());
    final SVNPropertyData data = myVcs.getSvnKitManager().createWCClient().doGetProperty(virtualToIoFile(myWorkingCopyDir), "svn:mergeinfo", UNDEFINED, WORKING);
    System.out.println(data.getValue().getString());
    Assert.assertEquals("/branches/b2:" + (numberBeforeCopy + 2), data.getValue().getString());
}
Also used : SVNPropertyData(org.tmatesoft.svn.core.wc.SVNPropertyData) SVNInfo(org.tmatesoft.svn.core.wc.SVNInfo) AtomicReference(java.util.concurrent.atomic.AtomicReference) Change(com.intellij.openapi.vcs.changes.Change) SmartList(com.intellij.util.SmartList) Test(org.junit.Test)

Example 4 with SVNPropertyData

use of org.tmatesoft.svn.core.wc.SVNPropertyData in project intellij-community by JetBrains.

the class SvnMergeInfoTest method assertMergeInfo.

private void assertMergeInfo(@NotNull File file, @NotNull String... values) throws SVNException {
    // TODO: Replace with ClientFactory model
    final SvnVcs vcs = SvnVcs.getInstance(myProject);
    final SVNWCClient wcClient = vcs.getSvnKitManager().createWCClient();
    final SVNPropertyData data = wcClient.doGetProperty(file, "svn:mergeinfo", SVNRevision.UNDEFINED, SVNRevision.WORKING);
    assert data != null && data.getValue() != null;
    boolean result = false;
    for (String value : values) {
        result |= value.equals(data.getValue().getString());
    }
    assert result;
}
Also used : SVNPropertyData(org.tmatesoft.svn.core.wc.SVNPropertyData) SVNWCClient(org.tmatesoft.svn.core.wc.SVNWCClient)

Example 5 with SVNPropertyData

use of org.tmatesoft.svn.core.wc.SVNPropertyData in project intellij-community by JetBrains.

the class SvnRollbackTest method getProperty.

private String getProperty(File file, String name) throws SVNException {
    final SVNWCClient client = myVcs.getSvnKitManager().createWCClient();
    final SVNPropertyData data = client.doGetProperty(file, name, SVNRevision.UNDEFINED, SVNRevision.WORKING);
    return data == null ? null : new String(data.getValue().getBytes());
}
Also used : SVNPropertyData(org.tmatesoft.svn.core.wc.SVNPropertyData) SVNWCClient(org.tmatesoft.svn.core.wc.SVNWCClient)

Aggregations

SVNPropertyData (org.tmatesoft.svn.core.wc.SVNPropertyData)7 SVNWCClient (org.tmatesoft.svn.core.wc.SVNWCClient)4 Change (com.intellij.openapi.vcs.changes.Change)3 Test (org.junit.Test)3 SVNInfo (org.tmatesoft.svn.core.wc.SVNInfo)3 SmartList (com.intellij.util.SmartList)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 SvnVcs (org.jetbrains.idea.svn.SvnVcs)1