Updating a patch file to work on a modified source tree
|
Author | Content |
---|---|
techiem2 Jul 16, 2008 8:58 AM EDT |
Ok, so I'm running a tremulous dedicated server with the tremx mod in place for my friends and I.
But...we want bots! Now, I have a patch file that adds some basic bot support, but it's built against the normal tremulous source tree, not the tweaked one used to generate the tremx mod, so the line numbers are off and thus the patch doesn't apply properly (i.e. you get duplicate functions, stuff that never makes it into the source from the patch, etc.). How do I go about doing a compare of the patch file data to the current source tree to make an updated patch with the right line numbers? I saw something about using diff, but what I've seen only seems to apply to single files, even though diff apparently supports directories (and when I tried diff thepatch.patch trunk it just gave me an error about trunk/thepatch.patch not existing). The patch file is written to be run from the directory above the svn trunk dir. Thanks to all the shell experts! |
krisum Jul 16, 2008 10:30 AM EDT |
One approach could be apply the patch, then observe all the rejects and correct the source files manually using those. If the compilation succeeds then a new patch can be generated by doing an "svn add" of all newly added files (new files can be seen using "svn status" for those files/directories that appear with a "?" status). The new patch can then be generated using svn diff. Another approach could be to first generate a diff between the normal tremulous tree and the tweaked tremx one, then apply that diff to the normal tremulous tree that has your patch applied. Then proceed as in the first approach, but generating the new diff will require "diff -r" between the two trees rather than "svn diff". |
techiem2 Jul 16, 2008 11:58 AM EDT |
Quoting:One approach could be apply the patch, then observe all the rejects and correct the source files manually using those. That's what I started to do first...but it ended up being a big mess and LOTS of manual work would be involved. Quoting: Another approach could be to first generate a diff between the normal tremulous tree and the tweaked tremx one, then apply that diff to the normal tremulous tree that has your patch applied. Then proceed as in the first approach, but generating the new diff will require "diff -r" between the two trees rather than "svn diff". How would I go about that? Thanks! |
Sander_Marechal Jul 16, 2008 2:23 PM EDT |
1) Generate a diff between standard tremulous and your modified tremulous 2) install standard tremulous 3) apply bot patch 4) apply patch you created in step 1 5) pray that the number of collisions is a lot lower so it's easier to fix manually |
techiem2 Jul 16, 2008 2:37 PM EDT |
aaaah I see.
So basically I'm generating the patch for tremx, then patching the main source with the bot first, and then with tremx to hopefully get fewer rejects/confusions. That might work. I'll have to give it a try. Ideally, you'd just be able to run a script that reads the sections of the patch file, then uses the context sections to compare the current source tree to update the line numbers for the sections.... But I don't know the shell tools well enough to write one.... |
krisum Jul 16, 2008 9:03 PM EDT |
Quoting: Ideally, you'd just be able to run a script that reads the sections of the patch file, then uses the context sections to compare the current source tree to update the line numbers for the sections....The patch command already handles shifting of line numbers etc. as far as possible. Normally it fails only when the context lines in the patch do not match in the source. I doubt that we can have a simple shell script that will do a better job that patch. |
gus3 Jul 16, 2008 9:36 PM EDT |
Let me just say: Kudos to the patch developers, Larry Wall, Paul Eggert, Wayne Davison, David MacKenzie, and probably lots of others, for making such a versatile program. This program exemplifies the Unix philosophy: "Do one thing, and do it well." |
You cannot post until you login.