Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 87202 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java (+14 lines)
Lines 120-125 Link Here
120
	protected void performEdit(IFile[] files, IProgressMonitor monitor) throws CVSException {
120
	protected void performEdit(IFile[] files, IProgressMonitor monitor) throws CVSException {
121
		getProvider(files).edit(files, false /* recurse */, true /* notify server */, true /* notify for writtable files */, ICVSFile.NO_NOTIFICATION, monitor);
121
		getProvider(files).edit(files, false /* recurse */, true /* notify server */, true /* notify for writtable files */, ICVSFile.NO_NOTIFICATION, monitor);
122
	}
122
	}
123
    
124
    protected void performUpdate(IFile[] files, IProgressMonitor monitor) throws CVSException {
125
        getProvider(files).update(files, monitor);
126
    }
123
	
127
	
124
	private boolean needsCheckout(IFile file) {
128
	private boolean needsCheckout(IFile file) {
125
		try {
129
		try {
Lines 134-139 Link Here
134
		}
138
		}
135
		return false;
139
		return false;
136
	}
140
	}
141
    
142
    protected boolean needsUpdate(IFile file, IProgressMonitor monitor) {
143
        try {
144
            return getProvider(new IFile[]{file}).needsUpdate(file, monitor);
145
        } catch (CVSException e) {
146
            // Log the exception and assume we don't need to update it
147
            CVSProviderPlugin.log(e);
148
        }
149
        return false;
150
    }
137
	
151
	
138
	protected IStatus setWritable(final IFile[] files) {
152
	protected IStatus setWritable(final IFile[] files) {
139
        for (int i = 0; i < files.length; i++) {
153
        for (int i = 0; i < files.length; i++) {
(-)src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java (-2 / +122 lines)
Lines 30-37 Link Here
30
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
30
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
31
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
31
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
32
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
32
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
33
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
34
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
35
import org.eclipse.team.internal.ccvs.core.util.*;
33
import org.eclipse.team.internal.ccvs.core.util.*;
36
import org.eclipse.team.internal.core.streams.CRLFtoLFInputStream;
34
import org.eclipse.team.internal.core.streams.CRLFtoLFInputStream;
37
import org.eclipse.team.internal.core.streams.LFtoCRLFInputStream;
35
import org.eclipse.team.internal.core.streams.LFtoCRLFInputStream;
Lines 996-999 Link Here
996
	public IResourceRuleFactory getRuleFactory() {
994
	public IResourceRuleFactory getRuleFactory() {
997
		return RESOURCE_RULE_FACTORY;
995
		return RESOURCE_RULE_FACTORY;
998
	}
996
	}
997
998
    /**
999
     * Determine if this file needs updated by calling the <code>cvs status</code> command.
1000
     * 
1001
     * @author <a href="mailto:gregor.kohlwes@csc.com,kohlwes@gmx.net">Gregor Kohlwes</a>
1002
     * @param resources
1003
     * @param progress
1004
     * @return IEditorsInfo[]
1005
     * @throws CVSException
1006
     */
1007
    public boolean needsUpdate(
1008
        IFile resource,
1009
        IProgressMonitor progress)
1010
        throws CVSException {
1011
1012
        // Build the local options
1013
        LocalOption[] commandOptions = new LocalOption[] { Command.DO_NOT_RECURSE };
1014
        progress.worked(10);
1015
        // Build the arguments list
1016
        String[] arguments = getValidArguments(new IResource[]{resource}, commandOptions);
1017
1018
        // Build the listener for the command
1019
        final String[] revision = new String[1];
1020
        IStatusListener listener = new IStatusListener(){
1021
            public void fileStatus(ICVSFolder commandRoot, String path, String remoteRevision) {
1022
                revision[0] = remoteRevision;
1023
            }
1024
        };
1025
1026
        // Check if canceled
1027
        if (progress.isCanceled()) {
1028
            return false;
1029
        }
1030
        // Build the session
1031
        Session session =
1032
            new Session(
1033
                workspaceRoot.getRemoteLocation(),
1034
                workspaceRoot.getLocalRoot());
1035
1036
        // Check if canceled
1037
        if (progress.isCanceled()) {
1038
            return false;
1039
        }
1040
        progress.beginTask(null, 100);
1041
        try {
1042
            // Opening the session takes 20% of the time
1043
            session.open(Policy.subMonitorFor(progress, 20), false /* read-only */);
1044
1045
            if (!progress.isCanceled()) {
1046
                // Execute the editors command
1047
                Command.UP_TO_DATE.execute(
1048
                    session,
1049
                    Command.NO_GLOBAL_OPTIONS,
1050
                    commandOptions,
1051
                    arguments,
1052
                    new StatusListener(listener),
1053
                    Policy.subMonitorFor(progress, 80));
1054
            }
1055
        } finally {
1056
            session.close();
1057
            progress.done();
1058
        }
1059
        // Return whether this file needs updated
1060
        ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(resource);
1061
        return !cvsFile.getSyncInfo().getRevision().equals(revision[0]);
1062
    }
1063
1064
    /**
1065
     * Update the resources by calling the <code>cvs update</code> command.
1066
     * 
1067
     * @author <a href="mailto:gregor.kohlwes@csc.com,kohlwes@gmx.net">Gregor Kohlwes</a>
1068
     * @param resources
1069
     * @param progress
1070
     * @return IEditorsInfo[]
1071
     * @throws CVSException
1072
     */
1073
    public void update(
1074
        IResource[] resources,
1075
        IProgressMonitor progress)
1076
        throws CVSException {
1077
1078
        // Build the local options
1079
        LocalOption[] commandOptions = new LocalOption[] { Command.DO_NOT_RECURSE };
1080
        progress.worked(10);
1081
        // Build the arguments list
1082
        String[] arguments = getValidArguments(resources, commandOptions);
1083
1084
        // Check if canceled
1085
        if (progress.isCanceled()) {
1086
            return;
1087
        }
1088
        // Build the session
1089
        Session session =
1090
            new Session(
1091
                workspaceRoot.getRemoteLocation(),
1092
                workspaceRoot.getLocalRoot());
1093
1094
        // Check if canceled
1095
        if (progress.isCanceled()) {
1096
            return;
1097
        }
1098
        progress.beginTask(null, 100);
1099
        try {
1100
            // Opening the session takes 20% of the time
1101
            session.open(Policy.subMonitorFor(progress, 20), false /* read-only */);
1102
1103
            if (!progress.isCanceled()) {
1104
                // Execute the update command locking on the first resource
1105
                Command.UPDATE.execute(
1106
                    session,
1107
                    resources[0],
1108
                    Command.NO_GLOBAL_OPTIONS,
1109
                    commandOptions,
1110
                    arguments,
1111
                    null,
1112
                    Policy.subMonitorFor(progress, 80));
1113
            }
1114
        } finally {
1115
            session.close();
1116
            progress.done();
1117
        }
1118
    }
999
}
1119
}
(-)src/org/eclipse/team/internal/ccvs/core/client/Command.java (+91 lines)
Lines 14-23 Link Here
14
14
15
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IWorkspaceRunnable;
18
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.runtime.*;
19
import org.eclipse.core.runtime.*;
20
import org.eclipse.core.runtime.jobs.ISchedulingRule;
18
import org.eclipse.osgi.util.NLS;
21
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.team.internal.ccvs.core.*;
22
import org.eclipse.team.internal.ccvs.core.*;
20
import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
23
import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
24
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
21
25
22
/**
26
/**
23
 * Abstract base class for command requests.
27
 * Abstract base class for command requests.
Lines 37-42 Link Here
37
	public final static Log LOG = new Log();
41
	public final static Log LOG = new Log();
38
	public final static Remove REMOVE = new Remove();
42
	public final static Remove REMOVE = new Remove();
39
	public final static Status STATUS = new Status();
43
	public final static Status STATUS = new Status();
44
    public final static Status UP_TO_DATE = new StatusUpdateCheck();
40
	public final static Tag TAG = new Tag();
45
	public final static Tag TAG = new Tag();
41
	// The CUSTOM_TAG command has special handling for added and removed resources.
46
	// The CUSTOM_TAG command has special handling for added and removed resources.
42
	// This behavior supports branching with local changes in the workspace
47
	// This behavior supports branching with local changes in the workspace
Lines 339-344 Link Here
339
		return status[0];
344
		return status[0];
340
	}
345
	}
341
	
346
	
347
    /**
348
     * Executes a CVS command.
349
     * <p>
350
     * Dispatches the commands, retrieves the results, and determines whether or
351
     * not an error occurred.  A listener may be supplied to capture message text
352
     * that would normally be written to the standard error and standard output
353
     * streams of a command line CVS client.
354
     * </p>
355
     * @param session the open CVS session
356
     * @param schedulingRule the scheduling rule to use when executing this command
357
     * @param globalOptions the array of global options, or NO_GLOBAL_OPTIONS
358
     * @param localOptions the array of local options, or NO_LOCAL_OPTIONS
359
     * @param arguments the array of arguments (usually filenames relative to localRoot), or NO_ARGUMENTS
360
     * @param listener the command output listener, or null to discard all messages
361
     * @param monitor the progress monitor
362
     * @return a status code indicating success or failure of the operation
363
     * @throws CVSException if a fatal error occurs (e.g. connection timeout)
364
     */
365
    public final IStatus execute(final Session session, ISchedulingRule schedulingRule, final GlobalOption[] globalOptions,
366
        final LocalOption[] localOptions, final String[] arguments, final ICommandOutputListener listener,
367
        IProgressMonitor pm) throws CVSException {      
368
        final IStatus[] status = new IStatus[1];
369
        ICVSRunnable job = new ICVSRunnable() {
370
            public void run(IProgressMonitor monitor) throws CVSException {
371
                // update the global and local options
372
                GlobalOption[] gOptions = filterGlobalOptions(session, globalOptions);
373
                LocalOption[] lOptions = filterLocalOptions(session, gOptions, localOptions);
374
                
375
                // print the invocation string to the console
376
                if (session.isOutputToConsole() || Policy.isDebugProtocol()) {
377
                    IPath commandRootPath;
378
                    IResource resource = session.getLocalRoot().getIResource();
379
                    if (resource == null) {
380
                        commandRootPath = Path.EMPTY;
381
                    } else {
382
                        commandRootPath = resource.getFullPath();
383
                    }
384
                    String line = constructCommandInvocationString(commandRootPath, gOptions, lOptions, arguments);
385
                    ConsoleListeners.getInstance().commandInvoked(session, line);
386
                    if (Policy.isDebugProtocol()) Policy.printProtocolLine("CMD> " + line); //$NON-NLS-1$
387
                }
388
                
389
                // run the command
390
                try {
391
                    session.setCurrentCommand(Command.this);
392
                    status[0] = doExecute(session, gOptions, lOptions, arguments, listener, monitor);
393
                    notifyConsoleOnCompletion(session, status[0], null);
394
                } catch (CVSException e) {
395
                    notifyConsoleOnCompletion(session, null, e);
396
                    throw e;
397
                } catch (RuntimeException e) {
398
                    notifyConsoleOnCompletion(session, null, e);
399
                    throw e;
400
                }
401
            }
402
        };
403
        if (isWorkspaceModification()) {
404
            run(schedulingRule, job, pm);
405
        } else {
406
            job.run(pm);
407
        }
408
        return status[0];
409
    }
410
411
    public void run(final ISchedulingRule schedulingRule, final ICVSRunnable job, IProgressMonitor monitor) throws CVSException {
412
        final CVSException[] error = new CVSException[1];
413
        try {
414
            // Do not use a scheduling rule in the workspace run since one
415
            // will be obtained by the EclipseSynchronizer
416
            ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
417
                public void run(IProgressMonitor monitor) throws CoreException {
418
                    try {
419
                        EclipseSynchronizer.getInstance().run(schedulingRule, job, monitor);
420
                    } catch(CVSException e) {
421
                        error[0] = e; 
422
                    }
423
                }
424
            }, null /* no rule */, 0, monitor);
425
        } catch(CoreException e) {
426
            throw CVSException.wrapException(e);
427
        }
428
        if(error[0]!=null) {
429
            throw error[0];
430
        }
431
    }
432
342
	/**
433
	/**
343
	 * Return whether this command modifies the workspace.
434
	 * Return whether this command modifies the workspace.
344
	 * If <code>true</code> is returned, a scheduling rule on
435
	 * If <code>true</code> is returned, a scheduling rule on
(-)src/org/eclipse/team/internal/ccvs/core/client/StatusUpdateCheck.java (+22 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2003 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.internal.ccvs.core.client;
12
13
14
public class StatusUpdateCheck extends Status {
15
	/*** Local options: specific to status ***/
16
17
	protected StatusUpdateCheck() { }
18
19
    protected boolean isWorkspaceModification() {
20
        return false;
21
    }
22
}

Return to bug 87202