tags:

views:

784

answers:

6

The patch is for nutch0.9: http://cvs.tty.org/~butch/blog/nutch_0.9_OR.patch

how should I apply the patch correctly?

OS is windows XP

More specifically,I'm using eclipse to debug nutch project.

Here is my trial:

D:\nutch-0.9.bak>patch -p0 < nutch_0.9_OR.patch
Hmm...  Looks like an ed script to me...
(Patch is indented 5 spaces.)
The text leading up to this was:
--------------------------
|diff -rBNu src.orig/java/org/apache/nutch/analysis/NutchAnalysisConstants.java src/java/org/apache/nutch/analysis/NutchAnalysisConstants.java
|--- src.orig/java/org/apache/nutch/analysis/NutchAnalysisConstants.java        2009-03-10 11:34:01.000000000 -0700
|+++ src/java/org/apache/nutch/analysis/NutchAnalysisConstants.java     2009-03-10 14:11:55.000000000 -0700
|@@ -4,30 +4,34 @@
| public interface NutchAnalysisConstants {
|
|   int EOF = 0;
|-  int WORD = 1;
|-  int ACRONYM = 2;
|-  int SIGRAM = 3;
|-  int IRREGULAR_WORD = 4;
|-  int C_PLUS_PLUS = 5;
|-  int C_SHARP = 6;
|-  int PLUS = 7;
|-  int MINUS = 8;
|-  int QUOTE = 9;
|-  int COLON = 10;
|-  int SLASH = 11;
|-  int DOT = 12;
|-  int ATSIGN = 13;
|-  int APOSTROPHE = 14;
|-  int WHITE = 15;
|-  int WORD_PUNCT = 16;
|-  int LETTER = 17;
|-  int CJK = 18;
|-  int DIGIT = 19;
|+  int QOR = 1;
|+  int WORD = 2;
|+  int ACRONYM = 3;
|+  int SIGRAM = 4;
|+  int IRREGULAR_WORD = 5;
|+  int C_PLUS_PLUS = 6;
|+  int C_SHARP = 7;
|+  int PLUS = 8;
|+  int MINUS = 9;
|+  int QUOTE = 10;
|+  int COLON = 11;
|+  int SLASH = 12;
|+  int LPAREN = 13;
|+  int RPAREN = 14;
|+  int DOT = 15;
|+  int ATSIGN = 16;
|+  int APOSTROPHE = 17;
|+  int WHITE = 18;
|+  int WORD_PUNCT = 19;
|+  int LETTER = 20;
|+  int CJK = 21;
|+  int DIGIT = 22;
|
|   int DEFAULT = 0;
|
|   String[] tokenImage = {
|     "<EOF>",
|+    "\"OR\"",
|     "<WORD>",
|     "<ACRONYM>",
|     "<SIGRAM>",
|@@ -39,6 +43,8 @@
|     "\"\\\"\"",
|     "\":\"",
|     "\"/\"",
|+    "\"(\"",
|+    "\")\"",
|     "\".\"",
|     "\"@\"",
|     "\"\\\'\"",
|diff -rBNu src.orig/java/org/apache/nutch/analysis/NutchAnalysis.java src/java/org/apache/nutch/analysis/NutchAnalysis.java
|--- src.orig/java/org/apache/nutch/analysis/NutchAnalysis.java 2009-03-10 11:34:01.000000000 -0700
|+++ src/java/org/apache/nutch/analysis/NutchAnalysis.java      2009-03-10 14:11:55.000000000 -0700
|@@ -56,7 +56,11 @@
|           queryString, (analyzer != null) ? analyzer : new NutchDocumentAnalyzer(conf));
|     parser.queryString = queryString;
|     parser.queryFilters = new QueryFilters(conf);
|-    return parser.parse(conf);
|+    try {
|+      return parser.parse(conf);
|+    } catch (ParseException pe) {
|+      throw new IOException("Parse exception: " + pe);
|+    }
|   }
|
|   /** For debugging. */
|@@ -77,44 +81,60 @@
|   String field;
|   boolean stop;
|   boolean prohibited;
|+  boolean required;
|     nonOpOrTerm();
|     label_1:
--------------------------
File to patch:
A: 
  1. You need the original source (at the given version!)
  2. You need the patch Unix utility (I have a copy for Windows coming with my precious UnxUtils, google that name to find the SourceForge project). Oh, well, just did it to ensure name is right: UnxUtils
  3. You apply the patch, it will change the sources
  4. You compile the project.
PhiLho
But my Q is that how to apply this patch?I've installed that utility already.
Shore
A: 

Have you got Cygwin ? Installing this will give you a patch.exe that you can use with the above (and a ton of other very useful stuff).

You can apply the patch using:

patch originalfile -i patchfile.patch -o updatedfile
Brian Agnew
But that patch is going to modifying multiple files.
Shore
A: 

One: Make a backup of your code.

Two: You did make a backup of your code, didn't you? 8-)

Three:

cd \path\to\nutch
patch -p0 < nutch_0.9_OR.patch
RichieHindle
+2  A: 

Since you mentioned Eclipse - right-click on the project, go to Team -> Apply patch.

Robert Munteanu
That should help!But how can I know which files are modified?
Shore
The apply patch wizard will do all for you.
Robert Munteanu
But I need to have the list of files that is modified,how?
Shore
Is D:\nutch-0.9.bak where the 'src' directory of Nutch is? You need to run the patch command in the directory where the 'src' directory of Nutch is.
RichieHindle
A: 

I'm assuming the following:

  • UnxUtils installed in C:\unxutils
  • "C:\unxutils\bin" and "C:\unxutils\usr\local\wbin" included in your PATH variable.
  • Nutch files in C:\nutch-0.9
  • *nutch_0.9_OR.patch* converted to windows line delimiters else you will get an error like this one "Assertion failed: hunk, file patch.c, line 321"
  • *nutch_0.9_OR.patch* copied to C:\nutch-0.9

Then open a command line cd C:\nutch-0.9 patch.exe -p0 -u -i nutch_0.9_OR.patch

Finished!

A: 

You should use right click on project, Team/Apply patch.

The third step of the wizard (review patch) contains a Patch Content section where the modified source files are listed.

Zoltán Ujhelyi