Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8d662ced17a1061551013d86602924a9baa8e74d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*******************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.internal.ccvs.core.client;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;

/**
 * A specialized update that will ignore unmanaged local content.
 * It is the same os CheckoutWithOverwrite.
 */
public class UpdateWithOverwrite extends Update {

	/**
	 * This class overrides the "Created" handler but uses the "Updated"
	 * behavior which will overwrite existing files.
	 */
	public class CreatedResponseHandler extends UpdatedHandler {
		public CreatedResponseHandler() {
			super(UpdatedHandler.HANDLE_UPDATED);
		}
		public String getResponseID() {
			return "Created"; //$NON-NLS-1$
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], java.lang.String[], org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor)
	 */
	protected IStatus doExecute(
			Session session,
			GlobalOption[] globalOptions,
			LocalOption[] localOptions,
			String[] arguments,
			ICommandOutputListener listener,
			IProgressMonitor monitor)
	throws CVSException {
		
		ResponseHandler newCreated = new CreatedResponseHandler();
		ResponseHandler oldCreated = session.getResponseHandler(newCreated.getResponseID());
		session.registerResponseHandler(newCreated);
		try {
			return super.doExecute(
					session,
					globalOptions,
					localOptions,
					arguments,
					listener,
					monitor);
		} finally {
			session.registerResponseHandler(oldCreated);
		}
	}
}

Back to the top