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

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus() . 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: StatusTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void statusWrong(StatusCall call) throws Exception {
    // XXX add ref client
    // does not exist
    File file = new File(getWC(), "file") ;

    ISVNClientAdapter c = getNbClient();
    SVNClientException ex = null;        
    try {
        switch (call) {
            case file:                    
                c.getStatus(new File[]{ file });                    
                break;                
            case filearray:                    
                c.getStatus(file, true, true, true, true);                    
                break;
        }
    } catch (SVNClientException e) {
        ex = e;
    }
    assertNull(ex);
}
 
Example 2
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 3
Source File: GetStatusCommand.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void run(IProgressMonitor monitor) throws SVNException {
    ISVNClientAdapter svnClient = repository.getSVNClient();
    try { 
        svnStatuses = svnClient.getStatus(resource.getLocation().toFile(), descend, getAll);
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    }
    finally {
    	repository.returnSVNClient(svnClient);
    }
}
 
Example 4
Source File: RecursiveStatusUpdateStrategy.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected ISVNStatus[] statusesToUpdate(IResource resource) throws SVNException {
       if (!(resource instanceof IProject)) {
           // if the status of the resource parent is not known, we
           // recursively update it instead 
           IContainer parent = resource.getParent();
           if (parent != null) {
               if (statusCache.getStatus(parent) == null) {
                   return statusesToUpdate(parent);
               }
           }
       }
       
       if (Policy.DEBUG_STATUS) {
           System.out.println("[svn] getting status for : " + resource.getFullPath()); //$NON-NLS-1$   
       }
       
       // don't do getRepository().getSVNClient() as we can ask the status of a file
       // that is not associated with a known repository
       // we don't need login & password so this is not a problem
       ISVNStatus[] statuses = null;
       ISVNClientAdapter svnClientAdapterStatus = null;
       try {
           SVNProviderPlugin.disableConsoleLogging(); 
           svnClientAdapterStatus = SVNProviderPlugin.getPlugin().getSVNClient();
           statuses = svnClientAdapterStatus.getStatus(resource.getLocation().toFile(),true, true);
       } catch (SVNClientException e1) {
       	if (!e1.getMessage().contains(SVNProviderPlugin.UPGRADE_NEEDED)) {
       		throw SVNException.wrapException(e1);
       	}
       } finally {
           SVNProviderPlugin.enableConsoleLogging();
           SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClientAdapterStatus);
       }

       return collectUnversionedFolders(statuses, true);
}
 
Example 5
Source File: NonRecursiveStatusUpdateStrategy.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected ISVNStatus[] statusesToUpdate(IResource resource) throws SVNException {
       // we update the parent and its immediate children 
       IResource resourceToUpdate = resource;
       if ((resource.getType() == IResource.FILE)) {
           resourceToUpdate = resource.getParent();
       }
       
       if (Policy.DEBUG_STATUS) {
           System.out.println("[svn] getting status for : " + resourceToUpdate.getFullPath()); //$NON-NLS-1$   
       }
       
       // don't do getRepository().getSVNClient() as we can ask the status of a file
       // that is not associated with a known repository
       // we don't need login & password so this is not a problem
       ISVNStatus[] statuses = null;
       ISVNClientAdapter svnClientAdapterStatus = null;
       try {
           svnClientAdapterStatus = SVNProviderPlugin.getPlugin().getSVNClient();
           SVNProviderPlugin.disableConsoleLogging(); 
           statuses = svnClientAdapterStatus.getStatus(
                   resourceToUpdate.getLocation().toFile(),
                   false, // do only immediate children. 
                   true); // retrieve all entries
       } catch (SVNClientException e1) {
           throw SVNException.wrapException(e1);
       } finally {
           SVNProviderPlugin.enableConsoleLogging();
           SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClientAdapterStatus);
       }

       return collectUnversionedFolders(statuses, false);
}
 
Example 6
Source File: SVNBasedArtifactRepository.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public boolean commit(int tenantId, String filePath) throws DeploymentSynchronizerException {
    if (log.isDebugEnabled()) {
        log.debug("SVN committing " + filePath);
    }
    TenantSVNRepositoryContext repoContext= tenantSVNRepositories.get(tenantId);
    if (repoContext == null ) {
        log.warn("TenantSVNRepositoryContext not initialized for " + tenantId);
        return false;
    }

    ISVNClientAdapter svnClient = repoContext.getSvnClient();

    File root = new File(filePath);
    try {
        svnClient.cleanup(root);
        // need to check svn status before executing other operations on commit logic otherwise unnecessary
        // getStatus() will get called
        ISVNStatus[] checkStatus = svnClient.getStatus(root, true, false);
        if (checkStatus != null && checkStatus.length > 0) {
            svnAddFiles(tenantId, root, checkStatus);
            cleanupDeletedFiles(tenantId, root, checkStatus);

            ISVNStatus[] status = svnClient.getStatus(root, true, false);
            if (status != null && status.length > 0 && !isAllUnversioned(status)) {


                boolean var12 = true;

                for (ISVNStatus statu : status) {
                    if (statu.getTextStatus() != SVNStatusKind.IGNORED) {
                        var12 = false;
                    }
                }

                if (var12) {
                    return false;
                }


                File[] files = new File[]{root};
                svnClient.commit(files, "Commit initiated by deployment synchronizer", true);

                //Always do a svn update if you do a commit. This is just to update the working copy's
                //revision number to the latest. This fixes out-of-date working copy issues.
                if (log.isDebugEnabled()) {
                    log.debug("Updating the working copy after the commit.");
                }
                checkout(tenantId, filePath);

                return true;
            } else {
                log.debug("No changes in the local working copy");
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("No changes in the local working copy to  commit " + filePath);
            }
        }
    } catch (SVNClientException e) {
        String message = e.getMessage();
        String pattern = System.getProperty("line.separator");
        message = message.replaceAll(pattern, " ");

        boolean isOutOfDate = message.matches(".*svn: Commit failed.* is out of date");

        if (isOutOfDate) {
            log.warn("Working copy is out of date. Forcing a svn update. Tenant: " + tenantId, e);
            boolean updated = checkout(tenantId, filePath);
            if (!updated) {
                log.error("Failed to update the working copy even though the previous commit failed due to " +
                        "out of date content.");
            }
        } else {
            handleException("Error while committing artifacts to the SVN repository", e);
        }
    }
    return false;
}