/*******************************************************************************
 * Copyright (c) 2005-2008 VecTrace (Zingo Andersen) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * 		bastian	implementation
 * 		Andrei Loskutov - bug fixes
 *******************************************************************************/
package com.vectrace.MercurialEclipse.commands.extensions.mq;

import org.eclipse.core.runtime.Assert;

import com.vectrace.MercurialEclipse.commands.AbstractClient;
import com.vectrace.MercurialEclipse.commands.AbstractShellCommand;
import com.vectrace.MercurialEclipse.commands.HgCommand;
import com.vectrace.MercurialEclipse.exception.HgException;
import com.vectrace.MercurialEclipse.model.HgRoot;

/**
 * @author bastian
 */
public class HgQPopClient extends AbstractClient {
	public static String popAll(HgRoot root, boolean force)
			throws HgException {
		Assert.isNotNull(root);
		AbstractShellCommand command = new HgCommand("qpop", //$NON-NLS-1$
				"Invoking qpop", root, true);
		command.setExecutionRule(new AbstractShellCommand.ExclusiveExecutionRule(root));

		command.addOptions("--config", "extensions.hgext.mq="); //$NON-NLS-1$ //$NON-NLS-2$

		command.addOptions("-a"); //$NON-NLS-1$
		if (force) {
			command.addOptions("--force"); //$NON-NLS-1$
		}
		return command.executeToString();
	}

	public static String pop(HgRoot root, boolean force, String patchName)
			throws HgException {
		AbstractShellCommand command = new HgCommand("qpop", //$NON-NLS-1$
				"Invoking qpop", root, true);
		command.setExecutionRule(new AbstractShellCommand.ExclusiveExecutionRule(root));

		command.addOptions("--config", "extensions.hgext.mq="); //$NON-NLS-1$ //$NON-NLS-2$

		if (force) {
			command.addOptions("--force"); //$NON-NLS-1$
		}

		if (!"".equals(patchName)) { //$NON-NLS-1$
			command.addOptions(patchName);
		}
		return command.executeToString();
	}
}

@@ -622,42 +622,56 @@
 ort 
-org.eclipse.core.runtime.Assert
+com.aragost.javahg.commands.ExecutionException
 ;%0A
-%0A
 impo
@@ -681,125 +681,98 @@
 com.
-vectrace.MercurialEclipse.commands.AbstractClient;%0Aimport com.vectrace.MercurialEclipse.commands.AbstractShell
+aragost.javahg.ext.mq.QPopCommand;%0Aimport com.aragost.javahg.ext.mq.flags.QPop
 Command
+Flags
 ;%0Aim
@@ -815,25 +815,30 @@
 ommands.
-HgCommand
+AbstractClient
 ;%0Aimport
@@ -1032,30 +1032,28 @@
 blic static 
-String
+void
  popAll(HgRo
@@ -1075,20 +1075,17 @@
 n force)
-%0A%09%09%09
+ 
 throws H
@@ -1101,49 +1101,15 @@
 n %7B%0A
-%09%09Assert.isNotNull(root);%0A%09%09AbstractShell
+%0A%09%09QPop
 Comm
@@ -1126,290 +1126,69 @@
 d = 
-new Hg
+QPop
 Command
-(%22qpop%22, //$NON-NLS-1$%0A%09%09%09%09%22Invoking qpop%22, root, true);%0A%09%09command.setExecutionRule(new AbstractShellCommand.ExclusiveExecutionRule(root));%0A%0A%09%09command.addOptions(%22--config%22, %22extensions.hgext.mq=%22); //$NON-NLS-1$ //$NON-NLS-2$%0A%0A%09%09command.addOptions(%22-a%22); //$NON-NLS-1$
+Flags.on(root.getRepository());%0A%0A%09%09command.all();%0A
 %0A%09%09i
@@ -1214,58 +1214,33 @@
 and.
-addOptions(%22--
 force
-%22
+(
 );
- //$NON-NLS-1$
 %0A%09%09%7D%0A
+%0A
 %09%09
-return 
+try %7B%0A%09%09%09
 comm
@@ -1246,35 +1246,123 @@
 mand.execute
-ToString();
+();%0A%09%09%7D catch (ExecutionException ee) %7B%0A%09%09%09throw new HgException(ee.getLocalizedMessage(), ee);%0A%09%09%7D
 %0A%09%7D%0A%0A%09public
@@ -1369,22 +1369,20 @@
  static 
-String
+void
  pop(HgR
@@ -1423,20 +1423,17 @@
 tchName)
-%0A%09%09%09
+ 
 throws H
@@ -1447,29 +1447,20 @@
 ion %7B%0A%09%09
-AbstractShell
+QPop
 Command 
@@ -1473,247 +1473,50 @@
 d = 
-new HgCommand(%22qpop%22, //$NON-NLS-1$%0A%09%09%09%09%22Invoking qpop%22, root, true);%0A%09%09command.setExecutionRule(new AbstractShellCommand.ExclusiveExecutionRule(root));%0A%0A%09%09command.addOptions(%22--config%22, %22extensions.hgext.mq=%22); //$NON-NLS-1$ //$NON-NLS-2$
+QPopCommandFlags.on(root.getRepository());
 %0A%0A%09%09
@@ -1543,50 +1543,31 @@
 and.
-addOptions(%22--
 force
-%22); //$NON-NLS-1$%0A%09%09%7D%0A%0A
+();%0A%09%09%7D%0A%0A%09%09try %7B%0A%09
 %09%09if
@@ -1610,24 +1610,25 @@
 S-1$%0A%09%09%09
+%09
 command.
 addOptio
@@ -1623,18 +1623,15 @@
 and.
-addOptions
+execute
 (pat
@@ -1645,19 +1645,22 @@
 ;%0A%09%09
-%7D%0A%09%09return 
+%09%7D else %7B%0A%09%09%09%09
 comm
@@ -1674,19 +1674,112 @@
 cute
-ToString();
+();%0A%09%09%09%7D%0A%09%09%7D catch (ExecutionException ee) %7B%0A%09%09%09throw new HgException(ee.getLocalizedMessage(), ee);%0A%09%09%7D
 %0A%09%7D%0A

Use JavaHg for QPop