[meld] Move shelljoin from misc to vc and simplify



commit 3a707e81388c4d143bb9accd4afb094b8b263d9e
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Aug 17 15:29:37 2013 +1000

    Move shelljoin from misc to vc and simplify

 meld/misc.py   |    8 --------
 meld/vcview.py |   10 ++++++++--
 2 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/meld/misc.py b/meld/misc.py
index 8af8a26..be2fc30 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -32,8 +32,6 @@ import gobject
 import gtk
 
 
-whitespace_re = re.compile(r"\s")
-
 if os.name != "nt":
     from select import select
 else:
@@ -44,12 +42,6 @@ else:
         return rlist, wlist, xlist
 
 
-def shelljoin( command ):
-    def quote(s):
-        return ((whitespace_re.search(s) is None) and s or ('"%s"' % s))
-    return " ".join( [ quote(x) for x in command ] )
-
-
 def error_dialog(primary, secondary, parent=None, messagetype=gtk.MESSAGE_ERROR):
     """A common error dialog handler for Meld
 
diff --git a/meld/vcview.py b/meld/vcview.py
index 50b5318..3c5ea90 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -625,7 +625,13 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         """Run 'command' on 'files'. Return a tuple of the directory the
            command was executed in and the output of the command.
         """
-        msg = misc.shelljoin(command)
+
+        def shelljoin(command):
+            def quote(s):
+                return '"%s"' % s if len(s.split()) > 1 else s
+            return " ".join(quote(tok) for tok in command)
+
+        msg = shelljoin(command)
         yield "[%s] %s" % (self.label_text, msg.replace("\n", "\t"))
         def relpath(pbase, p):
             kill = 0
@@ -640,7 +646,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
             workdir = self.vc.get_working_directory(_commonprefix(files))
         files = [relpath(workdir, f) for f in files]
         r = None
-        self.consolestream.command(misc.shelljoin(command + files) + " (in %s)\n" % workdir)
+        self.consolestream.command(shelljoin(command + files) + " (in %s)\n" % workdir)
         readiter = misc.read_pipe_iter(command + files, self.consolestream,
                                        workdir=workdir)
         try:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]