Java Code Examples for org.tigris.subversion.svnclientadapter.ISVNStatus#getTextStatus()

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNStatus#getTextStatus() . 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: CommandlineClient.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void notifyChangedStatus(File file, boolean rec, ISVNStatus[] oldStatuses) throws SVNClientException {
    Map<File, ISVNStatus> oldStatusMap = new HashMap<File, ISVNStatus>();
    for (ISVNStatus s : oldStatuses) {
        oldStatusMap.put(s.getFile(), s);
    }
    ISVNStatus[] newStatuses = getStatus(file, rec, true);
    for (ISVNStatus newStatus : newStatuses) {
        ISVNStatus oldStatus = oldStatusMap.get(newStatus.getFile());
        if( (oldStatus == null && newStatus != null) ||
             oldStatus.getTextStatus() != newStatus.getTextStatus() ||
             oldStatus.getPropStatus() != newStatus.getPropStatus())
        {
            notificationHandler.notifyListenersOfChange(newStatus.getPath()); /// onNotify(cmd.getAbsoluteFile(s.getFile().getAbsolutePath()), null);
        }
   }
}
 
Example 2
Source File: StatusUpdateStrategy.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Collect the content of unversioned folders.
 * @param statuses
 * @param recursive
 * @return
 */
protected ISVNStatus[] collectUnversionedFolders(ISVNStatus[] statuses, boolean recursive) {
	if (statuses == null) {
		return null;
	}
    List<ISVNStatus> processed = new ArrayList<ISVNStatus>();
    for (ISVNStatus status : statuses) {
    	processed.add(status);
    	if (status.getNodeKind() != SVNNodeKind.FILE && status.getTextStatus() == SVNStatusKind.UNVERSIONED) {
    		File folder = status.getFile();
    		if (!folder.isDirectory() && !folder.exists())
    			continue;
  			Set<String> alreadyProcessed = new HashSet<String>();
			processUnversionedFolder(folder, processed, recursive, alreadyProcessed);
    	}
    }

    return processed.toArray(new ISVNStatus[processed.size()]);
}
 
Example 3
Source File: SvnClientJavaHl.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
private static String getConflictPath(ISVNStatus status) {
	if (status.hasTreeConflict()) {
		return status.getConflictDescriptor().getPath();
	} else if (status.getConflictWorking() != null) {
		return status.getConflictWorking().toString();
	} else if (status.getTextStatus() == SVNStatusKind.CONFLICTED) {
		return status.getFile().toString();
	} else {
		return null;
	}
}
 
Example 4
Source File: SvnClientJavaHl.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * Checks the given {@link ISVNStatus} if modifications exist.
 * 
 * @param status the {@link ISVNStatus}
 * @return {@code true} if modifications exist
 */
private static boolean isModified(ISVNStatus status) {
	final SVNStatusKind textStatus = status.getTextStatus();
	if (textStatus == SVNStatusKind.ADDED || textStatus == SVNStatusKind.CONFLICTED
			|| textStatus == SVNStatusKind.DELETED || textStatus == SVNStatusKind.MERGED
			|| textStatus == SVNStatusKind.MODIFIED || textStatus == SVNStatusKind.REPLACED) {
		return true;
	} else {
		final SVNStatusKind propStatus = status.getPropStatus();
		return propStatus == SVNStatusKind.ADDED || propStatus == SVNStatusKind.CONFLICTED
				|| propStatus == SVNStatusKind.DELETED || propStatus == SVNStatusKind.MERGED
				|| propStatus == SVNStatusKind.MODIFIED || propStatus == SVNStatusKind.REPLACED;
	}
}
 
Example 5
Source File: StatusCacheManager.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * update the cache using the given statuses
 * @param status
 * @param workspaceRoot
 */
public IResource updateCache(IResource resource, ISVNStatus status) {
	if (resource != null && status != null && status.getTextStatus() != null && !resource.exists() && status.getTextStatus().equals(SVNStatusKind.MISSING) && (status.getLastChangedRevision() == null || status.getLastChangedRevision().getNumber() == -1)) {
		statusCache.removeStatus(resource);
		return resource;
	}
	return statusCache.addStatus(resource, new LocalResourceStatus(status, getURL(status), checkForReadOnly));
}
 
Example 6
Source File: StatusAndInfoCommand.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private RemoteResourceStatus[] collectRemoteStatuses(ISVNStatus[] statuses, ISVNClientAdapter client, final IProgressMonitor monitor)
 {
 	monitor.beginTask("", statuses.length);
 	try {
 	RemoteResourceStatus[] result = new RemoteResourceStatus[statuses.length];

     Arrays.sort(statuses, new Comparator() {
public int compare(Object o1, Object o2) {
	return ((ISVNStatus) o1).getPath().compareTo(((ISVNStatus) o2).getPath());
}            	
     });

     for (int i = 0; i < statuses.length; i++) {
     	ISVNStatus status = statuses[i];
     	SVNStatusKind localTextStatus = status.getTextStatus();

     	if (SVNStatusKind.UNVERSIONED.equals(localTextStatus)
     			|| SVNStatusKind.ADDED.equals(localTextStatus)
     			|| SVNStatusKind.IGNORED.equals(localTextStatus)
     		)
     	{
     		if (SVNStatusKind.NONE.equals(status.getRepositoryTextStatus()))
     			result[i] = RemoteResourceStatus.NONE;
     		else
         		result[i] = new RemoteResourceStatus(statuses[i], getRevisionFor(statuses[i]));
     	}
     	else
     	{
     		result[i] = new RemoteResourceStatus(statuses[i], getRevisionFor(statuses[i]));
     	}
     	monitor.worked(1);
     }	
     
     return result;
 	} finally {
 		monitor.done();
 	}
 }
 
Example 7
Source File: FileStatusCache.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Examines a file or folder that has an associated CVS entry. 
 * 
 * @param file file/folder to examine
 * @param status status of the file/folder as reported by the CVS server 
 * @return FileInformation file/folder status bean
 */ 
private FileInformation createVersionedFileInformation(File file, ISVNStatus status, RepositoryStatus repositoryStatus) {

    SVNStatusKind kind = status.getTextStatus();
    SVNStatusKind pkind = status.getPropStatus();

    int remoteStatus = 0;
    if (repositoryStatus != REPOSITORY_STATUS_UNKNOWN) {
        if (repositoryStatus.getStatus().getRepositoryTextStatus() == SVNStatusKind.MODIFIED
        || repositoryStatus.getStatus().getRepositoryPropStatus() == SVNStatusKind.MODIFIED) {
            remoteStatus = FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY;
        } else if (repositoryStatus.getStatus().getRepositoryTextStatus() == SVNStatusKind.DELETED
        /*|| repositoryStatus.getRepositoryPropStatus() == SVNStatusKind.DELETED*/) {
            remoteStatus = FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY;
        } else if (repositoryStatus.getStatus().getRepositoryTextStatus() == SVNStatusKind.ADDED
                    || repositoryStatus.getStatus().getRepositoryTextStatus() == SVNStatusKind.REPLACED) {
            // solved in createMissingfileInformation
        } else if ( (repositoryStatus.getStatus().getRepositoryTextStatus() == null &&
                     repositoryStatus.getStatus().getRepositoryPropStatus() == null)
                    ||
                    (repositoryStatus.getStatus().getRepositoryTextStatus() == SVNStatusKind.NONE &&
                     repositoryStatus.getStatus().getRepositoryPropStatus() == SVNStatusKind.NONE))
        {
            // no remote change at all
        } else {
            // so far above were observed....
            Subversion.LOG.log(Level.WARNING,"SVN.FSC: unhandled repository status: {0}" + "\n" +   // NOI18N
                                   "\ttext: " + "{1}" + "\n" +             // NOI18N
                                   "\tprop: " + "{2}", new Object[] { file.getAbsolutePath(), repositoryStatus.getStatus().getRepositoryTextStatus(), //NOI18N
                                       repositoryStatus.getStatus().getRepositoryPropStatus() });
        }
        if (repositoryStatus.getLock() != null) {
            remoteStatus |= FileInformation.STATUS_LOCKED_REMOTELY;
        }
    }
    
    if (status. getLockOwner() != null) {
        remoteStatus = FileInformation.STATUS_LOCKED | remoteStatus;
    }
    
    int propertyStatus = 0;
    if (SVNStatusKind.NONE.equals(pkind)) {
        // no influence
    } else if (SVNStatusKind.NORMAL.equals(pkind)) {
        // no influence
    } else if (SVNStatusKind.MODIFIED.equals(pkind)) {
        propertyStatus = FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY_PROPERTY;
    } else if (SVNStatusKind.CONFLICTED.equals(pkind)) {
        return new FileInformation(FileInformation.STATUS_VERSIONED_CONFLICT_CONTENT | remoteStatus, status);
    } else {
        throw new IllegalArgumentException("Unknown prop status: " + status.getPropStatus()); // NOI18N
    }

    int additionalStatus = remoteStatus | propertyStatus;
    if (status.hasTreeConflict()) {
        return new FileInformation(FileInformation.STATUS_VERSIONED_CONFLICT_TREE | additionalStatus, status);
    } else if (SVNStatusKind.NONE.equals(kind)) {
        return FILE_INFORMATION_UNKNOWN;
    } else if (SVNStatusKind.NORMAL.equals(kind)) {
        int finalStatus = FileInformation.STATUS_VERSIONED_UPTODATE | remoteStatus;
        if (propertyStatus != 0) {
            finalStatus = additionalStatus;
        }
        return new FileInformation(finalStatus, status);
    } else if (SVNStatusKind.MODIFIED.equals(kind)) {
        return new FileInformation(FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY_CONTENT | additionalStatus, status);
    } else if (SVNStatusKind.ADDED.equals(kind)) {
        return new FileInformation(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY | additionalStatus, status);
    } else if (SVNStatusKind.DELETED.equals(kind)) {                    
        return new FileInformation(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY | additionalStatus, status);
    } else if (SVNStatusKind.UNVERSIONED.equals(kind)) {            
        return new FileInformation(FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY | additionalStatus, status);
    } else if (SVNStatusKind.MISSING.equals(kind)) {            
        return new FileInformation(FileInformation.STATUS_VERSIONED_DELETEDLOCALLY | additionalStatus, status);
    } else if (SVNStatusKind.REPLACED.equals(kind)) {                      
        // this status or better to use this simplyfication?
        return new FileInformation(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY | additionalStatus, status);
    } else if (SVNStatusKind.MERGED.equals(kind)) {            
        return new FileInformation(FileInformation.STATUS_VERSIONED_MERGE | additionalStatus, status);
    } else if (SVNStatusKind.CONFLICTED.equals(kind)) {            
        return new FileInformation(FileInformation.STATUS_VERSIONED_CONFLICT_CONTENT | additionalStatus, status);
    } else if (SVNStatusKind.OBSTRUCTED.equals(kind)) {            
        return new FileInformation(FileInformation.STATUS_VERSIONED_CONFLICT_CONTENT | additionalStatus, status);
    } else if (SVNStatusKind.IGNORED.equals(kind)) {            
        return new FileInformation(FileInformation.STATUS_NOTVERSIONED_EXCLUDED | remoteStatus, status);
    } else if (SVNStatusKind.INCOMPLETE.equals(kind)) {            
        return new FileInformation(FileInformation.STATUS_VERSIONED_CONFLICT_CONTENT | additionalStatus, status);
    } else if (SVNStatusKind.EXTERNAL.equals(kind)) {            
        return new FileInformation(FileInformation.STATUS_VERSIONED_UPTODATE | remoteStatus, status);
    } else {        
        throw new IllegalArgumentException("Unknown text status: " + status.getTextStatus()); // NOI18N
    }
}
 
Example 8
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;
}
 
Example 9
Source File: SVNStatusUtils.java    From APICloud-Studio with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns if the resource has a remote counter-part
 * @param status
 * 
 * @return has version in repository
 */
public static boolean hasRemote(ISVNStatus status) {
	SVNStatusKind textStatus = status.getTextStatus();
    return ((isManaged(textStatus)) && (!textStatus.equals(SVNStatusKind.ADDED) || status.isCopied()));
}