This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 198527

Summary: Apply Diff Patch... is worthless: The patch cannot be applied in the selected context
Product: utilities Reporter: kpalsson
Component: DiffAssignee: Ondrej Vrabec <ovrabec>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 7.0   
Hardware: PC   
OS: Other   
Issue Type: DEFECT Exception Reporter:

Description kpalsson 2011-05-11 18:05:12 UTC
I used "team->export diff patch" to create a diff file, which looked good, but then when later trying to apply it again, I get the message, "The patch cannot be applied in the selected context" and nothing is done at all.

I realise that there are other bugs tracking the context path being relative to project roots and version control roots, but this bug is NOT about that.

This message is being applied simply because a hunk failed.  The "output" window had a tab labelled "patch report" which was _NOT_ brought to the foreground when this failed.  (It should have been, I should not have had to go looking)

On that tab, I get the following output:

11.5.2011 17:46:58  ===========================================================================
--- Successfully Patched ---
<none>
--- Failed ---
C:\srcx\cbms2-trunk\applications\mqtt2_v_ssr\mqtt2_v_ssr.cpp (Cannot apply hunk @@ 10 )

This is pretty worthless.  What happens at the command line when I try and apply the patch myself:


C:\srcx\cbms2-trunk\applications\mqtt2_v_ssr>patch -p0 --verbose -i mqtt_subtopi
cs_cleanup.diff
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|# This patch file was generated by NetBeans IDE
|# Following Index: paths are relative to: C:\srcx\cbms2-trunk\applications\mqtt
2_v_ssr
|# This patch can be applied using context Tools: Patch action on respective fol
der.
|# It uses platform neutral UTF-8 encoding and \n newlines.
|# Above lines and this line are ignored by the patching process.
|Index: mqtt2_v_ssr.cpp
|--- mqtt2_v_ssr.cpp Base (BASE)
|+++ mqtt2_v_ssr.cpp Locally Modified (Based On LOCAL)
--------------------------
Patching file `mqtt2_v_ssr.cpp' using Plan A...
Hunk #1 succeeded at 51 (offset -1 lines).
Hunk #2 succeeded at 120.
Hunk #3 FAILED at 261.
Hunk #4 succeeded at 278 (offset -3 lines).
Hunk #5 succeeded at 388.
Hunk #6 succeeded at 768 (offset -3 lines).
Hunk #7 succeeded at 792.
Hunk #8 succeeded at 859 (offset -3 lines).
Hunk #9 succeeded at 897.
1 out of 9 hunks FAILED -- saving rejects to mqtt2_v_ssr.cpp.rej
done

Notes: That comment that the "patch can be applied..." is wrong, that just gives the bad context error.

I would like a patch that has failed hunks to _succeed_ and then offer to show me the failed hunks!  It's pretty worthless in it's current state.