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

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNClientAdapter#addFile() . 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: TestKit.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void svnimport(File repoDir, File wc) throws SVNClientException, MalformedURLException {
    ISVNClientAdapter client = getClient();
    String url = TestUtilities.formatFileURL(repoDir);
    SVNUrl repoUrl = new SVNUrl(url);
    client.mkdir(repoUrl.appendPath(wc.getName()), "msg");        
    client.checkout(repoUrl.appendPath(wc.getName()), wc, SVNRevision.HEAD, true);        
    File[] files = wc.listFiles();
    if(files != null) {
        for (File file : files) {
            if(!isMetadata(file)) {
                client.addFile(file);
            }                
        }
        client.commit(new File[] {wc}, "commit", true);                    
    }
    Subversion.getInstance().versionedFilesChanged();
}
 
Example 2
Source File: AbstractSvnTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void svnimportWC() throws SVNClientException {
    ISVNClientAdapter client = getFullWorkingClient();
    SVNUrl url = getTestUrl().appendPath(wc.getName());
    try {
        client.mkdir(url, true, "msg");
    } catch (SVNClientException ex) {
    }
    client.checkout(url, wc, SVNRevision.HEAD, true);        
    File[] files = wc.listFiles();
    if(files != null) {
        for (File file : files) {
            if(!isMetadata(file)) {
                client.addFile(file);
            }
        }
        client.commit(new File[] {wc}, "commit", true);                    
    }        
}
 
Example 3
Source File: AbstractSvnTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void importFile(File folder) throws SVNClientException {
    ISVNClientAdapter client = getFullWorkingClient();
    SVNUrl url = getTestUrl().appendPath(folder.getName());        
    client.mkdir(url, true, "msg");
    client.checkout(url, folder, SVNRevision.HEAD, true);        
    File[] files = folder.listFiles();
    if(files != null) {
        for (File file : files) {
            if(!isMetadata(file)) {
                if (file.isDirectory()) {
                    client.addDirectory(file, true);
                } else {
                    client.addFile(file);
                }
            }
        }
        client.commit(new File[] {folder}, "commit", true);                    
    }        
}
 
Example 4
Source File: PropertyTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testKWPropertySet () throws Exception {                                                
    File folder = createFolder("folder");        
    File file1 = createFile(folder, "file1");        
    
    add(folder);
    add(file1);
    commit(getWC());
 
    ISVNClientAdapter c = getNbClient();        
    c.propertySet(file1, "svn:keywords", "Id", false);
    assertNotifiedFiles(file1);
    
    assertPropertyStatus(SVNStatusKind.MODIFIED, file1);
    
    // add property for new file
    File file2 = createFile(folder, "file2");
    assertStatus(SVNStatusKind.UNVERSIONED, file2);
    c.addFile(file2);
    assertStatus(SVNStatusKind.ADDED, file2);
    
    c.propertySet(file2, "svn:keywords", "Id", false);
    assertNotifiedFiles(file2);
    
    assertPropertyStatus(SVNStatusKind.MODIFIED, file2);
    
}
 
Example 5
Source File: PropertyTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testKWAutoPropSet () throws Exception {                                                
    File folder = createFolder("folder");        
    
    add(folder);
    commit(getWC());

    write(new File(SvnConfigFiles.getNBConfigPath(), "config"), "[miscellany]\n"
            + "enable-auto-props = yes\n"
            + "[auto-props]\n"
            + "*.java = svn:keywords=Id\n"
            + "");
    
    ISVNClientAdapter c = getNbClient();        
    File file1 = createFile(folder, "file1.java");
    assertStatus(SVNStatusKind.UNVERSIONED, file1);
    c.addFile(file1);
    assertStatus(SVNStatusKind.ADDED, file1);
    
    c.commit(new File[] { file1 }, "message", true);
}
 
Example 6
Source File: AddTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testAddNoFile() throws Exception {
    File file = new File(getWC(), "fail");

    assertStatus(SVNStatusKind.NONE, file);

    ISVNClientAdapter c = getNbClient();

    SVNClientException e = null;
    try {
        c.addFile(file);
    } catch (SVNClientException ex) {
        e = ex;
    }
    if (isJavahl()) {
        assertNotNull(e);
        assertTrue(e.getMessage().indexOf("is not a working copy") > -1
                || e.getMessage().indexOf("not found") > -1);
    }

    assertNotifiedFiles(new File[]{});
}
 
Example 7
Source File: AddTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testAddNotExistingFile() throws Exception {
    File folder = createFolder("folder");
    File file = new File(folder, "fail");

    assertStatus(SVNStatusKind.UNVERSIONED, file);
    
    ISVNClientAdapter c = getNbClient();
    SVNClientException e = null;        
    try {
        c.addFile(file);
    } catch (SVNClientException ex) {
        e = ex;
    }
    assertNotNull(e);
                    
    assertTrue(SvnClientExceptionHandler.isUnversionedResource(e.getMessage()) || e.getMessage().toLowerCase().contains("not found")
             || e.getMessage().toLowerCase().contains("some targets don't exist"));
    
    assertNotifiedFiles(new File[]{});  
}
 
Example 8
Source File: AbstractSvnTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void add(ISVNClientAdapter client, File file) throws SVNClientException {
    ISVNStatus status = getSVNStatus(file);        
    if(status.getTextStatus().equals(SVNStatusKind.UNVERSIONED)) {
        try {
            client.addFile(file);
        } catch (SVNClientException e) {
            if(e.getMessage().indexOf("is not a working copy") > -1 && 
               containsParent(e.getMessage(), file.getParentFile())) 
            {
                // ignore
            } else {
                throw e;
            }
        }
    }
    if(file.isFile() || status.getTextStatus().equals(SVNStatusKind.IGNORED)) {
        return; 
    }
    File[] files = file.listFiles();
    if(files != null) {
        for (File f : files) {
            if(!isMetadata(f)) {
                add(f);
            }
        }            
    }
}
 
Example 9
Source File: AddTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void testAddFile(String path) throws Exception {
    createAndAddParentFolders(path);
    File file = createFile(path);
    assertStatus(SVNStatusKind.UNVERSIONED, file);

    ISVNClientAdapter c = getNbClient();
    c.addFile(file);

    assertStatus(SVNStatusKind.ADDED, file);
    assertNotifiedFiles(file);
}
 
Example 10
Source File: DifferentWorkingDirsTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testDifferentWorkingDirs3() throws Exception {        
    File folder = createFolder("folder");        
    File folder1 = createFolder(folder, "folder1");        
    File folder2 = createFolder(folder, "folder2");        
    
    File wc1 = createFolder(folder1, "wc1");        
    File wc2 = createFolder(folder2, "wc2");        

    cleanUpRepo(new String[] {wc1.getName()});
    cleanUpRepo(new String[] {wc2.getName()});
    importFile(wc1);
    importFile(wc2);
    
    File file1 = createFile(wc1, "file1");
    File file2 = createFile(wc2, "file2");
    
    ISVNClientAdapter c = getNbClient();
    
    for(File f : new File[] {file1, file2}) {
        c.addFile(f);
    }
    
    c.commit(new File[] {file1, file2}, "msg", false);        
    
    assertStatus(SVNStatusKind.NORMAL, file1);
    assertStatus(SVNStatusKind.NORMAL, file2);
    
    assertNotifiedFiles(new File[] {file1, file2});
}
 
Example 11
Source File: AddTestHidden.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testAddAddedFile() throws Exception {
    File file = createFile("file");

    assertStatus(SVNStatusKind.UNVERSIONED, file);

    ISVNClientAdapter c = getNbClient();

    c.addFile(file);

    assertStatus(SVNStatusKind.ADDED, file);

    try {
        c.addFile(file);
        fail("should fail");
    } catch (SVNClientException ex) {
        
    }
    assertStatus(SVNStatusKind.ADDED, file);

    assertNotifiedFiles(file);
}