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());
}
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());
}
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());
}
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();
}
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());
}
}
Aggregations