Search in sources :

Example 1 with SVNInfo

use of org.tmatesoft.svn.core.wc.SVNInfo 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 SVNInfo

use of org.tmatesoft.svn.core.wc.SVNInfo 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 SVNInfo

use of org.tmatesoft.svn.core.wc.SVNInfo 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 SVNInfo

use of org.tmatesoft.svn.core.wc.SVNInfo in project Gargoyle by callakrsos.

the class SVNResource method getSvnUrlByFileSystem.

/**
	 * SVN 서버에 연결된 루트 디렉토리에 속하는 로컬 파일시스템의 파일에 해당하는 SVN서버 경로를 리턴한다.
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 8. 1.
	 * @return
	 * @throws Exception
	 */
public SVNURL getSvnUrlByFileSystem(File file, SVNRevision revision) throws Exception {
    SVNClientManager svnManager2 = getSvnManager();
    SVNInfo doInfo = svnManager2.getWCClient().doInfo(file, revision);
    return doInfo.getURL();
}
Also used : SVNInfo(org.tmatesoft.svn.core.wc.SVNInfo) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager)

Example 5 with SVNInfo

use of org.tmatesoft.svn.core.wc.SVNInfo in project ontrack by nemerosa.

the class SVNConfigurationServiceImpl method validate.

@Override
protected ConnectionResult validate(SVNConfiguration configuration) {
    // No trailing slash
    String url = configuration.getUrl();
    if (StringUtils.endsWith(url, "/")) {
        throw new SVNURLFormatException("The Subversion URL must not end with a slash: %s", url);
    }
    try (Transaction ignored = transactionService.start()) {
        // Creates a repository
        SVNRepository repository = SVNRepository.of(0, configuration, null);
        // Configuration URL
        SVNURL svnurl = SVNUtils.toURL(configuration.getUrl());
        // Connection to the root
        if (!svnClient.exists(repository, svnurl, SVNRevision.HEAD)) {
            return ConnectionResult.error(configuration.getUrl() + " does not exist.");
        }
        // Gets base info
        SVNInfo info = svnClient.getInfo(repository, svnurl, SVNRevision.HEAD);
        // Checks the repository root
        if (!Objects.equals(info.getRepositoryRootURL(), svnurl)) {
            return ConnectionResult.error(configuration.getUrl() + " must be the root of the repository.");
        }
        // OK
        return ConnectionResult.ok();
    } catch (Exception ex) {
        return ConnectionResult.error(ex.getMessage());
    }
}
Also used : Transaction(net.nemerosa.ontrack.tx.Transaction) SVNURL(org.tmatesoft.svn.core.SVNURL) SVNURLFormatException(net.nemerosa.ontrack.extension.svn.model.SVNURLFormatException) SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository) SVNInfo(org.tmatesoft.svn.core.wc.SVNInfo) ConfigurationValidationException(net.nemerosa.ontrack.model.support.ConfigurationValidationException) SVNURLFormatException(net.nemerosa.ontrack.extension.svn.model.SVNURLFormatException)

Aggregations

SVNInfo (org.tmatesoft.svn.core.wc.SVNInfo)10 Test (org.junit.Test)4 Change (com.intellij.openapi.vcs.changes.Change)3 SVNClientManager (org.tmatesoft.svn.core.wc.SVNClientManager)3 SVNPropertyData (org.tmatesoft.svn.core.wc.SVNPropertyData)3 SmartList (com.intellij.util.SmartList)2 File (java.io.File)2 Map (java.util.Map)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 SVNException (org.tmatesoft.svn.core.SVNException)2 SVNURL (org.tmatesoft.svn.core.SVNURL)2 SVNLogClient (org.tmatesoft.svn.core.wc.SVNLogClient)2 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)2 SVNWCClient (org.tmatesoft.svn.core.wc.SVNWCClient)2 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 Instant (java.time.Instant)1