/*******************************************************************************
 * Copyright (c) 2000, 2004 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.tigris.subversion.subclipse.ui.subscriber;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.tigris.subversion.subclipse.core.ISVNRemoteResource;
import org.tigris.subversion.subclipse.core.SVNTeamProvider;
import org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo;
import org.tigris.subversion.subclipse.ui.operations.UpdateOperation;
import org.tigris.subversion.svnclientadapter.SVNRevision;

public class UpdateSynchronizeOperation extends SVNSynchronizeOperation {
	private IResource[] resources;
	
	public UpdateSynchronizeOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements, IResource[] resources) {
		super(configuration, elements);
		this.resources = resources;
	}

	protected boolean promptForConflictHandling(Shell shell, SyncInfoSet syncSet) {
		return true;
	}

	protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
		IResource[] resourceArray = extractResources(resources, set);
		SVNRevision revision = null;
		SyncInfo[] syncInfos = set.getSyncInfos();
		for (int i = 0; i < syncInfos.length; i++) {
			SVNStatusSyncInfo syncInfo = (SVNStatusSyncInfo)syncInfos[i];
			IResourceVariant remote = syncInfo.getRemote();
			if (remote != null && remote instanceof ISVNRemoteResource) {
				SVNRevision rev = ((ISVNRemoteResource)remote).getLastChangedRevision();
				if (rev instanceof SVNRevision.Number) {
					long nbr = ((SVNRevision.Number)rev).getNumber();
					if (revision == null) revision = rev;
					else {
						long revisionNumber = ((SVNRevision.Number)revision).getNumber();
						if (nbr > revisionNumber) revision = rev;
					}
				}
			}
		}
		if (revision == null) revision = SVNRevision.HEAD;
		new UpdateOperation(getPart(), resourceArray, revision, true).run();
	}

}

@@ -2040,16 +2040,419 @@
 = null;%0A
+%09%09// If any folders are selected, we will update to HEAD so as%0A%09%09// to not back-revision any committed files which could be at%0A%09%09// a higher rev than the selected files%0A%09%09for (int i = 0; i %3C resourceArray.length; i++) %7B%0A            if (resourceArray%5Bi%5D.getType() != IResource.FILE) %7B%0A                revision = SVNRevision.HEAD;%0A                break;%0A            %7D%0A        %7D%0A%09%09if (revision == null) %7B%0A%09
 %09%09SyncIn
@@ -2490,16 +2490,17 @@
 os();%0A%09%09
+%09
 for (int
@@ -2532,24 +2532,25 @@
 gth; i++) %7B%0A
+%09
 %09%09%09SVNStatus
@@ -2602,16 +2602,17 @@
 fos%5Bi%5D;%0A
+%09
 %09%09%09IReso
@@ -2657,16 +2657,17 @@
 e();%0A%09%09%09
+%09
 if (remo
@@ -2716,24 +2716,25 @@
 Resource) %7B%0A
+%09
 %09%09%09%09SVNRevis
@@ -2794,24 +2794,25 @@
 Revision();%0A
+%09
 %09%09%09%09if (rev 
@@ -2845,24 +2845,25 @@
 ber) %7B%0A%09%09%09%09%09
+%09
 long nbr = (
@@ -2901,24 +2901,25 @@
 ber();%0A%09%09%09%09%09
+%09
 if (revision
@@ -2953,15 +2953,17 @@
 %09%09%09%09
+%09
 else %7B%0A
+%09
 %09%09%09%09
@@ -3032,24 +3032,25 @@
 er();%0A%09%09%09%09%09%09
+%09
 if (nbr %3E re
@@ -3075,24 +3075,32 @@
 sion = rev;%0A
+%09%09%09%09%09%09%7D%0A
 %09%09%09%09%09%7D%0A%09%09%09%09%7D

Modify the Update action from Synch view so that it updates to the HEAD revision if a folder is selected. If just specific files are selected then it still updates to the highest revision of the selected files.