[meld: 59/60] vc._vc: Add binary output support to Vc.run()



commit 47e95cd9652df91fe1b497bad1bc2266f1f14513
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Jul 30 08:09:14 2016 +1000

    vc._vc: Add binary output support to Vc.run()

 meld/vc/_vc.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index d0499e1..61130e7 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -144,18 +144,22 @@ class Vc(object):
         self._tree_meta_cache = {}
         self._tree_missing_cache = collections.defaultdict(set)
 
-    def run(self, *args):
+    def run(self, *args, use_locale_encoding=True):
         """Return subprocess running VC with `args` at VC's location
 
         For example, `git_vc.run('log', '-p')` will run `git log -p`
         and return the subprocess object.
 
+        If use_locale_encoding is True, the return value is a unicode
+        text stream with universal newlines. If use_locale_encoding is
+        False, the return value is a binary stream.
+
         Note that this runs at the *location*, not at the *root*.
         """
         cmd = (self.CMD,) + args
         return subprocess.Popen(
             cmd, cwd=self.location, stdout=subprocess.PIPE,
-            universal_newlines=True)
+            universal_newlines=use_locale_encoding)
 
     def get_files_to_commit(self, paths):
         """Get a list of files that will be committed from paths


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