From 69fd42aee3f3fed8dbb5f2933413cbf31cac74d1 Mon Sep 17 00:00:00 2001
From: Prashant Sharma <scrapcodes@gmail.com>
Date: Sun, 15 Sep 2013 15:51:02 +0530
Subject: [PATCH] ported repl improvements from master

---
 .../main/scala/org/apache/spark/repl/SparkILoop.scala    | 4 ++++
 .../main/scala/org/apache/spark/repl/SparkImports.scala  | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/repl/src/main/scala/org/apache/spark/repl/SparkILoop.scala b/repl/src/main/scala/org/apache/spark/repl/SparkILoop.scala
index bd132c29bf..988b624feb 100644
--- a/repl/src/main/scala/org/apache/spark/repl/SparkILoop.scala
+++ b/repl/src/main/scala/org/apache/spark/repl/SparkILoop.scala
@@ -915,6 +915,10 @@ class SparkILoop(in0: Option[BufferedReader], protected val out: JPrintWriter,
   }
 
   def createSparkContext(): SparkContext = {
+   val uri = System.getenv("SPARK_EXECUTOR_URI")
+   if (uri != null) {
+         System.setProperty("spark.executor.uri", uri)
+   }
     val master = this.master match {
       case Some(m) => m
       case None => {
diff --git a/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala b/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
index a33f07a83e..64084209e8 100644
--- a/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
+++ b/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
@@ -185,8 +185,13 @@ trait SparkImports {
             if (currentImps contains imv) addWrapper()
             val objName = req.lineRep.readPath
             val valName = "$VAL" + newValId();
-            code.append("val " + valName + " = " + objName + ".INSTANCE;\n")
-            code.append("import " + valName + req.accessPath + ".`" + imv + "`;\n")
+            
+            if(!code.toString.endsWith(".`" + imv + "`;\n")) { // Which means already imported
+               code.append("val " + valName + " = " + objName + ".INSTANCE;\n")
+               code.append("import " + valName + req.accessPath + ".`" + imv + "`;\n")
+            }
+            // code.append("val " + valName + " = " + objName + ".INSTANCE;\n")
+            // code.append("import " + valName + req.accessPath + ".`" + imv + "`;\n")
             // code append ("import " + (req fullPath imv) + "\n")
             currentImps += imv
           }
-- 
GitLab