Search in sources :

Example 6 with SVNConflictResolver

use of org.tigris.subversion.subclipse.ui.conflicts.SVNConflictResolver in project subclipse by subclipse.

the class OverrideAndUpdateSynchronizeOperation method run.

protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    if (!revertAndUpdate)
        return;
    if (!prompted) {
        getShell().getDisplay().syncExec(new Runnable() {

            public void run() {
                revertAndUpdate = MessageDialog.openQuestion(getShell(), Policy.bind("SyncAction.override.title"), // $NON-NLS-1$ //$NON-NLS-2$
                Policy.bind("SyncAction.override.confirm"));
            }
        });
        prompted = true;
    }
    if (!revertAndUpdate)
        return;
    IResource[] modifiedResourceArray = extractResources(modifiedResources, set);
    IResource[] resourceArray = extractResources(resources, set);
    if (modifiedResourceArray != null && modifiedResourceArray.length > 0) {
        monitor.beginTask(null, 100);
        try {
            new RevertResourcesCommand(provider.getSVNWorkspaceRoot(), modifiedResourceArray).run(Policy.subMonitorFor(monitor, 100));
        } catch (SVNException e) {
            collectStatus(e.getStatus());
        } finally {
            monitor.done();
        }
    }
    if (monitor.isCanceled()) {
        return;
    }
    SVNRevision revision = SVNRevision.HEAD;
    monitor.beginTask(null, 100);
    try {
        IResource[] incomingResources = getIncoming(resourceArray);
        SVNWorkspaceSubscriber.getInstance().updateRemote(incomingResources);
        if (changeSetSelected) {
            List<IResource> existingResources = new ArrayList<IResource>();
            for (IResource resource : incomingResources) {
                if (resource.exists()) {
                    existingResources.add(resource);
                } else {
                    UpdateResourcesCommand command = new UpdateResourcesCommand(provider.getSVNWorkspaceRoot(), new IResource[] { resource }, revision);
                    command.setConflictResolver(new SVNConflictResolver());
                    command.run(Policy.subMonitorFor(monitor, 100));
                }
            }
            if (!existingResources.isEmpty()) {
                IResource[] existingResourceArray = new IResource[existingResources.size()];
                existingResources.toArray(existingResourceArray);
                UpdateResourcesCommand command = new UpdateResourcesCommand(provider.getSVNWorkspaceRoot(), existingResourceArray, revision);
                command.setDepth(Depth.empty);
                command.setSetDepth(false);
                command.setConflictResolver(new SVNConflictResolver());
                command.run(Policy.subMonitorFor(monitor, 100));
            }
        } else {
            UpdateResourcesCommand command = new UpdateResourcesCommand(provider.getSVNWorkspaceRoot(), incomingResources, revision);
            command.setConflictResolver(new SVNConflictResolver());
            command.run(Policy.subMonitorFor(monitor, 100));
        }
    } catch (SVNException e) {
        collectStatus(e.getStatus());
    } catch (TeamException e) {
        collectStatus(e.getStatus());
    } finally {
        monitor.done();
    }
}
Also used : TeamException(org.eclipse.team.core.TeamException) RevertResourcesCommand(org.tigris.subversion.subclipse.core.commands.RevertResourcesCommand) ArrayList(java.util.ArrayList) UpdateResourcesCommand(org.tigris.subversion.subclipse.core.commands.UpdateResourcesCommand) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource) SVNConflictResolver(org.tigris.subversion.subclipse.ui.conflicts.SVNConflictResolver)

Example 7 with SVNConflictResolver

use of org.tigris.subversion.subclipse.ui.conflicts.SVNConflictResolver in project subclipse by subclipse.

the class UpdateOperation method execute.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.ui.operations.RepositoryProviderOperation#execute(org.tigris.subversion.subclipse.core.SVNTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
   */
protected void execute(SVNTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws SVNException, InterruptedException {
    monitor.beginTask(null, 100);
    try {
        if (conflictResolver != null && conflictResolver instanceof SVNConflictResolver) {
            ((SVNConflictResolver) conflictResolver).setPart(getPart());
        }
        SVNWorkspaceSubscriber.getInstance().updateRemote(resources);
        UpdateResourcesCommand command = new UpdateResourcesCommand(provider.getSVNWorkspaceRoot(), resources, revision);
        command.setDepth(depth);
        command.setSetDepth(setDepth);
        command.setIgnoreExternals(ignoreExternals);
        command.setForce(force);
        command.setConflictResolver(conflictResolver);
        command.run(Policy.subMonitorFor(monitor, 100));
    // updateWorkspaceSubscriber(provider, resources, Policy.subMonitorFor(monitor, 5));
    } catch (SVNException e) {
        if (e.operationInterrupted()) {
            showCancelledMessage();
        } else {
            collectStatus(e.getStatus());
        }
    } catch (TeamException e) {
        collectStatus(e.getStatus());
    } finally {
        SVNProviderPlugin.broadcastSyncInfoChanges(resources, false);
        monitor.done();
    }
}
Also used : TeamException(org.eclipse.team.core.TeamException) UpdateResourcesCommand(org.tigris.subversion.subclipse.core.commands.UpdateResourcesCommand) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNConflictResolver(org.tigris.subversion.svnclientadapter.ISVNConflictResolver) SVNConflictResolver(org.tigris.subversion.subclipse.ui.conflicts.SVNConflictResolver)

Aggregations

SVNConflictResolver (org.tigris.subversion.subclipse.ui.conflicts.SVNConflictResolver)7 TeamException (org.eclipse.team.core.TeamException)4 SVNException (org.tigris.subversion.subclipse.core.SVNException)4 ISVNConflictResolver (org.tigris.subversion.svnclientadapter.ISVNConflictResolver)4 ArrayList (java.util.ArrayList)3 IResource (org.eclipse.core.resources.IResource)3 UpdateResourcesCommand (org.tigris.subversion.subclipse.core.commands.UpdateResourcesCommand)3 ParseException (java.text.ParseException)2 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)2 MalformedURLException (java.net.MalformedURLException)1 IProject (org.eclipse.core.resources.IProject)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 RevertResourcesCommand (org.tigris.subversion.subclipse.core.commands.RevertResourcesCommand)1 SwitchToUrlCommand (org.tigris.subversion.subclipse.core.commands.SwitchToUrlCommand)1 SVNLightweightDecorator (org.tigris.subversion.subclipse.ui.decorator.SVNLightweightDecorator)1 UpdateOperation (org.tigris.subversion.subclipse.ui.operations.UpdateOperation)1 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)1