Java Code Examples for org.tigris.subversion.svnclientadapter.SVNRevision#equals()

The following examples show how to use org.tigris.subversion.svnclientadapter.SVNRevision#equals() . 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: RevertModifications.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private RevisionInterval getResortedRevisionInterval(SVNRevision revision1, SVNRevision revision2) {
    RevisionInterval ret; 
    if(revision1.equals(SVNRevision.HEAD) && revision1.equals(SVNRevision.HEAD)) {
        ret = new RevisionInterval (revision1, revision2);
    } else if (revision1.equals(SVNRevision.HEAD)) {
        ret = new RevisionInterval (revision2, revision1);
    } else if (revision2.equals(SVNRevision.HEAD)) {
        ret = new RevisionInterval (revision1, revision2);                
    } else {
        Long r1 = Long.parseLong(revision1.toString());
        Long r2 = Long.parseLong(revision2.toString());
        if(r1.compareTo(r2) < 0) {
            ret = new RevisionInterval (revision1, revision2);
        } else {
            ret = new RevisionInterval (revision2, revision1);
        }
    }
    return ret;
}
 
Example 2
Source File: RevertModificationsAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static RevertModifications.RevisionInterval recountStartRevision(SvnClient client, SVNUrl repository, RevertModifications.RevisionInterval ret) throws SVNClientException {
    SVNRevision currStartRevision = ret.startRevision;
    SVNRevision currEndRevision = ret.endRevision;

    if(currStartRevision.equals(SVNRevision.HEAD)) {
        ISVNInfo info = client.getInfo(repository);
        currStartRevision = info.getRevision();
    }

    long currStartRevNum = Long.parseLong(currStartRevision.toString());
    long newStartRevNum = (currStartRevNum > 0) ? currStartRevNum - 1
                                                : currStartRevNum;

    return new RevertModifications.RevisionInterval(
                                     new SVNRevision.Number(newStartRevNum),
                                     currEndRevision);
}
 
Example 3
Source File: MultiDiffPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void selectItem (JComboBox cmbDiffTree, SVNRevision revision) {
    Object toSelect = null;
    if (fileUrl != null) {
        DefaultComboBoxModel model = (DefaultComboBoxModel) cmbDiffTree.getModel();
        for (int i = 0; i < model.getSize(); ++i) {
            Object o = model.getElementAt(i);
            if (o instanceof RepositoryFile) {
                RepositoryFile inModel = (RepositoryFile) o;
                if (inModel.getFileUrl().equals(fileUrl) && revision.equals(inModel.getRevision())) {
                    toSelect = o;
                    break;
                }
            }
        }
    }
    if (toSelect != null) {
        cmbDiffTree.setSelectedItem(toSelect);
    }
}
 
Example 4
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 5
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNProperty propertyGet(SVNUrl url, SVNRevision revision,
		SVNRevision peg, String propertyName) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPGET);
		String target = url.toString();
		String commandLine = "propget -r " + revision.toString() + " "
				+ propertyName + " " + target;
		if (!peg.equals(SVNRevision.HEAD))
			commandLine += "@" + peg.toString();
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		byte[] bytes = svnClient.propertyGet(target, propertyName,
				JhlConverter.convert(revision), JhlConverter.convert(peg));
		if (bytes == null)
			return null;
		else
			return JhlPropertyData.newForUrl(target, propertyName, bytes);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 6
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void diff(File path, SVNUrl url, SVNRevision urlRevision,
		File outFile, boolean recurse) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF);

		// we don't want canonical file path (otherwise the complete file
		// name
		// would be in the patch). This way the user can choose to use a
		// relative
		// path
		String wcPath = fileToSVNPath(path, false);
		String svnOutFile = fileToSVNPath(outFile, false);

		String commandLine = "diff --old " + wcPath + " ";
		commandLine += "--new " + url.toString();
		if (!urlRevision.equals(SVNRevision.HEAD))
			commandLine += "@" + urlRevision.toString();

		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		svnClient.diff(wcPath, Revision.WORKING, url.toString(),
				JhlConverter.convert(urlRevision), null, svnOutFile,
				Depth.infinityOrEmpty(recurse), null, false, true, false,
				true);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 7
Source File: RevertModifications.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected boolean validateRevision(SVNRevision revision) {
    boolean valid = revision == null || revision.equals(SVNRevision.HEAD) || revision.getKind() == SVNRevision.Kind.number;
    RevertModifications.this.okButton.setEnabled(valid);
    return valid;
}
 
Example 8
Source File: RepositoryPaths.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void searchRepository() {
    SVNRevision revision = getRevision();     
    
    final SvnSearch svnSearch;
    try {
        RepositoryFile[] repositoryFiles = getRepositoryFiles();
        if(repositoryFiles.length > 0) {
            svnSearch = new SvnSearch(repositoryFiles); 
        } else {
            svnSearch = new SvnSearch(new RepositoryFile[] { repositoryFile }); 
        }                            
    } catch (MalformedURLException ex) {
        Subversion.LOG.log(Level.SEVERE, null, ex);
        return;
    }
                           
    final DialogDescriptor dialogDescriptor = 
            new DialogDescriptor(svnSearch.getSearchPanel(), java.util.ResourceBundle.getBundle("org/netbeans/modules/subversion/ui/browser/Bundle").getString("CTL_RepositoryPath_SearchRevisions")); 
    dialogDescriptor.setModal(true);
    dialogDescriptor.setHelpCtx(new HelpCtx(searchHelpID));
    dialogDescriptor.setValid(false);
    
    svnSearch.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            //if( ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName()) ) {
                dialogDescriptor.setValid(svnSearch.getSelectedRevision() != null);
           // }
        }
    });
    
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);        
    dialog.setVisible(true);

    // handle results
    if (DialogDescriptor.OK_OPTION.equals(dialogDescriptor.getValue())) {       
        revision = svnSearch.getSelectedRevision();
        if(revision != null) {
            if(revision.equals(SVNRevision.HEAD) ) {
                setRevisionTextField(""); // NOI18N
            } else {
                setRevisionTextField(revision.toString());                       
            }
        }
    } else {
        svnSearch.cancel(); 
    }
}
 
Example 9
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
private ISVNAnnotations annotate(String target, SVNRevision revisionStart,
		SVNRevision revisionEnd, SVNRevision pegRevision,
		boolean ignoreMimeType, boolean includeMergedRevisions)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.ANNOTATE);
		if (revisionStart == null)
			revisionStart = new SVNRevision.Number(1);
		if (revisionEnd == null)
			revisionEnd = SVNRevision.HEAD;
		if (pegRevision == null)
			pegRevision = SVNRevision.HEAD;
		String commandLine = "blame ";
		if (includeMergedRevisions)
			commandLine += "-g ";
		commandLine = commandLine + "-r " + revisionStart.toString() + ":"
				+ revisionEnd.toString() + " ";
		commandLine = commandLine + target + "@" + pegRevision;
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();

		JhlAnnotations annotations = new JhlAnnotations();
		svnClient.blame(target, JhlConverter.convert(pegRevision),
				JhlConverter.convert(revisionStart),
				JhlConverter.convert(revisionEnd), ignoreMimeType,
				includeMergedRevisions, annotations);
		return annotations;
	} catch (ClientException e) {
		if (includeMergedRevisions
				&& ((ClientException) e).getAprError() == SVNClientException.UNSUPPORTED_FEATURE) {
			return annotate(target, revisionStart, revisionEnd,
					pegRevision, ignoreMimeType, false);
		}
		if (e.getAprError() == ErrorCodes.fsNotFound && pegRevision != null
				&& !pegRevision.equals(revisionEnd)) {
			return annotate(target, revisionStart, pegRevision,
					pegRevision, ignoreMimeType, includeMergedRevisions);
		} else {
			notificationHandler.logException(e);
			throw new SVNClientException(e);
		}
	}

}
 
Example 10
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
private void getLogMessages(String target, SVNRevision pegRevision,
		SVNRevision revisionStart, SVNRevision revisionEnd,
		boolean stopOnCopy, boolean fetchChangePath, long limit,
		boolean includeMergedRevisions, String[] requestedProperties,
		ISVNLogMessageCallback worker) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.LOG);
		String logExtras = "";
		if (includeMergedRevisions)
			logExtras = logExtras + " -g";
		if (stopOnCopy)
			logExtras = logExtras + " --stop-on-copy";
		if (limit > 0)
			logExtras = logExtras + " --limit " + limit;
		notificationHandler.logCommandLine("log -r "
				+ revisionStart.toString() + ":" + revisionEnd.toString()
				+ " " + target + logExtras);
		JhlLogMessageCallback callback = new JhlLogMessageCallback(worker);
		Set<String> revProps = new HashSet<String>(
				requestedProperties.length);
		for (int i = 0; i < requestedProperties.length; i++) {
			revProps.add(requestedProperties[i]);
		}
		List<RevisionRange> range = new ArrayList<RevisionRange>();
		range.add(new RevisionRange(JhlConverter.convert(revisionStart),
				JhlConverter.convert(revisionEnd)));
		svnClient.logMessages(target, JhlConverter.convert(pegRevision),
				range, stopOnCopy, fetchChangePath, includeMergedRevisions,
				revProps, limit, callback);
	} catch (ClientException e) {
		// upgradeProject(new File(target));
		if (e.getAprError() == ErrorCodes.unsupportedFeature
				&& includeMergedRevisions) {
			getLogMessages(target, pegRevision, revisionStart, revisionEnd,
					stopOnCopy, fetchChangePath, limit, false,
					requestedProperties, worker);
		} else {
			if ((e.getAprError() == ErrorCodes.fsNotFound || e
					.getAprError() == ErrorCodes.clientUnrelatedResources)
					&& pegRevision != null
					&& !pegRevision.equals(revisionStart)) {
				getLogMessages(target, pegRevision, pegRevision,
						revisionEnd, stopOnCopy, fetchChangePath, limit,
						includeMergedRevisions, requestedProperties, worker);
			} else {

				upgradeProject(new File(target));
				notificationHandler.logException(e);
				throw new SVNClientException(e);
			}
		}
	}
}