Java Code Examples for org.tigris.subversion.svnclientadapter.ISVNClientAdapter#switchToUrl()

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNClientAdapter#switchToUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwitchToTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSwitchToFile() throws Exception {                                        
    File file = createFile("file");
    add(file);
    commit(file);
            
    File filecopy = createFile("filecopy");
    
    ISVNClientAdapter c = getNbClient();
    c.copy(getFileUrl(file), getFileUrl(filecopy), "copy", SVNRevision.HEAD);

    assertCopy(getFileUrl(filecopy));
    assertInfo(file, getFileUrl(file));
    
    c.switchToUrl(file, getFileUrl(filecopy), SVNRevision.HEAD, false);
    
    assertInfo(file, getFileUrl(filecopy));         
    assertNotifiedFiles();// XXX empty also in svnCA - why?! - no output from cli
}
 
Example 2
Source File: MergeTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testFolderMergeRec() throws Exception {                                        
    File folder = createFolder("folder");
    add(folder);
    commit(folder);
    assertInfo(folder, getFileUrl(folder));
    
    File foldercopy = new File(getWC(), "foldercopy");
    
    ISVNClientAdapter c = getNbClient();
    c.copy(getFileUrl(folder), getFileUrl(foldercopy), "copy", SVNRevision.HEAD);
    c.switchToUrl(folder, getFileUrl(foldercopy), SVNRevision.HEAD, true);

    assertCopy(getFileUrl(foldercopy));
    assertInfo(folder, getFileUrl(foldercopy));
    
    File folder1 = createFolder(folder, "folder1");
    File file = createFile(folder, "file");
    File file1 = createFile(folder1, "file");
    add(file);
    add(folder1);
    add(file1);
    commit(folder);
    assertTrue(file.exists());
    
    c.switchToUrl(folder, getFileUrl(folder), SVNRevision.HEAD, true);
    assertCopy(getFileUrl(folder));
    assertInfo(folder, getFileUrl(folder));        
    assertFalse(file.exists());
    assertFalse(file1.exists());
    assertFalse(folder1.exists());
    
    ISVNLogMessage[] log = getCompleteLog(getFileUrl(folder));
    c.merge(getFileUrl(foldercopy), log[0].getRevision(), getFileUrl(foldercopy), SVNRevision.HEAD, folder, false, true);
    assertTrue(file.exists());
    assertTrue(file1.exists());
    assertTrue(folder1.exists());
    assertNotifiedFiles(new File[] {file, file1, folder1});        
}
 
Example 3
Source File: SwitchToTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testSwitchToFilePrevRev() throws Exception {                                        
    File file = createFile("file");
    add(file);
    write(file, 1);
    commit(file);
    
    File filecopy = createFile("filecopy");
    
    ISVNClientAdapter c = getNbClient();
    c.copy(getFileUrl(file), getFileUrl(filecopy), "copy", SVNRevision.HEAD);

    assertCopy(getFileUrl(filecopy));
    assertInfo(file, getFileUrl(file));
    
    // switch to copy
    c.switchToUrl(file, getFileUrl(filecopy), SVNRevision.HEAD, false);        
    assertInfo(file, getFileUrl(filecopy));        
    
    SVNRevision prevrev = getRevision(file);
    
    // change copy
    write(file, 2);
    commit(file);
    
    // switch to trunk
    c.switchToUrl(file, getFileUrl(file), SVNRevision.HEAD, false);        
    assertInfo(file, getFileUrl(file));        
    
    // switch to copies prev revision
    c.switchToUrl(file, getFileUrl(filecopy), prevrev, false);    
    
    // test
    assertInfo(file, getFileUrl(filecopy));        
    assertContents(file, 1);
    SVNRevision rev = getRevision(file);
    assertEquals(((SVNRevision.Number)prevrev).getNumber(), ((SVNRevision.Number)rev).getNumber());
    assertNotifiedFiles(file);        
}
 
Example 4
Source File: SwitchToTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testSwitchToFolderNonRec() throws Exception {                                        
    File folder = createFolder("folder");
    File file = createFile(folder, "file");
    File folder1 = createFolder(folder, "folder1");
    File file1 = createFile(folder1, "file1");
    add(folder);
    add(file);
    add(folder1);
    add(file1);
    commit(folder);
            
    File foldercopy = createFolder("foldercopy");
    
    ISVNClientAdapter c = getNbClient();
    c.copy(getFileUrl(folder), getFileUrl(foldercopy), "copy", SVNRevision.HEAD);

    assertCopy(getFileUrl(foldercopy));
    assertInfo(folder, getFileUrl(folder));
    assertInfo(file, getFileUrl(folder).appendPath(file.getName()));
    assertInfo(folder1, getFileUrl(folder).appendPath(folder1.getName()));
    assertInfo(file1, getFileUrl(folder).appendPath(folder1.getName()).appendPath(file1.getName()));
    
    c.switchToUrl(folder, getFileUrl(foldercopy), SVNRevision.HEAD, false);
    
    assertInfo(folder, getFileUrl(foldercopy));
    assertInfo(file, getFileUrl(foldercopy).appendPath(file.getName()));        
    assertInfo(folder1, getFileUrl(folder).appendPath(folder1.getName()));
    assertInfo(file1, getFileUrl(folder).appendPath(folder1.getName()).appendPath(file1.getName()));
    assertNotifiedFiles(new File[] {});  // XXX empty also in svnCA - why?! - no output from cli      
}
 
Example 5
Source File: SwitchToTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testSwitchToFolderRec() throws Exception {
    File folder = createFolder("folder");
    File file = createFile(folder, "file");
    File folder1 = createFolder(folder, "folder1");
    File file1 = createFile(folder1, "file1");
    add(folder);
    add(file);
    add(folder1);
    add(file1);
    commit(folder);

    File foldercopy = createFolder("foldercopy");

    ISVNClientAdapter c = getNbClient();
    c.copy(getFileUrl(folder), getFileUrl(foldercopy), "copy", SVNRevision.HEAD);

    assertCopy(getFileUrl(foldercopy));
    assertInfo(folder, getFileUrl(folder));
    assertInfo(file, getFileUrl(folder).appendPath(file.getName()));
    assertInfo(folder1, getFileUrl(folder).appendPath(folder1.getName()));
    assertInfo(file1, getFileUrl(folder).appendPath(folder1.getName()).appendPath(file1.getName()));

    c.switchToUrl(folder, getFileUrl(foldercopy), SVNRevision.HEAD, true);

    assertInfo(folder, getFileUrl(foldercopy));
    assertInfo(file, getFileUrl(foldercopy).appendPath(file.getName()));
    assertInfo(folder1, getFileUrl(foldercopy).appendPath(folder1.getName()));
    assertInfo(file1, getFileUrl(foldercopy).appendPath(folder1.getName()).appendPath(file1.getName()));
    assertNotifiedFiles(new File[] {});       // XXX empty also in svnCA - why?! - no output from cli
}
 
Example 6
Source File: SwitchToTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testSwitchToFolderWithAtSignRec() throws Exception {
    if(!shouldBeTestedWithCurrentClient(true, false)) {
        return;
    }
    File folder = createFolder("fol@der");
    File file = createFile(folder, "file");
    File folder1 = createFolder(folder, "folder1");
    File file1 = createFile(folder1, "file1");
    add(folder);
    add(file);
    add(folder1);
    add(file1);
    commit(folder);

    File foldercopy = createFolder("folder@copy");

    ISVNClientAdapter c = getNbClient();
    c.copy(getFileUrl(folder), getFileUrl(foldercopy), "copy", SVNRevision.HEAD);

    assertCopy(getFileUrl(foldercopy));
    assertInfo(folder, getFileUrl(folder));
    assertInfo(file, getFileUrl(folder).appendPath(file.getName()));
    assertInfo(folder1, getFileUrl(folder).appendPath(folder1.getName()));
    assertInfo(file1, getFileUrl(folder).appendPath(folder1.getName()).appendPath(file1.getName()));

    c.switchToUrl(folder, getFileUrl(foldercopy), SVNRevision.HEAD, true);

    assertInfo(folder, getFileUrl(foldercopy));
    assertInfo(file, getFileUrl(foldercopy).appendPath(file.getName()));
    assertInfo(folder1, getFileUrl(foldercopy).appendPath(folder1.getName()));
    assertInfo(file1, getFileUrl(foldercopy).appendPath(folder1.getName()).appendPath(file1.getName()));
    assertNotifiedFiles(new File[] {});       // XXX empty also in svnCA - why?! - no output from cli
}
 
Example 7
Source File: SwitchToUrlCommand.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void run(IProgressMonitor monitor) throws SVNException {    
	final IProgressMonitor subPm = Policy.infiniteSubMonitorFor(monitor, 100);
	ISVNClientAdapter svnClient = null;
       try {
   		subPm.beginTask(null, Policy.INFINITE_PM_GUESS_FOR_SWITCH);
           svnClient = root.getRepository().getSVNClient();
   		if (conflictResolver != null) {
   			svnClient.addConflictResolutionCallback(conflictResolver);
   		}
           svnClient.addNotifyListener(operationResourceCollector);
           OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(subPm, svnClient));
           File file = resource.getLocation().toFile();
           svnClient.switchToUrl(file, svnUrl, svnRevision, svnRevision, depth, setDepth, ignoreExternals, force, ignoreAncestry);
           OperationManager.getInstance().onNotify(resource.getLocation().toFile(), SVNNodeKind.UNKNOWN);
       } catch (SVNClientException e) {
           throw SVNException.wrapException(e);
       } finally {
       	Set<IResource> operationResources = operationResourceCollector.getOperationResources();
       	if (operationResources.size() == 0) {
       		IResource[] resources = SVNWorkspaceRoot.getResourcesFor(resource);
       		for (IResource refreshResource : resources) {
       			operationResources.add(refreshResource);
       		}
       	}
           OperationManager.getInstance().endOperation(true, operationResources);
           if (svnClient != null) {
    		if (conflictResolver != null) {
    			svnClient.addConflictResolutionCallback(null);
    		}
    		root.getRepository().returnSVNClient(svnClient);
           }
           subPm.done();
       }
}
 
Example 8
Source File: MergeTestHidden.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testMergeFolderNonRec() throws Exception {                                        
    // init wc
    File folder = createFolder("folder");
    add(folder);
    commit(folder);
    assertInfo(folder, getFileUrl(folder));
    
    // init copy from wc
    File foldercopy = new File(getWC(), "foldercopy");
            
    ISVNClientAdapter c = getNbClient();
    c.copy(getFileUrl(folder), getFileUrl(foldercopy), "copy", SVNRevision.HEAD);
    // switch to copy
    c.switchToUrl(folder, getFileUrl(foldercopy), SVNRevision.HEAD, true);

    assertCopy(getFileUrl(foldercopy));
    assertInfo(folder, getFileUrl(foldercopy));
    
    // add new files to copy
    File folder1 = createFolder(folder, "folder1");
    File file = createFile(folder, "file");
    File file1 = createFile(folder1, "file");
    add(file);
    add(folder1);
    add(file1);
    commit(folder);
    assertTrue(file.exists());
    
    // switch back to wc
    c.switchToUrl(folder, getFileUrl(folder), SVNRevision.HEAD, true);
    assertCopy(getFileUrl(folder));
    assertInfo(folder, getFileUrl(folder));        
    assertFalse(file.exists());
    assertFalse(file1.exists());
    assertFalse(folder1.exists());
    
    // merge wc with copy
    ISVNLogMessage[] log = getCompleteLog(getFileUrl(folder));
    c.merge(getFileUrl(foldercopy), log[0].getRevision(), getFileUrl(foldercopy), SVNRevision.HEAD, folder, false, false);
    assertTrue(file.exists());
    assertFalse(file1.exists());
    assertFalse(folder1.exists());
    
    assertNotifiedFiles(new File[] {file, folder1});
}
 
Example 9
Source File: MergeTestHidden.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testMergeFolderFrom2Urls() throws Exception {                                        
    File folder = createFolder("folder");
    add(folder);
    commit(folder);
    assertInfo(folder, getFileUrl(folder));
    
    File foldercopy1 = new File(getWC(), "foldercopy1");
    
    ISVNClientAdapter c = getNbClient();
    c.copy(getFileUrl(folder), getFileUrl(foldercopy1), "copy", SVNRevision.HEAD);
    c.switchToUrl(folder, getFileUrl(foldercopy1), SVNRevision.HEAD, true);

    assertCopy(getFileUrl(foldercopy1));
    assertInfo(folder, getFileUrl(foldercopy1));
    
    File file1 = createFile(folder, "file1");
    add(file1);
    commit(folder);
    assertTrue(file1.exists());

    File foldercopy2 = new File(getWC(), "foldercopy2");
    
    c = getNbClient();
    c.copy(getFileUrl(foldercopy1), getFileUrl(foldercopy2), "copy", SVNRevision.HEAD);
    c.switchToUrl(folder, getFileUrl(foldercopy2), SVNRevision.HEAD, true);

    assertCopy(getFileUrl(foldercopy2));
    assertInfo(folder, getFileUrl(foldercopy2));
    
    File file2 = createFile(folder, "file2");
    add(file2);
    commit(folder);
    assertTrue(file2.exists());
    
    c.switchToUrl(folder, getFileUrl(folder), SVNRevision.HEAD, true);
    assertCopy(getFileUrl(folder));
    assertInfo(folder, getFileUrl(folder));                
    assertFalse(file1.exists());
    assertFalse(file2.exists());
    
    ISVNLogMessage[] log = getCompleteLog(getFileUrl(foldercopy1));
    c.merge(getFileUrl(foldercopy1), log[0].getRevision(), getFileUrl(foldercopy2), SVNRevision.HEAD, folder, true, true);
    assertTrue(file1.exists());
    assertTrue(file2.exists());
    assertNotifiedFiles(new File[] {file1, file2});        
}