Howto apply a patch/diff file

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Howto apply a patch/diff file

Post by Yexo »

michielh wrote:I'm using the r17081 B patch for Cargodist and the r17064 patch for Daylength. Should they be the same revision?
Most likely this is close enough, but when merging 2 or more patches you have to do some manual work. For that some coding knowledge is necesary.

As to your first problem: that file should be part of cargodist. Perhaps you downloaded an incorrect patch?
User avatar
michielh
Engineer
Engineer
Posts: 22
Joined: 29 Apr 2009 13:17
Location: NL

Re: Howto apply a patch/diff file

Post by michielh »

The cargodist patch I used is quite new (http://www.tt-forums.net/viewtopic.php?p=808231#p808231), maybe something went wrong there?

And when I apply the Daylength patch in TortoiseSVN it does give some errors. Is that a big issue?
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Howto apply a patch/diff file

Post by Yexo »

michielh wrote:The cargodist patch I used is quite new (http://www.tt-forums.net/viewtopic.php?p=808231#p808231), maybe something went wrong there?
That patch is indeed not complete.
And when I apply the Daylength patch in TortoiseSVN it does give some errors. Is that a big issue?
You should either apply the patch to the revision it was made for or fix the errors you get yourself.
User avatar
michielh
Engineer
Engineer
Posts: 22
Joined: 29 Apr 2009 13:17
Location: NL

Re: Howto apply a patch/diff file

Post by michielh »

Ok, so I should try another patch. There is a r17064 patch of cargodist, but that's an .diff file and I don't know how to use it with TortoiseSVN..

And is fixing those errors difficult? Because I've got 0,0 experience with coding/c++
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Howto apply a patch/diff file

Post by Yexo »

michielh wrote:Ok, so I should try another patch. There is a r17064 patch of cargodist, but that's an .diff file and I don't know how to use it with TortoiseSVN..
The extension doesn't matter. ".patch" or ".diff", it's all the same.
And is fixing those errors difficult? Because I've got 0,0 experience with coding/c++
Without any experience, yes, it's hard.
User avatar
michielh
Engineer
Engineer
Posts: 22
Joined: 29 Apr 2009 13:17
Location: NL

Re: Howto apply a patch/diff file

Post by michielh »

]Without any experience, yes, it's hard.
Hm, that would be to difficult for me, i guess i'd better wait until these patches get in the trunk.

Anyway, thanks for the help :)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Howto apply a patch/diff file

Post by Yexo »

michielh wrote:
]Without any experience, yes, it's hard.
Hm, that would be to difficult for me, i guess i'd better wait until these patches get in the trunk.

Anyway, thanks for the help :)
Hard does not mean impossible, it just means you'll have to take a lot more time to figure out all problems. Experience doesn't come free you know.

Applying a single patch to the revision it was made should be without any errors, so you should be able to do that (assuming the patch is valid and complete, which is not the case with the cargodist patch you linked).
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: Howto apply a patch/diff file

Post by Wasila »

What does the -i actually mean?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Howto apply a patch/diff file

Post by planetmaker »

try "patch --help"
zedd
Engineer
Engineer
Posts: 74
Joined: 13 Mar 2007 02:38

Re: Howto apply a patch/diff file

Post by zedd »

Ehm how do I actually compile the folder Tortoise downloaded?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Howto apply a patch/diff file

Post by planetmaker »

Let a compiler do the work for you. Translating the source code into binary manually is a pain.
zedd
Engineer
Engineer
Posts: 74
Joined: 13 Mar 2007 02:38

Re: Howto apply a patch/diff file

Post by zedd »

No s***.

I thought Tortoise was a compiler too?
If not can you direct me to one, and if it is can you tell me how cause there is nothing in the Tortoise menu that resembles compile.

The ottd wiki is blank on all the compiling topics...
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Howto apply a patch/diff file

Post by planetmaker »

zedd wrote:The ottd wiki is blank on all the compiling topics...
Yes, of course: http://lmgtfy.com/?q=compiling+openttd
zedd
Engineer
Engineer
Posts: 74
Joined: 13 Mar 2007 02:38

Re: Howto apply a patch/diff file

Post by zedd »

Compile on Mac
Compiling on MinGW

this does not exactly make it clear that MinGW applies to Windows... but I am following the instructions now

So I can skip the SVN steps if i use another svn client right?
zedd
Engineer
Engineer
Posts: 74
Joined: 13 Mar 2007 02:38

Re: Howto apply a patch/diff file

Post by zedd »

Ok now I compiled a revision that seems to work.

But I have the same problem as above
trying to apply cargodist_r17899.diff to r17899 I just get blank boxes in Tortosie.
I have checked out the svn and use apply patch in the tortoise menu on the catalouge.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Howto apply a patch/diff file

Post by Rubidium »

zedd wrote:trying to apply cargodist_r17899.diff to r17899 I just get blank boxes in Tortosie
cargodist is not developed using subversion as version control system. Tortoise's merge tool *only* supports its own/subversion's particular flavour of patch/diff files, which is different from the diff files the version control system of cargodist. As such Tortoise can't be used to apply cargodist patches (this I consider a bug, or at least a seriously missing feature, in Tortoise).

You'll have to use the command line tool patch; I don't know which exact version you'd need for Windows (I guess it's mentioned in one of the pages of this thread), I know there're some versions around that can't handle the cargodist patch.
zedd
Engineer
Engineer
Posts: 74
Joined: 13 Mar 2007 02:38

Re: Howto apply a patch/diff file

Post by zedd »

Ok

Someone directed me to a tool here http://gnuwin32.sourceforge.net/packages/patch.htm

So I type
patch -p0 < patch_name
?

But where should the files be located and whatnot?
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Howto apply a patch/diff file

Post by Gremnon »

the patch you're applying must be in the working directory (1), as must the files it refers to - for openttd, this means it must be in the same place as the file 'configure' and 'readme', not inside the src folder. If you've just checked out the source code via svn, it's the folder that all the files just checked out went to.

(1) the working directory, found by the command 'pwd'. It's where you are right now, for instance, '/home/gremnon//svn/ottdsrc' is the the working directory of my nightly on my computer.
zedd
Engineer
Engineer
Posts: 74
Joined: 13 Mar 2007 02:38

Re: Howto apply a patch/diff file

Post by zedd »

Ok so maybe patch.exe works better if i restart my computer...

now it at least returns something

Code: Select all

C:\Program Files\GnuWin32\bin>patch -p0 -i cargodist_r17899.diff
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
|index 6feab38..456762a 100644
|--- a/projects/openttd_vs80.vcproj
|+++ b/projects/openttd_vs80.vcproj
--------------------------
File to patch:
yes i put the source in that directory where the patch.exe was, so it is now where the config files and src folder and stuff is.

Ok so i input location of openttd_vs.vcproj manually and now this

Code: Select all

File to patch: projects/openttd_vs80.vcproj
patching file projects/openttd_vs80.vcproj
missing header for unified diff at line 59 of patch
can't find file to patch at input line 59
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|0,6 +1116,30 @@
|                               >
|                       </File>
|                       <File
|+                              RelativePath=".\..\src\linkgraph\demands.h"
|+                              >
|+                      </File>
|+                      <File
|+                              RelativePath=".\..\src\linkgraph\demand_settings
.h"
|+                              >
|+                      </File>
|+                      <File
|+                              RelativePath=".\..\src\linkgraph\flowmapper.h"
|+                              >
|+                      </File>
|+                      <File
|+                              RelativePath=".\..\src\linkgraph\linkgraph.h"
|+                              >
|+                      </File>
|+                      <File
|+                              RelativePath=".\..\src\linkgraph\linkgraph_types
.h"
|+                              >
|+                      </File>
|+                      <File
|+                              RelativePath=".\..\src\linkgraph\mcf.h"
|+                              >
|+                      </File>
|+                      <File
|                               RelativePath=".\..\src\livery.h"
|                               >
|                       </File>
--------------------------
File to patch:
???

I also tried it with -p1

Code: Select all

C:\Program Files\GnuWin32\bin>patch -p1 -i cargodist_r17899.diff
patching file projects/openttd_vs80.vcproj
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
openttd_vs80.vcproj file has been altered judging from the TortioseSVN icons but nothing else.
this compiles but gameplay is same as the nightly
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Howto apply a patch/diff file

Post by fonso »

Copy the cargodist patch to the folder where your openttd sources are. See Grenmon's post. Your OpenTTD sources are probably not in C:\Program Files\GnuWin32\bin. You can check from the command line with 'dir'. If you see configure and readme among the output of 'dir' you're in the right folder. You can change folders with 'cd'. The correct folder is probably something like C:\Documents and Settings\zedd\My Documents\OpenTTD. That's just a guess though, you have to find that yourself. When you know where the openttd sources are you have to change to that folder:

Code: Select all

cd "C:\Documents and Settigns\zedd\My Documents\OpenTTD"
(Question to Windows users: does that work? Or do you have to escape the spaces somehow?)
Then run:

Code: Select all

patch -p1 -i cargodist_r17899.diff
Mind the "-p1" instead of "-p0". For that to work your patch.exe either needs to be in the PATH environment variable (it probably isn't) or you have to copy it to the OpenTTD folder, too.
The guy on the picture is not me, it's Alonso.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Baidu [Spider], Semrush [Bot] and 18 guests