org.tigris.subversion.svnclientadapter.ISVNStatus Java Examples

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNStatus. 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: SvnProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void addFile(SvnClient client, File file, boolean recursively) throws SVNClientException {
    if(SvnUtils.isPartOfSubversionMetadata(file)) return;
    ISVNStatus status = SvnUtils.getSingleStatus(client, file);
    if(status.getTextStatus().equals(SVNStatusKind.UNVERSIONED)) {
        boolean isDir = file.isDirectory();
        if (isDir) {
            client.addDirectory(file, false);
        } else {
            client.addFile(file);
        }
        if(recursively && isDir) {
            File[] files = file.listFiles();
            if(files == null) return;
            for (File f : files) {
                addFile(client, f, recursively);
            }
        }
    }
}
 
Example #2
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusFileCopied1NewFormat() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/new-format-file-copied1/testapp/AnotherAnotherMain.java");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertTrue(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/AnotherAnotherMain.java", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.ADDED, parsedStatus.getTextStatus());
    assertEquals(18, parsedStatus.getRevision().getNumber());        
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    assertNull(parsedStatus.getLastChangedDate());
    assertEquals(-1, parsedStatus.getLastChangedRevision().getNumber());
    assertNull(parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.NONE, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #3
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusFileRemovedNewFormat() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/new-format-file-removed/testapp/ReadMe.txt");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/ReadMe.txt", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.DELETED, parsedStatus.getTextStatus());
    assertEquals(18, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2006-08-16T05:15:12.039161Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(18, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("ed", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.NONE, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #4
Source File: SVNBasedArtifactRepository.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public List<String> processUnversionedWebappActions(ISVNStatus[] status) {
    List<String> addToSvn = new ArrayList<String>();
    for (ISVNStatus st : status) {
        String path = st.getPath();
        if (path != null && isWebApp(path)) {
            int lastIdx = path.lastIndexOf(File.separator);
            String simpleName = lastIdx > 0 ? path.substring(lastIdx + 1) : null;
            if (simpleName != null) {
                if (!simpleName.endsWith(".war")) {
                    // This is a directory ensure there is no .war exists before adding to SVN
                    File appBase = new File(path.concat(".war"));
                    if (!appBase.exists()) {
                        addToSvn.add(simpleName);
                    }

                }
            }
        }
    }
    return addToSvn;
}
 
Example #5
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public InputStream getContent(File path, SVNRevision revision)
		throws SVNClientException {
	try {
		String target = fileToSVNPath(path, false);
		notificationHandler.setCommand(ISVNNotifyListener.Command.CAT);
		notificationHandler.logCommandLine("cat -r " + revision.toString()
				+ " " + target);
		notificationHandler.setBaseDir();

		if (revision.equals(SVNRevision.BASE)) {
			// This is to work-around a JavaHL problem when trying to
			// retrieve the base revision of a newly added file.
			ISVNStatus status = getSingleStatus(path);
			if (status.getTextStatus().equals(SVNStatusKind.ADDED))
				return new ByteArrayInputStream(new byte[0]);
		}
		byte[] contents = svnClient.fileContent(target,
				JhlConverter.convert(revision), Revision.BASE);
		InputStream input = new ByteArrayInputStream(contents);
		return input;
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #6
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusPropertyAdded() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/prop-added/testapp/AnotherMain.java");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/AnotherMain.java", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getTextStatus());
    assertEquals(8, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2006-04-25T06:55:09.997277Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(8, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("ed", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.MODIFIED, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #7
Source File: SvnWcParser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private List<ISVNStatus> getStatus(File path, boolean descend) throws LocalSubversionException {
    List<ISVNStatus> ret = new ArrayList<ISVNStatus>(20);                        
    ret.add(getSingleStatus(path));
    
    File[] children = getChildren(path);
    if(children != null) {
        for (int i = 0; i < children.length; i++) {
            if(!SvnUtils.isPartOfSubversionMetadata(children[i]) && !SvnUtils.isAdministrative(path)) {                                       
                if(descend && children[i].isDirectory()) {                
                    ret.addAll(getStatus(children[i], descend));                
                } else {
                    ret.add(getSingleStatus(children[i]));  // 
                }                   
            }
        }        
    }        
    return ret;
}
 
Example #8
Source File: ResolveConflictsAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static Map<File, ISVNStatus> getTreeConflicts (File[] files) {
    Map<File, ISVNStatus> treeConflicts = new HashMap<File, ISVNStatus>(files.length);
    if (files.length > 0) {
        try {
            SvnClient client = Subversion.getInstance().getClient(false);
            FileStatusCache cache = Subversion.getInstance().getStatusCache();
            for (File file : files) {
                if ((cache.getStatus(file).getStatus() & FileInformation.STATUS_VERSIONED_CONFLICT_TREE) != 0) {
                    ISVNStatus status = SvnUtils.getSingleStatus(client, file);
                    if (status.hasTreeConflict()) {
                        treeConflicts.put(file, status);
                    }
                }
            }
        } catch (SVNClientException ex) {
            Subversion.LOG.log(Level.INFO, null, ex);
        }
    }
    return treeConflicts;
}
 
Example #9
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusPropertyModified() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/prop-modified/testapp/AnotherMain.java");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/AnotherMain.java", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getTextStatus());
    assertEquals(9, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2006-04-25T07:01:25.704780Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(9, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("ed", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.MODIFIED, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #10
Source File: SVNLocalCompareInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void getUnadded(ISVNClientAdapter client, ISVNLocalResource resource, File file) throws SVNClientException, SVNException {
	ISVNStatus[] statuses = client.getStatus(file, true, true);
	for (ISVNStatus status : statuses) {
		IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource.getResource(), status);
		if (currentResource != null) {
			ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(currentResource);
			if (!localResource.isIgnored()) {
				if (!SVNStatusUtils.isManaged(status)) {
					if (!isSymLink(currentResource)) {
	                 	if (currentResource.getType() != IResource.FILE) {
	                 		unversionedFolders.add(currentResource);
						} else {
	             			if (addToUnadded(currentResource)) unaddedList.add(currentResource);
						}
					}
				}
			}
		}
	}
	IResource[] unaddedResources = getUnaddedResources(unversionedFolders);
	for (IResource unaddedResource : unaddedResources) {
		unaddedList.add(unaddedResource);
	}
}
 
Example #11
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusFileLockedWithCommentNewFormat() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/new-format-file-locked-with-comment/testapp/AnotherMain.java");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/AnotherMain.java", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getTextStatus());
    assertEquals(19, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2006-04-25T07:05:57.738276Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(10, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("ed", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getPropStatus());
    assertEquals("This is my comment", parsedStatus.getLockComment());
    assertEquals("ed", parsedStatus.getLockOwner());
    expectedDate = SvnWcUtils.parseSvnDate("2006-08-29T10:36:02.498983Z");
    assertEquals(expectedDate, parsedStatus.getLockCreationDate());
}
 
Example #12
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusNoChangesKeywords() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/no-changes-keywords/testapp/Main.java");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("file:///data/subversion/trunk/testapp/Main.java", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getTextStatus());
    assertEquals(989, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2007-06-13T12:02:16.625421Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(330, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("tomas", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #13
Source File: ApiTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testCommit() throws SVNClientException, IOException {
    File folder = new File(workDir, "testCommitFolder");
    folder.mkdirs();
    TestKit.svnimport(repoDir, folder);

    ISVNStatus s = TestKit.getSVNStatus(folder);
    assertEquals(SVNStatusKind.NORMAL, s.getTextStatus());

    File file = new File(folder, "file");
    file.createNewFile();
    TestKit.add(file);
    s = TestKit.getSVNStatus(file);
    assertEquals(SVNStatusKind.ADDED, s.getTextStatus());

    Subversion.getInstance().versionedFilesChanged();
    SvnUtils.refreshParents(folder);
    Subversion.getInstance().getStatusCache().refreshRecursively(folder);

    org.netbeans.modules.subversion.api.Subversion.commit(new File[] {folder}, "", "", "msg");
    s = TestKit.getSVNStatus(file);
    assertEquals(SVNStatusKind.NORMAL, s.getTextStatus());

}
 
Example #14
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusPropertyAddedNewFormat() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/new-format-prop-added/testapp/AnotherMain.java");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/AnotherMain.java", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getTextStatus());
    assertEquals(19, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2006-04-25T07:05:57.738276Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(10, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("ed", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.MODIFIED, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #15
Source File: ResolveConflictsAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static Map<File, ISVNStatus> getPropertyConflicts (File[] files) {
    Map<File, ISVNStatus> propertyConflicts = new HashMap<File, ISVNStatus>(files.length);
    if (files.length > 0) {
        try {
            SvnClient client = Subversion.getInstance().getClient(false);
            FileStatusCache cache = Subversion.getInstance().getStatusCache();
            for (File file : files) {
                if ((cache.getStatus(file).getStatus() & FileInformation.STATUS_VERSIONED_CONFLICT_CONTENT) != 0) {
                    ISVNStatus status = SvnUtils.getSingleStatus(client, file);
                    if (status.getPropStatus() == SVNStatusKind.CONFLICTED) {
                        propertyConflicts.put(file, status);
                    }
                }
            }
        } catch (SVNClientException ex) {
            Subversion.LOG.log(Level.INFO, null, ex);
        }
    }
    return propertyConflicts;
}
 
Example #16
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusFileConflict() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/file-conflicts/testapp/ReadMe.txt");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/ReadMe.txt", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.CONFLICTED, parsedStatus.getTextStatus());
    assertEquals(5, parsedStatus.getRevision().getNumber());
    assertEquals(5, parsedStatus.getLastChangedRevision().getNumber());
    assertNotNull(parsedStatus.getConflictNew());
    assertNotNull(parsedStatus.getConflictOld());
    assertNotNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2006-04-25T04:12:27.726955Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(5, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("ed", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #17
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusFileAddedNewFormat() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/new-format-file-added/testapp/ReadMe.txt");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/ReadMe.txt", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.ADDED, parsedStatus.getTextStatus());
    assertEquals(0, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    assertNull(parsedStatus.getLastChangedDate());
    assertEquals(-1, parsedStatus.getLastChangedRevision().getNumber());
    assertNull(parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.NONE, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #18
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Tests a specific case... where the file doesn't exist, and there is no entry in the SVN
 * files, but it's still being queried by the module.  Return unversioned.  Working copy is
 * the format as of SVN 1.4.0
 */
public void testGetSingleStatusFileUnknownAnywhereNewFormat() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/new-format-no-changes/testapp/readme.txt");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/readme.txt", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.UNVERSIONED, parsedStatus.getTextStatus());
    assertEquals(0, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    assertNull(parsedStatus.getLastChangedDate());
    assertEquals(0, parsedStatus.getLastChangedRevision().getNumber());
    assertNull(parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.UNKNOWN, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.UNVERSIONED, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #19
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Tests a specific case... where the file doesn't exist, and there is no entry in the SVN
 * files, but it's still being queried by the module.  Return unversioned
 */
public void testGetSingleStatusFileUnknownAnywhere() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/no-changes/testapp/ReadMe.txt");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/ReadMe.txt", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.UNVERSIONED, parsedStatus.getTextStatus());
    assertEquals(0, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    assertNull(parsedStatus.getLastChangedDate());
    assertEquals(0, parsedStatus.getLastChangedRevision().getNumber());
    assertNull(parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.UNKNOWN, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.UNVERSIONED, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #20
Source File: FileStatusCache.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void patchRevision(File[] fileArray, Number revision) {        
    for (File file : fileArray) {            
        synchronized(this) {        
            FileInformation status = getCachedStatus(file);
            ISVNStatus entry = status != null ? status.getEntry(file) : null;
            if(entry != null) {
                Number rev = entry.getRevision();
                if(rev == null) continue;
                if(rev.getNumber() != revision.getNumber()) {
                    FileInformation info = createFileInformation(file, new FakeRevisionStatus(entry, revision), REPOSITORY_STATUS_UNKNOWN);
                    File dir = file.getParentFile();
                    Map<File, FileInformation> files = getScannedFiles(dir);
                    Map<File, FileInformation> newFiles = new HashMap<File, FileInformation>(files);
                    newFiles.put(file, info);
                    turbo.writeEntry(dir, FILE_STATUS_MAP, newFiles.isEmpty() ? null : newFiles);
                }
            }
        }
    }
}
 
Example #21
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusFileUnknownNewFormat() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/new-format-file-unknown/testapp/readme.txt");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/readme.txt", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.UNVERSIONED, parsedStatus.getTextStatus());
    assertEquals(0, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    assertNull(parsedStatus.getLastChangedDate());
    assertEquals(0, parsedStatus.getLastChangedRevision().getNumber());
    assertNull(parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.UNKNOWN, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.UNVERSIONED, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #22
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusFileUnknown() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/file-unknown/testapp/ReadMe.txt");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/ReadMe.txt", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.UNVERSIONED, parsedStatus.getTextStatus());
    assertEquals(0, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    assertNull(parsedStatus.getLastChangedDate());
    assertEquals(0, parsedStatus.getLastChangedRevision().getNumber());
    assertNull(parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.UNKNOWN, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.UNVERSIONED, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #23
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusFileChangesNewFormat() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/new-format-file-changes/testapp/AnotherMain.java");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/AnotherMain.java", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.MODIFIED, parsedStatus.getTextStatus());
    assertEquals(16, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2006-04-25T07:05:57.738276Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(10, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("ed", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #24
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusFileChanges() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/file-changes/testapp/Main.java");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/Main.java", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.MODIFIED, parsedStatus.getTextStatus());
    assertEquals(2, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2006-04-12T10:43:46.371180Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(2, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("ed", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #25
Source File: SvnWcParserTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetSingleStatusNoChangesNewFormat() throws Exception {
    File myFile = new File(dataRootDir + "/SvnWcParser/new-format-no-changes/testapp/Main.java");
    ISVNStatus parsedStatus = svnWcParser.getSingleStatus(myFile);
    assertFalse(parsedStatus.isCopied());
    assertEquals("svn://gonzo/testRepos/trunk/testApp/src/testapp/Main.java", parsedStatus.getUrl().toString());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getTextStatus());
    assertEquals(16, parsedStatus.getRevision().getNumber());
    assertNull(parsedStatus.getConflictNew());
    assertNull(parsedStatus.getConflictOld());
    assertNull(parsedStatus.getConflictWorking());
    assertEquals(myFile, parsedStatus.getFile());
    Date expectedDate = SvnWcUtils.parseSvnDate("2006-08-05T03:42:58.306031Z");
    assertEquals(expectedDate, parsedStatus.getLastChangedDate());
    assertEquals(16, parsedStatus.getLastChangedRevision().getNumber());
    assertEquals("ed", parsedStatus.getLastCommitAuthor());
    assertEquals(SVNNodeKind.FILE, parsedStatus.getNodeKind());
    assertEquals(myFile.getPath(), parsedStatus.getPath());
    assertEquals(SVNStatusKind.NORMAL, parsedStatus.getPropStatus());
    assertNull(parsedStatus.getLockComment());
    assertNull(parsedStatus.getLockOwner());
    assertNull(parsedStatus.getLockCreationDate());
}
 
Example #26
Source File: ResolveTreeConflictWizard.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNStatus getRemoteCopiedTo(boolean getAll) throws Exception {
	if (remoteCopiedTo == null && !remoteCopiedToRetrieved) {
		remoteCopiedToRetrieved = true;
		logMessages = getLogMessages();
		if (logMessages != null) {
			for (int i = 0; i < logMessages.length; i++) {
				ISVNLogMessageChangePath[] changePaths = logMessages[i].getChangedPaths();
				for (int j = 0; j < changePaths.length; j++) {
					if (changePaths[j].getAction() == 'A' && changePaths[j].getCopySrcPath() != null) {
						if ((svnResource.getUrl() != null && svnResource.getUrl().toString().endsWith(changePaths[j].getCopySrcPath())) || changePaths[j].getCopySrcPath().endsWith(svnResource.getIResource().getFullPath().toString())) {
							statuses = getStatuses(getAll);
							for (int k = 0; k < statuses.length; k++) {
								if (statuses[k].getUrl() != null && statuses[k].getUrl().toString().endsWith(changePaths[j].getPath())) {
									remoteCopiedTo = statuses[k];
									return remoteCopiedTo;
								}
							}
						}
					}
				}
			}
		}
	}		
	return remoteCopiedTo;
}
 
Example #27
Source File: StatusUpdateStrategy.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
void processUnversionedFolder(final File folder, final List<ISVNStatus> statuses, final boolean recursive, final Set<String> alreadyProcessed) {
	String absolutePath = folder.getAbsolutePath();
	if (alreadyProcessed.contains(absolutePath))
		return;
	
	alreadyProcessed.add(absolutePath);

	File[] files = folder.listFiles();
	if (files == null)
		return;

	for (File file : files) {
		statuses.add(new SVNStatusUnversioned(file, false));
		
		if (recursive && file.isDirectory()) {
			processUnversionedFolder(file, statuses, recursive, alreadyProcessed);
			continue;
		}
	}
}
 
Example #28
Source File: TestKit.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void add(File file) throws SVNClientException {
    ISVNStatus status = getSVNStatus(file);
    if(status.getTextStatus().equals(SVNStatusKind.UNVERSIONED)) {
        getClient().addFile(file);
    }
    if(file.isFile()) {
        return; 
    }
    File[] files = file.listFiles();
    if(files != null) {
        for (File f : files) {
            if(!isMetadata(f)) {
                add(f);
            }
        }            
    }
}
 
Example #29
Source File: ResolveActionWithChoices.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private SVNTreeConflict getTreeConflict(final IResource resource) {
	BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
		public void run() {
			ISVNClientAdapter client = null;
			try {
				client = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().getSVNClient();
				ISVNStatus[] statuses = client.getStatus(resource.getLocation().toFile(), true, true, true);
				for (int i = 0; i < statuses.length; i++) {
					if (statuses[i].hasTreeConflict()) {
						treeConflict = new SVNTreeConflict(statuses[i]);
						break;
					}
				}
			} catch (Exception e) {
				SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
			}
			finally {
				SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().returnSVNClient(client);
			}
		}			
	});
	return treeConflict;
}
 
Example #30
Source File: WorkspaceAction.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
    final List modified = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
		 IResource resource = resources[i];
		 ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
		 
		 // get adds, deletes, updates and property updates.
		 GetStatusCommand command = new GetStatusCommand(svnResource, true, false);
		 command.run(iProgressMonitor);
		 ISVNStatus[] statuses = command.getStatuses();
		 for (int j = 0; j < statuses.length; j++) {
		     if (SVNStatusUtils.isReadyForRevert(statuses[j]) ||
		   		  !SVNStatusUtils.isManaged(statuses[j])) {
		         IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
		         if (currentResource != null)
		             modified.add(currentResource);
		     }
		 }
	}
    return (IResource[]) modified.toArray(new IResource[modified.size()]);
}