498906: ChangeActivityHandleOperation should do nothing if no handles
have changed

Change-Id: If5a1ca24a1d965b6b62bbffd7ca137f24bae7772
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=498906
diff --git a/org.eclipse.mylyn.context.tasks.ui/src/org/eclipse/mylyn/internal/context/tasks/ui/ChangeActivityHandleOperation.java b/org.eclipse.mylyn.context.tasks.ui/src/org/eclipse/mylyn/internal/context/tasks/ui/ChangeActivityHandleOperation.java
index d4ca4e9..ef43e79 100644
--- a/org.eclipse.mylyn.context.tasks.ui/src/org/eclipse/mylyn/internal/context/tasks/ui/ChangeActivityHandleOperation.java
+++ b/org.eclipse.mylyn.context.tasks.ui/src/org/eclipse/mylyn/internal/context/tasks/ui/ChangeActivityHandleOperation.java
@@ -15,6 +15,8 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -45,8 +47,15 @@
 	@Override
 	protected void operations(IProgressMonitor monitor)
 			throws CoreException, InvocationTargetException, InterruptedException {
+		Map<String, String> changedHandles = handles.entrySet()
+				.stream()
+				.filter(e -> !e.getKey().equals(e.getValue()))
+				.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+		if (changedHandles.isEmpty()) {
+			return;
+		}
 		try {
-			refactorMetaContextHandles(handles, monitor);
+			refactorMetaContextHandles(changedHandles, monitor);
 			TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
 		} finally {
 			monitor.done();