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

The following examples show how to use org.tigris.subversion.svnclientadapter.SVNRevision#getRevision() . 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: CommitAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns log message for given revision
 * @param client
 * @param file
 * @param revision
 * @return log message
 * @throws org.tigris.subversion.svnclientadapter.SVNClientException
 */
private static ISVNLogMessage getLogMessage (ISVNClientAdapter client, File file, long revision) throws SVNClientException {
    SVNRevision rev = SVNRevision.HEAD;
    ISVNLogMessage log = null;
    try {
        rev = SVNRevision.getRevision(String.valueOf(revision));
    } catch (ParseException ex) {
        Subversion.LOG.log(Level.WARNING, "" + revision, ex);
    }
    if (Subversion.LOG.isLoggable(Level.FINER)) {
        Subversion.LOG.log(Level.FINER, "{0}: getting last commit message for svn hooks", CommitAction.class.getName());
    }
    // log has to be called directly on the file
    final SVNUrl fileRepositoryUrl = SvnUtils.getRepositoryUrl(file);
    ISVNLogMessage[] ls = client.getLogMessages(fileRepositoryUrl, rev, rev);
    if (ls.length > 0) {
        log = ls[0];
    } else {
        Subversion.LOG.log(Level.WARNING, "no logs available for file {0} with repo url {1}", new Object[]{file, fileRepositoryUrl});
    }
    return log;
}
 
Example 2
Source File: ShowAnnotationOperation.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private String getSingleEntry(ISVNRemoteFile file, Long revLong) {
	ISVNClientAdapter client = null;
	try {
		client = file.getRepository().getSVNClient();
		SVNRevision revision = SVNRevision.getRevision(revLong.toString());
		ISVNLogMessage [] messages = client.getLogMessages(file.getRepository().getRepositoryRoot(), revision, revision, false);
		if (messages.length == 1)
			return messages[0].getMessage();
		else
			return null;
	} catch (Exception e) {
		return null;
	}
	finally {
		file.getRepository().returnSVNClient(client);
	}
}
 
Example 3
Source File: SvnWizardUpdatePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public boolean performFinish() {
       if (headButton.getSelection()) revision = SVNRevision.HEAD;
       else {
           try {
               revision = SVNRevision.getRevision(revisionText.getText().trim());
           } catch (ParseException e1) {
             MessageDialog.openError(getShell(), Policy.bind("UpdateDialog.title"), Policy.bind("UpdateDialog.invalid")); //$NON-NLS-1$ //$NON-NLS-2$
             return false;   
           }
       }		
       setDepth = setDepthButton.getSelection();
       ignoreExternals = ignoreExternalsButton.getSelection();
       force = forceButton.getSelection();
       depth = DepthComboHelper.getDepth(depthCombo);
       conflictResolver = new SVNConflictResolver(resources[0], getTextConflictHandling(), getBinaryConflictHandling(), getPropertyConflictHandling(), getTreeConflictHandling());
	return true;
}
 
Example 4
Source File: ReplaceWithBranchTagWizardMainPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public boolean performFinish() {
	urlCombo.saveUrl();
	try {
		url =  new SVNUrl(urlCombo.getText());
	} catch (MalformedURLException e) {
		MessageDialog.openError(getShell(), "Replace with Branch/Tag", e.getMessage()); //$NON-NLS-1$
		return false;
	}
       if (headButton.getSelection()) revision = SVNRevision.HEAD;
       else {
           try {
               revision = SVNRevision.getRevision(revisionText.getText().trim());
           } catch (ParseException e1) {
             MessageDialog.openError(getShell(), "Replace with Branch/Tag", Policy.bind("SwitchDialog.invalid")); //$NON-NLS-1$ //$NON-NLS-2$
             return false;   
           }
       }
	return true;
}
 
Example 5
Source File: RemoteResourceTransfer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object fromByteArray(byte[] buffer) {
  try {
    ByteArrayInputStream in = new ByteArrayInputStream(buffer);
    DataInputStream readIn = new DataInputStream(in);

    boolean isFolder = readIn.readBoolean();

    // first, we read the url of the remote resource
    SVNUrl urlResource = new SVNUrl(readIn.readUTF());
        
    // then we read the url of the repository
    String location = readIn.readUTF();
    
    // we read the revision
    SVNRevision revision = SVNRevision.getRevision(readIn.readUTF());

    // we read the last changed revision
    SVNRevision.Number lastChangedRevision = ( Number) SVNRevision.getRevision(readIn.readUTF());
    
    Date date = new Date(readIn.readLong());
    
    String author = null;
    try {
    	author = readIn.readUTF();
    } catch (Exception e) {
    	// Ignore null author
    }
    
    ISVNRepositoryLocation repositoryLocation = SVNProviderPlugin.getPlugin().getRepository(location);
        
    if (isFolder) {
      return new RemoteFolder(null, repositoryLocation,urlResource, revision, lastChangedRevision, date, author);
    }
    return new RemoteFile(null, repositoryLocation,urlResource, revision, lastChangedRevision, date, author);
  } catch(Exception ex) {
    return null;        
  }
}
 
Example 6
Source File: SvnWizardCompareMultipleResourcesWithBranchTagPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public boolean performFinish() {
       urlCombo.saveUrl();
       try {
       	if (urlStrings.length > 1) {
       		urls = new SVNUrl[compareResources.length];
       		for (int i = 0; i < compareResources.length; i++) {
       			if (urlCombo.getText().endsWith("/")) //$NON-NLS-1$
       				urls[i] = new SVNUrl(urlCombo.getText() + compareResources[i].getPartialPath());
       			else
       				urls[i] = new SVNUrl(urlCombo.getText() + "/" + compareResources[i].getPartialPath()); //$NON-NLS-1$
       		}
       	}
       	else {
       		urls = new SVNUrl[1];
       		urls[0] = new SVNUrl(urlCombo.getText());
       	}
           if (headButton.getSelection()) revision = SVNRevision.HEAD;
           else {
               try {
                   revision = SVNRevision.getRevision(revisionText.getText().trim());
               } catch (ParseException e1) {
                 MessageDialog.openError(getShell(), Policy.bind("SvnWizardCompareMultipleResourcesWithBranchTagPage.0"), Policy.bind("SwitchDialog.invalid")); //$NON-NLS-1$ //$NON-NLS-2$
                 return false;   
               }
           }
       } catch (MalformedURLException e) {
           MessageDialog.openError(getShell(), Policy.bind("SvnWizardCompareMultipleResourcesWithBranchTagPage.0"), e.getMessage()); //$NON-NLS-1$
           return false;
       }
       return true;
}
 
Example 7
Source File: SvnWizardBranchTagPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public boolean performFinish() {
       if (projectProperties != null) {
           issue = issueText.getText().trim();
           if (projectProperties.isWarnIfNoIssue() && (issueText.getText().trim().length() == 0)) {
               if (!MessageDialog.openQuestion(getShell(), Policy.bind("BranchTagDialog.title"), Policy.bind("BranchTagDialog.0", projectProperties.getLabel()))) { //$NON-NLS-1$ //$NON-NLS-2$
                   issueText.setFocus();
                   return false;
               }
           }
           if (issueText.getText().trim().length() > 0) {
               String issueError = projectProperties.validateIssue(issueText.getText().trim());
               if (issueError != null) {
                   MessageDialog.openError(getShell(), Policy.bind("BranchTagDialog.title"), issueError); //$NON-NLS-1$
                   issueText.selectAll();
                   issueText.setFocus();
                   return false;
               }
           }
       }        
       toUrlCombo.saveUrl();
       createOnServer = !workingCopyButton.getSelection();
       specificRevision = revisionButton.getSelection();
       makeParents = makeParentsButton.getSelection();
       if(switchAfterBranchTagCheckBox != null) {
       	switchAfterBranchTag = switchAfterBranchTagCheckBox.getSelection();
       }
       
       comment = commitCommentArea.getComment(true);
       if (serverButton.getSelection()) revision = SVNRevision.HEAD;
       try {
           toUrl = new SVNUrl(toUrlCombo.getText());
           if (revisionButton.getSelection()) revision = SVNRevision.getRevision(revisionText.getText().trim());
       } catch (Exception e) {
           MessageDialog.openError(getShell(), Policy.bind("BranchTagDialog.title"), e.getMessage()); //$NON-NLS-1$
           return false;
       }
       if (resource != null) updateTagsProperty(toUrl);		
	return true;
}
 
Example 8
Source File: SvnWizardBranchTagPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void updateTagsProperty(SVNUrl toUrl) {
 	ISVNClientAdapter svnClient = null;
 	try {
ISVNProperty property = null;
property = svnResource.getSvnProperty("subclipse:tags"); //$NON-NLS-1$
if (property == null) return;
newAlias = new Alias();
newAlias.setBranch(toUrl.toString().toUpperCase().indexOf("TAGS") == -1); //$NON-NLS-1$
String relativePath = toUrl.toString().substring(svnResource.getRepository().getUrl().toString().length());
newAlias.setRelativePath(relativePath);
SVNRevision revision = null;
if (revisionButton.getSelection()) revision = SVNRevision.getRevision(revisionText.getText().trim());
else {
	svnClient = svnResource.getRepository().getSVNClient();
	ISVNInfo svnInfo = svnClient.getInfo(url);
	revision = SVNRevision.getRevision(svnInfo.getRevision().toString());
}
newAlias.setRevision(Integer.parseInt(revision.toString()));
newAlias.setName(toUrl.getLastPathSegment());
BranchTagPropertyUpdateDialog dialog = new BranchTagPropertyUpdateDialog(getShell(), resource, newAlias, "BranchTagPropertyUpdateDialog"); //$NON-NLS-1$
if (dialog.open() == BranchTagPropertyUpdateDialog.OK) 
	newAlias = dialog.getNewAlias();
else
	newAlias = null;
 	} catch (Exception e) {}
 	finally {
 		svnResource.getRepository().returnSVNClient(svnClient);
 	}
 }
 
Example 9
Source File: SvnWizardAnnotatePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private boolean validateRevision(String revision) {
       try {
           SVNRevision.getRevision(revision);
       } catch (ParseException e1) {
         return false;
       }		
       return true;
}
 
Example 10
Source File: SvnWizardSwitchPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public boolean performFinish() {
       try {
       	if (showUrl) {
        	urlCombo.saveUrl();
        	if (urlStrings.length > 1) {
        		urls = new SVNUrl[switchResources.length];
        		for (int i = 0; i < switchResources.length; i++) {
        			if (urlCombo.getText().endsWith("/")) //$NON-NLS-1$
        				urls[i] = new SVNUrl(urlCombo.getText() + switchResources[i].getPartialPath());
        			else
        				urls[i] = new SVNUrl(urlCombo.getText() + "/" + switchResources[i].getPartialPath()); //$NON-NLS-1$
        		}
        	}
        	else {
        		urls = new SVNUrl[1];
        		urls[0] = new SVNUrl(urlCombo.getText());
        	}
            if (headButton.getSelection()) revision = SVNRevision.HEAD;
            else {
                try {
                    revision = SVNRevision.getRevision(revisionText.getText().trim());
                } catch (ParseException e1) {
                  MessageDialog.openError(getShell(), Policy.bind("SwitchDialog.title"), Policy.bind("SwitchDialog.invalid")); //$NON-NLS-1$ //$NON-NLS-2$
                  return false;   
                }
            }
       	}
           setDepth = setDepthButton.getSelection();
           ignoreExternals = ignoreExternalsButton.getSelection();
           force = forceButton.getSelection();
           ignoreAncestry = ignoreAncestryButton.getSelection();
           depth = DepthComboHelper.getDepth(depthCombo);
           conflictResolver = new SVNConflictResolver(resources[0], getTextConflictHandling(), getBinaryConflictHandling(), getPropertyConflictHandling(), getTreeConflictHandling());
       } catch (MalformedURLException e) {
           MessageDialog.openError(getShell(), Policy.bind("SwitchDialog.title"), e.getMessage()); //$NON-NLS-1$
           return false;
       }
       return true;
}
 
Example 11
Source File: BranchTagWizard.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void updateTagsProperty(SVNUrl toUrl) {
 	ISVNClientAdapter svnClient = null;
 	try {
 		if (resources.length > 1) return;
ISVNProperty property = null;
property = repositoryPage.getSvnResource().getSvnProperty("subclipse:tags"); //$NON-NLS-1$
if (property == null) return;
newAlias = new Alias();
newAlias.setBranch(toUrl.toString().toUpperCase().indexOf("TAGS") == -1); //$NON-NLS-1$
String relativePath = toUrl.toString().substring(repositoryPage.getSvnResource().getRepository().getUrl().toString().length());
newAlias.setRelativePath(relativePath);
SVNRevision revision = null;
if (copyPage.revisionButton.getSelection()) revision = SVNRevision.getRevision(copyPage.getRevision());
else {
	svnClient = repositoryPage.getSvnResource().getRepository().getSVNClient();
	ISVNInfo svnInfo = svnClient.getInfo(repositoryPage.getUrl());
	revision = SVNRevision.getRevision(svnInfo.getRevision().toString());
}
newAlias.setRevision(Integer.parseInt(revision.toString()));
newAlias.setName(toUrl.getLastPathSegment());
BranchTagPropertyUpdateDialog dialog = new BranchTagPropertyUpdateDialog(getShell(), getResource(), newAlias, "BranchTagPropertyUpdateDialog"); //$NON-NLS-1$
if (dialog.open() == BranchTagPropertyUpdateDialog.OK) 
	newAlias = dialog.getNewAlias();
else
	newAlias = null;
 	} catch (Exception e) {}
 	finally {
 		if (svnClient != null) {
 			repositoryPage.getSvnResource().getRepository().returnSVNClient(svnClient);
 		}
 	}
 }
 
Example 12
Source File: CheckoutWizardCheckoutAsWithProjectFilePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public SVNRevision getRevision() {
	if (headButton.getSelection()) return SVNRevision.HEAD;
	SVNRevision svnRevision = null;
		try {
			svnRevision = SVNRevision.getRevision(revisionText.getText().trim());
		} catch (ParseException e) {}
	if (svnRevision == null)
		return SVNRevision.HEAD;
	return svnRevision;
}
 
Example 13
Source File: CheckoutWizardCheckoutAsWithoutProjectFilePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public SVNRevision getRevision() {
	if (headButton.getSelection()) return SVNRevision.HEAD;
	SVNRevision svnRevision = null;
		try {
			svnRevision = SVNRevision.getRevision(revisionText.getText().trim());
		} catch (ParseException e) {}
		if (svnRevision == null)
			return SVNRevision.HEAD;
		return svnRevision;
}
 
Example 14
Source File: CheckoutWizardCheckoutAsMultiplePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public SVNRevision getRevision() {
	if (headButton.getSelection()) return SVNRevision.HEAD;
	SVNRevision svnRevision = null;
		try {
			svnRevision = SVNRevision.getRevision(revisionText.getText().trim());
		} catch (ParseException e) {}
	if (svnRevision == null)
		return SVNRevision.HEAD;
	return svnRevision;
}