Question

I'm new to contributing to an open source project and I've been handed a patch to continue work on. I have updated my local working copy to the latest in trunk, and when I apply the patch, pretty much all hunks are being rejected.

I'm guessing that the patch was made with a slightly earlier version of trunk, which is why maybe the line numbers aren't matching up. I suppose I could always go through the code manually copying and pasting each hunk, but I'll spend all my development time patching my code instead of contributing!

Is there an easy way to address this issue? Does the patch contain any information about what revision of trunk it was made against? Should I just try to revert my working copy until I find a revision that the patch applies to?

Or am I just missing something simple? Trunk updates pretty darned frequently - I can't imagine everyone on the project having these issues...

Was it helpful?

Solution

If patch was created

  • From SVN Working Copy
  • Using SVN-command svn diff instead of OS-specific

you can see in patch-file information about patch-point.

Patch as svn diff between two revisions in repository

...
--- trunk/G1.txt    (revision 3)
+++ trunk/G1.txt    (revision 4)
...

Patch as svn diff between BASE revision and modified Working Copy

...
--- G1.txt  (revision 4)
+++ G1.txt  (working copy)
...

(--- strings in both cases contain revision, to which patch have to be applied)

For this easy case you have svn up to SOURCE revision, svn patch patch-file, in order to commit applied changes as new revision you must (with modified Working Copy) svn up to HEAD revision, resolve all possible appeared conflicts and only after resolving all conflicts commit revision with changes

Another (somehow more usable way) may be: create branch from SOURCE revision, apply patch to WC of this branch, merge branch (with patch in it) back to mainline.

I'll prefer seconf way - less headache, less chances to commit mistakes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top