[BUG] Difference bridge does not patch

Michael Allan mike at zelea.com
Wed Oct 24 02:54:45 EDT 2012


> ... The temporary directory of tomcat containing the position files
> is /tmp/tomcat6-tomcat6-tmp. What is it for you?

  patchFile.getPath() =
    /var/tmp/tomcat-6/WP_D_patch1185637321458787331.533

-------------------------------
@@ -25,6 +25,7 @@
 import org.apache.wicket.markup.repeater.RepeatingView;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.util.io.IOUtils;
 import votorola.g._.*;
 import votorola.a.*;
 import votorola.a.count.*;
@@ -1098,7 +1099,8 @@
                     final ProcessBuilder pB = new ProcessBuilder( "/bin/bash", "-c",
                       "patch --force --no-backup-if-mismatch --unified "
                       + (isReversePatch? "--reverse ": "")
-                      + targetFile.getName() + " " + patchFile.getName() + " 2>&1" );
+                      + targetFile.getName() + " " + patchFile.getName() /*+ " 2>&1"*/ );
+                    pB.directory(patchFile.getParentFile());
                     logger.fine( "calling out to OS: " + pB.command() );
                     final Process p = pB.start();
                     outB.append( "PATCHING" ).append( '\n' );
@@ -1114,7 +1116,10 @@
                           outB.toString() ).pre());
                         return;
                     }
-                    else if( exitValue != 0 ) throw new IOException( "exit value of " + exitValue + " from process: " + pB.command() );
+                    else if( exitValue != 0 ) {
+                        final String err = IOUtils.toString(p.getErrorStream());
+                        throw new IOException( "exit value of " + exitValue + " from process: " + pB.command() + " : " + err);
+                    }
                 }
-------------------------------

I agree with the basic fix, which is just this line:

+                    pB.directory(patchFile.getParentFile());

But please (!) use bracket style to match rest of file. :-)

> Ok, I have patched WP_D to report the stderr result of the patch
> command in the exception. ...

Except we still need stderr redirected to outB.  That's why I went
through BASH.

   "patch's exit status is 0 if all hunks are applied successfully, 1
   if some hunks cannot be applied or there were merge conflicts, and
   2 if there is more serious trouble."  patch(1)

Usually it fails normally (1) and the stderr message goes to outB for
the user to read.  In your case (2), it instead throws an exception.
So maybe append outB.toString() to the exception?  Does that work?

And maybe comment the exitValue block with the manpage quote above?

Mike

PS, don't forget to add your name to the copyright when making
troublesome fixes like this.  Please follow this format:
http://zelea.com/project/votorola/contributors.xht#acknowledgment

PPS, your patch attached as binary and was difficult to read.

> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: fix-patch-process-directory.patch
> Type: text/x-patch
> Size: 1781 bytes
> Desc: not available
> URL: <http://mail.zelea.com/list/votorola/attachments/20121024/d3f7d829/attachment.bin>
> _______________________________________________


conseo said:
> Hey Mike,
> 
> > 
> > The patch command is built up here:
> > http://zelea.com/var/db/repo/votorola/file/796d661dea6c/votorola/s/wic/diff/
> > WP_D.java#l1098
> > 
> > The command itself is spit to the tomcat log.  You should see the file
> > names there.  Try re-executing the command manually, see what's wrong.
> 
> Ok, I have patched WP_D to report the stderr result of the patch command in 
> the exception. I have then found out that the patch command is run in the 
> wrong directory and have set it explicitly to the parent directory of the 
> patch file. The temporary directory of tomcat containing the position files is 
> /tmp/tomcat6-tomcat6-tmp. What is it for you?
> 
> conseo



More information about the Votorola mailing list