[meld] Silence stderr messages in git and svn file retrieval



commit 2d44cb6afb221eaab4e9f4d0795ae6d45a5d0365
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Dec 3 07:03:42 2012 +1000

    Silence stderr messages in git and svn file retrieval
    
    Since error messages were most often along the lines of "can't find the
    file because you just added it", the extra command-line debug logging
    just looked bad without adding information.

 meld/vc/git.py    |   11 +++++++++--
 meld/vc/svn_17.py |   11 +++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 82a634a..457f6f0 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -32,6 +32,7 @@ import errno
 import os
 import re
 import shutil
+import subprocess
 import tempfile
 
 from . import _vc
@@ -89,8 +90,14 @@ class Vc(_vc.CachedVc):
             raise _vc.InvalidVCPath(self, path, "Path not in repository")
         path = path[len(self.root) + 1:]
 
-        vc_file = _vc.popen(["git", "cat-file", "blob", commit + ":" + path],
-                            cwd=self.location)
+        obj = commit + ":" + path
+        process = subprocess.Popen(["git", "cat-file", "blob", obj],
+                                   cwd=self.location, stdout=subprocess.PIPE,
+                                   stderr=subprocess.PIPE)
+        vc_file = process.stdout
+
+        # Error handling here involves doing nothing; in most cases, the only
+        # sane response is to return an empty temp file.
 
         with tempfile.NamedTemporaryFile(prefix='meld-tmp', delete=False) as f:
             shutil.copyfileobj(vc_file, f)
diff --git a/meld/vc/svn_17.py b/meld/vc/svn_17.py
index 8133c10..6814ef6 100644
--- a/meld/vc/svn_17.py
+++ b/meld/vc/svn_17.py
@@ -23,6 +23,7 @@
 
 import os
 import shutil
+import subprocess
 import tempfile
 
 from . import _vc
@@ -47,8 +48,14 @@ class Vc(svn.Vc):
             raise _vc.InvalidVCPath(self, path, "Path not in repository")
         path = path[len(self.root) + 1:]
 
-        vc_file = _vc.popen([self.CMD, "cat", "-r", commit, path],
-                            cwd=self.location)
+        process = subprocess.Popen([self.CMD, "cat", "-r", commit, path],
+                                   cwd=self.location, stdout=subprocess.PIPE,
+                                   stderr=subprocess.PIPE)
+        vc_file = process.stdout
+
+        # Error handling here involves doing nothing; in most cases, the only
+        # sane response is to return an empty temp file. The most common error
+        # is "no base revision until committed" from diffing a new file.
 
         with tempfile.NamedTemporaryFile(prefix='meld-tmp', delete=False) as f:
             shutil.copyfileobj(vc_file, f)



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