You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/03/09 20:45:05 UTC

incubator-tinkerpop git commit: Allow :remote close to close even when in remote eval mode.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1096 b45366d1f -> 6e88249e2


Allow :remote close to close even when in remote eval mode.

It first exits remote eval and then executes the close operation on the remote.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/6e88249e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/6e88249e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/6e88249e

Branch: refs/heads/TINKERPOP-1096
Commit: 6e88249e20750996aa39fb7f806d1391a570a26c
Parents: b45366d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 9 14:44:19 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 9 14:44:19 2016 -0500

----------------------------------------------------------------------
 .../gremlin/console/commands/RemoteCommand.groovy         | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6e88249e/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
index 5662356..d192b7b 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
@@ -110,15 +110,23 @@ class RemoteCommand extends ComplexCommandSupport {
 
     def Object do_close = {
         if (mediator.remotes.size() == 0) return "Please add a remote first with [connect]"
+
+        // the console is in remote evaluation mode.  closing at this point will needs to exit that mode and then
+        // kill the remote itself
+        def line = !mediator.localEvaluation ? swapEvalautionMode() : ""
+
         def removed = mediator.removeCurrent()
         removed.close()
-        return "Removed - $removed"
+        return line.isEmpty() ? "Removed - $removed" : "$line and removed - $removed"
     }
 
     def Object do_console = {
         if (mediator.remotes.size() == 0) return "Please add a remote first with [connect]"
         if (!mediator.currentRemote().allowRemoteConsole()) return "The ${mediator.currentRemote()} is not compatible with 'connect' - use ':>' instead"
+        return swapEvalautionMode()
+    }
 
+    private String swapEvalautionMode() {
         mediator.localEvaluation = !mediator.localEvaluation
         if (mediator.localEvaluation)
             return "Exited remote console - all commands will be evaluated locally"