Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Borowitz2012-02-27 20:15:49 +0000
committerShawn O. Pearce2012-03-01 03:09:24 +0000
commitd023f2c78bb18ae81817436fb592cd51283eede4 (patch)
treedc0070a7730921f12cc8848f1ee330f3f0e8169c
parent903e1b81d43af97e9aff611c77e82cb0969530d8 (diff)
downloadjgit-d023f2c78bb18ae81817436fb592cd51283eede4.tar.gz
jgit-d023f2c78bb18ae81817436fb592cd51283eede4.tar.xz
jgit-d023f2c78bb18ae81817436fb592cd51283eede4.zip
Extract filterCommands as a static method on ReceiveCommand
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java22
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java19
2 files changed, 28 insertions, 13 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
index a1788d1282..b5ee206eb0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
@@ -45,6 +45,8 @@ package org.eclipse.jgit.transport;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.lib.ObjectId;
@@ -120,6 +122,26 @@ public class ReceiveCommand {
OK;
}
+ /**
+ * Filter a list of commands according to result.
+ *
+ * @param commands
+ * commands to filter.
+ * @param want
+ * desired status to filter by.
+ * @return a copy of the command list containing only those commands with the
+ * desired status.
+ */
+ public static List<ReceiveCommand> filter(List<ReceiveCommand> commands,
+ final Result want) {
+ List<ReceiveCommand> r = new ArrayList<ReceiveCommand>(commands.size());
+ for (final ReceiveCommand cmd : commands) {
+ if (cmd.getResult() == want)
+ r.add(cmd);
+ }
+ return r;
+ }
+
private final ObjectId oldId;
private final ObjectId newId;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
index 0d79110289..fd57308d7d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
@@ -821,7 +821,8 @@ public class ReceivePack {
});
}
- postReceive.onPostReceive(this, filterCommands(Result.OK));
+ postReceive.onPostReceive(this,
+ ReceiveCommand.filter(commands, Result.OK));
if (unpackError != null)
throw new UnpackException(unpackError);
@@ -1165,9 +1166,11 @@ public class ReceivePack {
}
private void executeCommands() {
- preReceive.onPreReceive(this, filterCommands(Result.NOT_ATTEMPTED));
+ preReceive.onPreReceive(this,
+ ReceiveCommand.filter(commands, Result.NOT_ATTEMPTED));
- List<ReceiveCommand> toApply = filterCommands(Result.NOT_ATTEMPTED);
+ List<ReceiveCommand> toApply = ReceiveCommand.filter(commands,
+ Result.NOT_ATTEMPTED);
ProgressMonitor updating = NullProgressMonitor.INSTANCE;
if (sideBand) {
SideBandProgressMonitor pm = new SideBandProgressMonitor(msgOut);
@@ -1182,16 +1185,6 @@ public class ReceivePack {
updating.endTask();
}
- private List<ReceiveCommand> filterCommands(final Result want) {
- final List<ReceiveCommand> r = new ArrayList<ReceiveCommand>(commands
- .size());
- for (final ReceiveCommand cmd : commands) {
- if (cmd.getResult() == want)
- r.add(cmd);
- }
- return r;
- }
-
private void sendStatusReport(final boolean forClient, final Reporter out)
throws IOException {
if (unpackError != null) {

Back to the top