org.tigris.subversion.svnclientadapter.SVNUrl Java Examples

The following examples show how to use org.tigris.subversion.svnclientadapter.SVNUrl. 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: SvnWizardUpdatePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected void showLog() {
 ISVNRemoteResource remoteResource = null;
    try {
        remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]).getRepository().getRemoteFile(new SVNUrl(commonRoot));
    } catch (Exception e) {
        MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), e.toString()); //$NON-NLS-1$
        return;
    }
    if (remoteResource == null) {
        MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + commonRoot); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        return;	            
    }	
    HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
    if (dialog.open() == HistoryDialog.CANCEL) return;
    ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
    if (selectedEntries.length == 0) return;
    revisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
    setPageComplete(canFinish());
}
 
Example #2
Source File: SubversionVCS.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public boolean areCollocated(File a, File b) {
    File fra = getTopmostManagedAncestor(a);
    File frb = getTopmostManagedAncestor(b);
    if (fra == null || !fra.equals(frb)) return false;
    try {
        SVNUrl ra = SvnUtils.getRepositoryRootUrl(a);
        if(ra == null) {
            // this might happen. there is either no svn client available or
            // no repository url stored in the metadata (svn < 1.3).
            // one way or another, can't do anything reasonable at this point
            Subversion.LOG.log(Level.WARNING, "areCollocated returning false due to missing repository url for {0} {1}", new Object[] {a, b});
            return false;
        }
        SVNUrl rb = SvnUtils.getRepositoryRootUrl(b);
        SVNUrl rr = SvnUtils.getRepositoryRootUrl(fra);
        return ra.equals(rb) && ra.equals(rr);
    } catch (SVNClientException e) {
        if (!WorkingCopyAttributesCache.getInstance().isSuppressed(e)) {
            Subversion.LOG.log(Level.INFO, null, e);
        }
        Subversion.LOG.log(Level.WARNING, "areCollocated returning false due to catched exception " + a + " " + b);
        // root not found
        return false;
    }
}
 
Example #3
Source File: AnnotationBar.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void revert(File file, String revision) {
    final Context ctx = new Context(file);

    final SVNUrl url;
    try {
        url = SvnUtils.getRepositoryRootUrl(file);
    } catch (SVNClientException ex) {
        SvnClientExceptionHandler.notifyException(ex, true, true);
        return;
    }
    final RepositoryFile repositoryFile = new RepositoryFile(url, url, SVNRevision.HEAD);

    final RevertModifications revertModifications = new RevertModifications(repositoryFile, revision);
    if(!revertModifications.showDialog()) {
        return;
    }

    RequestProcessor rp = Subversion.getInstance().getRequestProcessor(url);
    SvnProgressSupport support = new SvnProgressSupport() {
        @Override
        public void perform() {
            RevertModificationsAction.performRevert(revertModifications.getRevisionInterval(), revertModifications.revertNewFiles(), !revertModifications.revertRecursively(), ctx, this);
        }
    };
    support.start(rp, url, NbBundle.getMessage(AnnotationBar.class, "MSG_Revert_Progress")); // NOI18N
}
 
Example #4
Source File: MoveRemoteResourceWizardMainPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Validates the contents of the editable fields and set page completion
 * and error messages appropriately. Call each time folder name or parent url
    * is modified
 */
private void validateFields() {
	if (resourceNameText.getText().length() == 0) {
		setErrorMessage(null);
		setPageComplete(false);
		return;
	}
	try {
		new SVNUrl(Util.appendPath(urlParentText.getText(), resourceNameText.getText()));
	} catch (MalformedURLException e) {
		setErrorMessage(Policy.bind("MoveRemoteResourceWizardMainPage.invalidUrl")); //$NON-NLS-1$);
		setPageComplete(false);
		return;
	}
	setErrorMessage(null);
	setPageComplete(true);
}
 
Example #5
Source File: SvnClientExceptionHandler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages("CTL_Action_Cancel=Cancel")
public static boolean handleAuth (SVNUrl url) {
    SvnKenaiAccessor support = SvnKenaiAccessor.getInstance();
    String sUrl = url.toString();
    if(support.isKenai(sUrl)) {
        return support.showLogin() && support.getPasswordAuthentication(sUrl, true) != null;
    } else {
        Repository repository = new Repository(Repository.FLAG_SHOW_PROXY, org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "MSG_Error_ConnectionParameters"));  // NOI18N
        repository.selectUrl(url, true);

        JButton retryButton = new JButton(org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "CTL_Action_Retry"));           // NOI18N
        String title = org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "MSG_Error_AuthFailed");
        Object option = repository.show(
                title, 
                new HelpCtx("org.netbeans.modules.subversion.client.SvnClientExceptionHandler"), //NOI18N
                new Object[] { retryButton,
                    Bundle.CTL_Action_Cancel()
                }, retryButton);

        boolean ret = (option == retryButton);
        if(ret) {
            SvnModuleConfig.getDefault().insertRecentUrl(repository.getSelectedRC());
        }
        return ret;
    }
}
 
Example #6
Source File: BranchTagAction.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    if (action != null && !action.isEnabled()) { 
    	action.setEnabled(true);
    } 
    else {
     IResource[] resources = getSelectedResources();
    	BranchTagWizard wizard = new BranchTagWizard(resources);
    	SizePersistedWizardDialog dialog = new SizePersistedWizardDialog(getShell(), wizard, "BranchTag"); //$NON-NLS-1$
    	wizard.setParentDialog(dialog);
    	if (dialog.open() == WizardDialog.OK) {	
    		SVNUrl[] sourceUrls = wizard.getUrls();
    		SVNUrl destinationUrl = wizard.getToUrl();
    		String message = wizard.getComment();
    		boolean createOnServer = wizard.isCreateOnServer();
         BranchTagOperation branchTagOperation = new BranchTagOperation(getTargetPart(), getSelectedResources(), sourceUrls, destinationUrl, createOnServer, wizard.getRevision(), message);
         branchTagOperation.setMakeParents(wizard.isMakeParents());
         branchTagOperation.setMultipleTransactions(wizard.isSameStructure());
         branchTagOperation.setNewAlias(wizard.getNewAlias());
         branchTagOperation.switchAfterTagBranchOperation(wizard.isSwitchAfterBranchTag());
         branchTagOperation.setSvnExternals(wizard.getSvnExternals());
         branchTagOperation.run();        		
    	}
    }
}
 
Example #7
Source File: SvnClientFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void setupCommandline () {
    if(!checkCLIExecutable()) return;
    
    factory = new ClientAdapterFactory() {
        @Override
        protected ISVNClientAdapter createAdapter() {
            return new CommandlineClient(); //SVNClientAdapterFactory.createSVNClient(CmdLineClientAdapterFactory.COMMANDLINE_CLIENT);
        }
        @Override
        protected SvnClientInvocationHandler getInvocationHandler(ISVNClientAdapter adapter, SvnClientDescriptor desc, SvnProgressSupport support, int handledExceptions) {
            return new SvnClientInvocationHandler(adapter, desc, support, handledExceptions, ConnectionType.cli);
        }
        @Override
        protected ISVNPromptUserPassword createCallback(SVNUrl repositoryUrl, int handledExceptions) {
            return null;
        }
        @Override
        protected ConnectionType connectionType() {
            return ConnectionType.cli;
        }
    };
    LOG.info("running on commandline");
}
 
Example #8
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void copy(File srcPath, SVNUrl destUrl, String message)
		throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);
		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.COPY);
		String src = fileToSVNPath(srcPath, false);
		String dest = destUrl.toString();
		notificationHandler.logCommandLine("copy " + src + " " + dest);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(srcPath));
		List<CopySource> copySources = new ArrayList<CopySource>();
		copySources.add(new CopySource(src, Revision.WORKING,
				Revision.WORKING));
		svnClient.copy(copySources, dest, true, true, true, null,
				new JhlCommitMessage(fixedMessage), null);
		// last parameter is not used
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #9
Source File: RepositoryFile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public RepositoryFile(SVNUrl repositoryUrl, String[] pathSegments, SVNRevision revision) throws MalformedURLException {
    this(repositoryUrl, revision);
    this.pathSegments = pathSegments;    
    repositoryRoot = pathSegments == null;        
    
    if(!repositoryRoot) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < pathSegments.length; i++) {
            sb.append(pathSegments[i]);
            if(i<pathSegments.length-1) {
            sb.append("/"); // NOI18N
            }            
        }
        path = sb.toString();        
        fileUrl = repositoryUrl.appendPath(path);        
    }
}
 
Example #10
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void propertySet(SVNUrl url, SVNRevision.Number baseRev,
		String propertyName, String propertyValue, String message)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPSET);
		if (propertyName.startsWith("svn:")) {
			// Normalize line endings in property value
			svnClient.propertySetRemote(url.toString(),
					baseRev.getNumber(), propertyName,
					fixSVNString(propertyValue).getBytes(),
					new JhlCommitMessage(message), false, null,
					new JhlCommitCallback());
		} else {
			svnClient.propertySetRemote(url.toString(),
					baseRev.getNumber(), propertyName,
					propertyValue.getBytes(),
					new JhlCommitMessage(message), false, null,
					new JhlCommitCallback());
		}
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #11
Source File: CopyDialogTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testProcessRecentFolders_NoBranchInHistory_OnTrunk () throws Exception {
    JComboBox combo = new JComboBox();
    JTextComponent comp = (JTextComponent) combo.getEditor().getEditorComponent();
    Map<String, String> items;
    // combo items should be sorted by name
    
    // file on trunk, no branch in history
    items = CopyDialog.setupModel(combo, new RepositoryFile(new SVNUrl("file:///home"), "trunk/subfolder/folder", SVNRevision.HEAD), recentUrlsWithoutBranches, false);
    assertModel(items, combo, Arrays.asList(new String[] {
        "trunk/subfolder/folder", null,
        "----------", null,
        MORE_BRANCHES, null,
        "----------", null,
        "Project/src/folder", null,
        "Project2/src/folder", null,
        "trunk/Project/src/folder", null
    }));
    // least recently used is preselected
    assertEquals("branches/[BRANCH_NAME]/subfolder/folder", comp.getText());
    // no branch - no selection
    assertEquals("[BRANCH_NAME]", comp.getSelectedText());
}
 
Example #12
Source File: CheckoutTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void testCheckoutFolder(String repoFolderName,
                                String targetFolderName) throws Exception {
    File cifolder = createFolder(repoFolderName);
    File folder1 = createFolder(cifolder, "folder1");
    File file = createFile(folder1, "file");

    importFile(cifolder);        

    File checkout = createFolder(targetFolderName);
    SVNUrl url = getTestUrl().appendPath(cifolder.getName());
    ISVNClientAdapter c = getNbClient();         
    c.checkout(url, checkout, SVNRevision.HEAD, true);
            
    File chFolder1 = new File(checkout, folder1.getName());
    File chFile = new File(chFolder1, file.getName());
    
    assertTrue(chFolder1.exists());
    assertTrue(chFile.exists());
    assertStatus(SVNStatusKind.NORMAL, checkout);                   
    assertStatus(SVNStatusKind.NORMAL, chFolder1);        
    assertStatus(SVNStatusKind.NORMAL, chFile);

    assertNotifiedFiles(new File[] {chFolder1, chFile});
}
 
Example #13
Source File: RepositoryFile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public RepositoryFile(SVNUrl repositoryUrl, SVNUrl fileUrl, SVNRevision revision) {       
    this(repositoryUrl, revision);
    this.fileUrl = fileUrl;        
    repositoryRoot = fileUrl == null;   
    
    if(!repositoryRoot) {            
        String[] fileUrlSegments = fileUrl.getPathSegments();
        int fileSegmentsLength = fileUrlSegments.length;
        int repositorySegmentsLength = repositoryUrl.getPathSegments().length;
        pathSegments = new String[fileSegmentsLength - repositorySegmentsLength];
        StringBuffer sb = new StringBuffer();
        for (int i = repositorySegmentsLength; i < fileSegmentsLength; i++) {
            pathSegments[i-repositorySegmentsLength] = fileUrlSegments[i];
            sb.append(fileUrlSegments[i]);
            if(i-repositorySegmentsLength < pathSegments.length-1) {
                sb.append("/"); // NOI18N
            }
        }    
        path = sb.toString();
    }                
}
 
Example #14
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public InputStream getContent(SVNUrl url, SVNRevision revision,
		SVNRevision pegRevision) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.CAT);
		String commandLine = "cat -r " + revision + " " + url;
		if (pegRevision != null) {
			commandLine = commandLine + "@" + pegRevision;
		}
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();

		byte[] contents = svnClient.fileContent(url.toString(),
				JhlConverter.convert(revision),
				JhlConverter.convert(pegRevision));
		InputStream input = new ByteArrayInputStream(contents);
		return input;
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #15
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void mkdir(SVNUrl url, boolean makeParents, String message)
		throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);

		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.MKDIR);
		Set<String> target = new HashSet<String>();
		target.add(url.toString());
		if (makeParents)
			notificationHandler.logCommandLine("mkdir --parents -m \""
					+ getFirstMessageLine(fixedMessage) + "\" " + target);
		else
			notificationHandler.logCommandLine("mkdir -m \""
					+ getFirstMessageLine(fixedMessage) + "\" " + target);
		notificationHandler.setBaseDir();
		svnClient.mkdir(target, makeParents, null, new JhlCommitMessage(
				fixedMessage), null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #16
Source File: BranchTagCommand.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public SVNUrl getDestinationUrl(String sourceUrl) {
	if (!multipleTransactions) {
		if (sourceUrls.length == 1) {
			return destinationUrl;
		} else {
			String uncommonPortion = sourceUrl.substring(getCommonRoot().length());
			String toUrl = destinationUrl.toString() + uncommonPortion;
			try {
	return new SVNUrl(toUrl);
} catch (MalformedURLException e) {
	return destinationUrl;
}   			
		}
	}
	else return (SVNUrl)urlMap.get(sourceUrl);
}
 
Example #17
Source File: LogCommand.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public LogCommand(SVNUrl url, String[] paths, SVNRevision revStart, SVNRevision revEnd, SVNRevision pegRevision, boolean stopOnCopy, boolean fetchChangePath, long limit) {        
    this.revStart = revStart;
    this.revEnd = revEnd;
    this.pegRevision = pegRevision;
    this.stopOnCopy = stopOnCopy;
    this.fetchChangePath = fetchChangePath;
    this.limit = limit;
    this.url = url;
    this.paths = paths;
                    
    this.type = LogType.url;
    
    file = null;
}
 
Example #18
Source File: RelocateAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void validate(RelocatePanel panel, JButton btnOk) {
    try {
        new SVNUrl(panel.getNewURL().getText());
        btnOk.setEnabled(true);
    } catch (MalformedURLException e) {
        btnOk.setEnabled(false);
    }
}
 
Example #19
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public ISVNProperty[] getProperties(SVNUrl url) throws SVNClientException {
    ListPropertiesCommand cmd = new ListPropertiesCommand(url, false);
    exec(cmd);
    List<String> names = cmd.getPropertyNames();
    List<ISVNProperty> props = new ArrayList<ISVNProperty>(names.size());
    for (String name : names) {
        ISVNProperty prop = propertyGet(url, name);
        if (prop != null) {
            props.add(prop);
        }
    }
    return props.toArray(new ISVNProperty[props.size()]);
}
 
Example #20
Source File: CreateCopyAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void performContextAction(final Node[] nodes) {
    
    if(!Subversion.getInstance().checkClientAvailable()) {            
        return;
    }
    
    Context ctx = getContext(nodes);

    final File[] roots = SvnUtils.getActionRoots(ctx);
    if(roots == null || roots.length == 0) return;
    File[] files = Subversion.getInstance().getStatusCache().listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE);       
    
    File interestingFile;
    if(roots.length == 1) {
        interestingFile = roots[0];
    } else {
        interestingFile = SvnUtils.getPrimaryFile(roots[0]);
    }

    final SVNUrl repositoryUrl; 
    final SVNUrl fileUrl;        
    try {            
        repositoryUrl = SvnUtils.getRepositoryRootUrl(interestingFile); // XXX
        fileUrl = SvnUtils.getRepositoryUrl(interestingFile);
    } catch (SVNClientException ex) {
        SvnClientExceptionHandler.notifyException(ex, true, true);
        return;
    }                   
    final RepositoryFile repositoryFile = new RepositoryFile(repositoryUrl, fileUrl, SVNRevision.HEAD);        

    final RequestProcessor rp = createRequestProcessor(ctx);
    final boolean hasChanges = files.length > 0;
    final CreateCopy createCopy = new CreateCopy(repositoryFile, interestingFile, hasChanges);

    performCopy(createCopy, rp, nodes, roots);
}
 
Example #21
Source File: UpdateTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void testUpdateFile(String folder1Name,
                            String folder2Name,
                            String fileName) throws Exception {
    File wc1 = createFolder(folder1Name);
    File file1 = createFile(wc1, fileName);
    write(file1, 1);
    importFile(wc1);
    assertStatus(SVNStatusKind.NORMAL, wc1);
    assertStatus(SVNStatusKind.NORMAL, file1);
                    
    File wc2 = createFolder(folder2Name);
    File file2 = new File(wc2, fileName);
    
    SVNUrl url = getTestUrl().appendPath(wc1.getName());
    ISVNClientAdapter c = getNbClient();         
    c.checkout(url, wc2, SVNRevision.HEAD, true);
    assertStatus(SVNStatusKind.NORMAL, file2);
    assertContents(file2, 1);
    
    SVNRevision revisionBefore = (SVNRevision.Number) getRevision(getRepoUrl());
    
    write(file2, 2);
    assertStatus(SVNStatusKind.MODIFIED, file2);
    commit(file2);
    assertStatus(SVNStatusKind.NORMAL, file2);
                    
    clearNotifiedFiles();     
    long r = c.update(file1, SVNRevision.HEAD, false);
    
    SVNRevision revisionAfter = (SVNRevision.Number) getRevision(getRepoUrl());
    
    assertNotSame(revisionBefore, revisionAfter);
    assertEquals(((SVNRevision.Number)revisionAfter).getNumber(), r);
    assertStatus(SVNStatusKind.NORMAL, file1);
    assertContents(file1, 2);     
    assertNotifiedFiles(new File[] {file1});
}
 
Example #22
Source File: SvnConfigFiles.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean setProxy(SVNUrl url, Ini.Section nbGlobalSection) {
    String host =  SvnUtils.ripUserFromHost(url.getHost());        
    Ini.Section svnGlobalSection = svnServers.get(GLOBAL_SECTION);
    URI uri = null;
    boolean passwordAdded = false;
    try {
        uri = new URI(url.toString());
    } catch (URISyntaxException ex) {
        Subversion.LOG.log(Level.INFO, null, ex);
        return passwordAdded;
    }
    String proxyHost = NetworkSettings.getProxyHost(uri);
    // check DIRECT connection
    if(proxyHost != null && proxyHost.length() > 0) {
        String proxyPort = NetworkSettings.getProxyPort(uri);
        assert proxyPort != null;
        nbGlobalSection.put("http-proxy-host", proxyHost);                     // NOI18N
        nbGlobalSection.put("http-proxy-port", proxyPort);                     // NOI18N

        // and the authentication
        String username = NetworkSettings.getAuthenticationUsername(uri);
        if(username != null) {
            String password = getProxyPassword(NetworkSettings.getKeyForAuthenticationPassword(uri));

            nbGlobalSection.put("http-proxy-username", username);                               // NOI18N
            nbGlobalSection.put("http-proxy-password", password);                               // NOI18N
            passwordAdded = true;
        }
    }
    // check if there are also some no proxy settings
    // we should get from the original svn servers file
    mergeNonProxyKeys(host, svnGlobalSection, nbGlobalSection);
    return passwordAdded;
}
 
Example #23
Source File: BranchTagOperation.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public BranchTagOperation(IWorkbenchPart part, IResource[] resources, SVNUrl[] sourceUrls, SVNUrl destinationUrl, boolean createOnServer, SVNRevision revision, String message) {
    super(part, resources);
    this.sourceUrls = sourceUrls;
    this.destinationUrl = destinationUrl;
    this.createOnServer = createOnServer;
    this.revision = revision;
    this.message = message;
}
 
Example #24
Source File: JhlInfo2.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public SVNUrl getRepository() {
	try {
		return new SVNUrl(info.getReposRootUrl());
	} catch (MalformedURLException e) {
           //should never happen.
		return null;
	}
}
 
Example #25
Source File: Subversion.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static SvnClient getClient(SVNUrl url, String username, String password) {       
    try {
        if(username != null) {
            password = password != null ? password : "";                    // NOI18N
            return getSubversion().getClient(url, username, password.toCharArray());
        } else {
            return getSubversion().getClient(url);
        }
    } catch (SVNClientException ex) {
        SvnClientExceptionHandler.notifyException(ex, false, true);
    }        
    return null;
}
 
Example #26
Source File: ProjectProperties.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private static String resolveUrl(String url, ISVNLocalResource svnResource) {
	String resolvedUrl = null;
	
	// Relative to repository root, with navigators.
	if (url.startsWith("^/")) {
		SVNUrl repositoryUrl = svnResource.getRepository().getUrl();
		String path = url.substring(1);
		while (path.startsWith("/..")) {
			if (repositoryUrl.getParent() == null) break;
			repositoryUrl = repositoryUrl.getParent();
			path = path.substring(3);
		}
		resolvedUrl = repositoryUrl + path;
	}
	
	// Relative to host.
	else if (url.startsWith("/")) {
		String resourceUrl = svnResource.getUrl().toString();
		String protocol = svnResource.getUrl().getProtocol();
		int start = protocol.length();
		while (resourceUrl.substring(start, start + 1).equals(":") || resourceUrl.substring(start, start + 1).equals("/"))
			start++;
		int end = resourceUrl.indexOf("/", start);
		if (end == -1) resolvedUrl = resourceUrl + url;
		else resolvedUrl = resourceUrl.substring(0, end) + url;
	}
	
	//  Non-relative
	else resolvedUrl = url;
	
	return resolvedUrl;
}
 
Example #27
Source File: Merge.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public SVNUrl getMergeEndUrl() {
    try {
        return mergeEndRepositoryPaths.getRepositoryFiles()[0].getFileUrl();
    } catch (MalformedURLException ex) {
        // should be already checked and
        // not happen at this place anymore
        Subversion.LOG.log(Level.INFO, null, ex);
    }
    return null;
}
 
Example #28
Source File: JhlInfo2.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public SVNUrl getUrl() {
	try {
		return new SVNUrl(info.getUrl());
	} catch (MalformedURLException e) {
           //should never happen.
		return null;
	}
}
 
Example #29
Source File: NotificationsManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void notifyChanges (HashMap<Long, Notification> notifications, SVNUrl repositoryUrl) {
    for (Map.Entry<Long, Notification> e : notifications.entrySet()) {
        Notification notification = e.getValue();
        File[] files = notification.getFiles();
        Long revision = notification.getRevision();
        notifyFileChange(files, files[0].getParentFile(), repositoryUrl.toString(), revision == null ? null : revision.toString());
    }
}
 
Example #30
Source File: JhlStatus.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public SVNUrl getUrl() {
	try {
           return (_s.getUrl() != null) ? new SVNUrl(_s.getUrl()) : null;
       } catch (MalformedURLException e) {
           //should never happen.
           return null;
       }
}