[PATCH] Be more verbose when patch invocation fails



misc.write_pipe() will now return both the exit code and the error
message which might be given on stderr. Both will be printed upon
failure. This function is not being used elsewhere, so it is safe to
change the return value.
---
 misc.py   |    6 +++---
 vcview.py |    8 +++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/misc.py b/misc.py
index 8b1dee8..6f3514c 100644
--- a/misc.py
+++ b/misc.py
@@ -238,9 +238,9 @@ def read_pipe_iter(command, errorstream, yield_interval=0.1, workdir=None):
 def write_pipe(command, text):
     """Write 'text' into a shell command.
     """
-    proc = subprocess.Popen(command, stdin=subprocess.PIPE)
-    proc.communicate(text)
-    return proc.wait()
+    proc = subprocess.Popen(command, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
+    err = proc.communicate(text)[1]
+    return err, proc.wait()
 
 def clamp(val, lower, upper):
     """Clamp 'val' to the inclusive range [lower,upper].
diff --git a/vcview.py b/vcview.py
index b4c6070..3560c6b 100644
--- a/vcview.py
+++ b/vcview.py
@@ -497,7 +497,8 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
             diffs.append( (destfile, pathtofile) )
 
         patchcmd = self.vc.patch_command( tmpdir )
-        if misc.write_pipe(patchcmd, patch) == 0:
+        err, ret = misc.write_pipe(patchcmd, patch)
+        if ret == 0:
             for d in diffs:
                 self.emit("create-diff", d)
         else:
@@ -508,6 +509,9 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
                     Maybe you don't have 'GNU patch' installed,
                     or you use an untested version of %s.
                     
+                    Exit code %d, error message:
+                    %s
+                    
                     Please send email bug report to:
                     meld-list gnome org
                     
@@ -519,6 +523,8 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
                     - the output of '%s somefile.txt'
                     - patch command: '%s'
                     """) % (self.vc.NAME,
+                            ret,
+                            err,
                             meldapp.version,
                             self.vc.NAME,
                             " ".join(self.vc.diff_command()),
-- 
1.6.3.3



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