Search in sources :

Example 41 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class SwitchAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    if (action != null && !action.isEnabled()) {
        action.setEnabled(true);
    } else {
        IResource[] resources = getSelectedResources();
        // Use different wizard page name if multiple resources selected so that
        // page size and location will be saved and restored separately for
        // single selection switch and multiple selection switch.
        String pageName;
        if (resources.length > 1)
            pageName = "SwitchDialogWithConflictHandling.multiple";
        else
            // $NON-NLS-1$
            pageName = "SwitchDialogWithConflictHandling";
        SvnWizardSwitchPage switchPage = new SvnWizardSwitchPage(pageName, resources);
        SvnWizard wizard = new SvnWizard(switchPage);
        SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
        wizard.setParentDialog(dialog);
        if (dialog.open() == SvnWizardDialog.OK) {
            SVNUrl[] svnUrls = switchPage.getUrls();
            SVNRevision svnRevision = switchPage.getRevision();
            SwitchOperation switchOperation = new SwitchOperation(getTargetPart(), resources, svnUrls, svnRevision);
            switchOperation.setDepth(switchPage.getDepth());
            switchOperation.setSetDepth(switchPage.isSetDepth());
            switchOperation.setIgnoreExternals(switchPage.isIgnoreExternals());
            switchOperation.setForce(switchPage.isForce());
            switchOperation.setIgnoreAncestry(switchPage.isIgnoreAncestry());
            switchOperation.setCanRunAsJob(canRunAsJob);
            switchOperation.setConflictResolver(switchPage.getConflictResolver());
            switchOperation.run();
        }
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SvnWizardSwitchPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardSwitchPage) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource) SwitchOperation(org.tigris.subversion.subclipse.ui.operations.SwitchOperation)

Example 42 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class RevisionDetailsAction method run.

public void run() {
    remoteResource = null;
    logEntry = null;
    includeTags = SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_SHOW_TAGS_IN_REMOTE);
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            try {
                RevisionGraphEditorInput input = (RevisionGraphEditorInput) editor.getEditorInput();
                ISVNInfo info = input.getInfo();
                ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(info.getRepository().toString());
                remoteResource = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node.getPath()), new SVNRevision.Number(node.getRevision()));
                AliasManager tagManager = null;
                if (includeTags)
                    tagManager = new AliasManager(remoteResource.getUrl());
                SVNRevision pegRevision = new SVNRevision.Number(node.getRevision());
                SVNRevision revisionStart = new SVNRevision.Number(node.getRevision());
                SVNRevision revisionEnd = new SVNRevision.Number(node.getRevision());
                GetLogsCommand logCmd = new GetLogsCommand(remoteResource, pegRevision, revisionStart, revisionEnd, false, 0, tagManager, true);
                logCmd.run(null);
                ILogEntry[] logEntries = logCmd.getLogEntries();
                if (logEntries != null && logEntries.length > 0) {
                    logEntry = logEntries[0];
                }
            } catch (Exception e) {
                MessageDialog.openError(Display.getDefault().getActiveShell(), "Revision Info", e.getMessage());
            }
        }
    });
    if (logEntry != null) {
        ShowRevisionsDialog dialog = new ShowRevisionsDialog(Display.getDefault().getActiveShell(), logEntry, remoteResource, includeTags, null);
        dialog.setTitle("Revision Info");
        dialog.setSelectFirst(true);
        dialog.open();
    }
}
Also used : AliasManager(org.tigris.subversion.subclipse.core.history.AliasManager) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) RevisionGraphEditorInput(org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ShowRevisionsDialog(org.tigris.subversion.subclipse.ui.dialogs.ShowRevisionsDialog) GetLogsCommand(org.tigris.subversion.subclipse.core.commands.GetLogsCommand) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Example 43 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class Cache method refresh.

public void refresh(List refreshedNodes, ISVNInfo info, IProgressMonitor monitor, int unitWorked) {
    ISVNLogMessageCallback callback = new ISVNLogMessageCallback() {

        public void singleMessage(ISVNLogMessage message) {
            update(message, true);
        }
    };
    revisionsTempFile = new File(root, "revisionsTemp");
    logMessagesTempFile = new File(root, "logMessagesTemp");
    revisionsTempFile.delete();
    logMessagesTempFile.delete();
    try {
        revisionsTempFile.createNewFile();
        logMessagesTempFile.createNewFile();
    } catch (IOException e) {
        Activator.handleError(e);
    }
    List revisions = new ArrayList();
    Iterator iter = refreshedNodes.iterator();
    while (iter.hasNext()) {
        Node node = (Node) iter.next();
        revisions.add(Long.toString(node.getRevision()));
    }
    startTempUpdate();
    RandomAccessFile file = null;
    ISVNClientAdapter client = null;
    try {
        client = SVNProviderPlugin.getPlugin().getSVNClient();
        file = new RandomAccessFile(logMessagesFile, "r");
        int revInt = new Long(getLatestRevision()).intValue();
        while (file.getFilePointer() < file.length()) {
            ISVNLogMessage lm = readNext(file, true);
            level = 0;
            int index = revisions.indexOf(lm.getRevision().toString());
            if (index == -1) {
                update(lm, true);
                if (lm.hasChildren() && lm.getChildMessages() != null) {
                    updateChildren(lm, true);
                }
                monitor.worked(unitWorked / revInt);
            } else {
                Node updateNode = (Node) refreshedNodes.get(index);
                SVNRevision updateRevision = new SVNRevision.Number(updateNode.getRevision());
                client.getLogMessages(new SVNUrl(info.getRepository() + updateNode.getPath()), updateRevision, updateRevision, updateRevision, false, true, 0, true, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
                monitor.worked(unitWorked);
            // updateRevision = (ISVNLogMessage)refreshedMessages.get(index);
            // monitor.worked(unitWorked);
            }
            if (monitor.isCanceled()) {
                break;
            }
        }
    } catch (Exception e) {
    } finally {
        closeFile(file);
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
    }
    finishTempUpdate();
    if (monitor.isCanceled()) {
        revisionsTempFile.delete();
        logMessagesTempFile.delete();
        return;
    }
    revisionsFile.delete();
    logMessagesFile.delete();
    revisionsTempFile.renameTo(revisionsFile);
    logMessagesTempFile.renameTo(logMessagesFile);
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ISVNLogMessage(org.tigris.subversion.svnclientadapter.ISVNLogMessage) IOException(java.io.IOException) ISVNLogMessageCallback(org.tigris.subversion.svnclientadapter.ISVNLogMessageCallback) RandomAccessFile(java.io.RandomAccessFile) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 44 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class SVNUrlWithPegRevision method parse.

private void parse(SVNUrl url) {
    String urlString = url.toString();
    if (!urlString.endsWith("@")) {
        int index = urlString.lastIndexOf("@");
        if (index != -1) {
            String rev = urlString.substring(index + 1);
            try {
                pegRevision = SVNRevision.getRevision(rev);
            } catch (ParseException e) {
            }
            if (pegRevision != null) {
                urlString = urlString.substring(0, index);
                try {
                    this.url = new SVNUrl(urlString);
                } catch (MalformedURLException e) {
                    this.url = url;
                    pegRevision = null;
                }
                return;
            }
        }
    }
    this.url = url;
}
Also used : MalformedURLException(java.net.MalformedURLException) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ParseException(java.text.ParseException)

Example 45 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.

the class Util method getUrlForRevision.

public static SVNUrl getUrlForRevision(ISVNRemoteResource resource, SVNRevision.Number revision, IProgressMonitor pm) throws SVNException {
    SVNUrl url = resource.getUrl();
    SVNRevision revisionStart = new SVNRevision.Number(revision.getNumber());
    GetLogsCommand getLogsCommand = new GetLogsCommand(resource, SVNRevision.HEAD, revisionStart, SVNRevision.HEAD, false, 0, null, true);
    getLogsCommand.run(pm);
    ILogEntry[] logEntries = getLogsCommand.getLogEntries();
    String path = resource.getRepositoryRelativePath().replaceAll("%20", " ");
    for (int i = logEntries.length - 1; i > -1; i--) {
        ILogEntry logEntry = logEntries[i];
        if (!logEntry.getRevision().equals(revision)) {
            LogEntryChangePath[] changePaths = logEntry.getLogEntryChangePaths();
            for (LogEntryChangePath changePath : changePaths) {
                if (changePath.getPath().equals(path) && changePath.getCopySrcPath() != null) {
                    try {
                        path = changePath.getCopySrcPath();
                        url = new SVNUrl(resource.getRepository().getRepositoryRoot().toString() + changePath.getCopySrcPath());
                    } catch (MalformedURLException e) {
                    }
                }
            }
        }
    }
    return url;
}
Also used : MalformedURLException(java.net.MalformedURLException) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) GetLogsCommand(org.tigris.subversion.subclipse.core.commands.GetLogsCommand) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision)

Aggregations

SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)83 SVNException (org.tigris.subversion.subclipse.core.SVNException)29 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)26 MalformedURLException (java.net.MalformedURLException)25 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)21 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)19 ParseException (java.text.ParseException)18 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)17 IResource (org.eclipse.core.resources.IResource)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)14 TeamException (org.eclipse.team.core.TeamException)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)13 ArrayList (java.util.ArrayList)12 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)12 File (java.io.File)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 RemoteFolder (org.tigris.subversion.subclipse.core.resources.RemoteFolder)8