|
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 |