One of the things which I like about doing open source coding is that we have the ability to distribute patches created using diff and then apply the patches to our source trees, hence we tend to forget about the times where we used to distribute our pascal or even worse basic code by zipping the entire source directory prior to sending the code off.
Lets look a little at the example of where I upgraded Horde Chora to version 1.2.2 from Chora version 1.2.1.
It was really easy to use the patch instead of downloading the entire tarball of Chora and then having to extract the files, rename all the files in the config directory, etc. etc.
I needed to get the patchfile for Chora to do the conversion from Chora version 1.2.1 to 1.2.2 and I used wget to retrieve the file.
root@*snip*:~# wget ftp://ftp.horde.org/pub/chora/patches/patch-chora-1.2.1-1.2.2.gz
--00:18:21-- ftp://ftp.horde.org/pub/chora/patches/patch-chora-1.2.1-1.2.2.gz
=> `patch-chora-1.2.1-1.2.2.gz'
Resolving ftp.horde.org... done.
Connecting to ftp.horde.org[199.175.137.150]:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/chora/patches ... done.
==> PASV ... done. ==> RETR patch-chora-1.2.1-1.2.2.gz ... done.
Length: 3,135 (unauthoritative)
100%[====================================>] 3,135 40.82K/s ETA 00:00
00:18:22 (40.82 KB/s) - `patch-chora-1.2.1-1.2.2.gz' saved [3135]
I first renamed my old version of Chora's directory to the version I was planning on patching upto.
root@*snip*:*snip*/horde# mv chora-1.2.1 chora-1.2.2
I then uncompressed the patch file, prior to running the patch command and passing on the filename to patch.
root@*snip*:*snip*/horde# gzcat ~jacques/patch-chora-1.2.1-1.2.2.gz > patch-chora-1.2.1-1.2.2
root@*snip*:*snip*/horde# patch < patch-chora-1.2.1-1.2.2
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/annotate.php chora-1.2.2/annotate.php
|--- chora-1.2.1/annotate.php 2003-01-03 13:48:49.000000000 +0100
|+++ chora-1.2.2/annotate.php 2004-03-26 23:43:22.000000000 +0100
--------------------------
Patching file chora-1.2.2/annotate.php using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/co.php chora-1.2.2/co.php
|--- chora-1.2.1/co.php 2003-01-03 13:48:49.000000000 +0100
|+++ chora-1.2.2/co.php 2004-03-26 23:43:22.000000000 +0100
--------------------------
Patching file chora-1.2.2/co.php using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/cvs.php chora-1.2.2/cvs.php
|--- chora-1.2.1/cvs.php 2003-01-03 13:48:48.000000000 +0100
|+++ chora-1.2.2/cvs.php 2004-03-26 23:43:22.000000000 +0100
--------------------------
Patching file chora-1.2.2/cvs.php using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/diff.php chora-1.2.2/diff.php
|--- chora-1.2.1/diff.php 2003-01-03 13:48:48.000000000 +0100
|+++ chora-1.2.2/diff.php 2004-06-12 16:06:20.000000000 +0200
--------------------------
Patching file chora-1.2.2/diff.php using Plan A...
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 23.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/docs/CHANGES chora-1.2.2/docs/CHANGES
|--- chora-1.2.1/docs/CHANGES 2004-03-09 00:24:29.000000000 +0100
|+++ chora-1.2.2/docs/CHANGES 2004-06-12 23:25:52.000000000 +0200
--------------------------
Patching file chora-1.2.2/docs/CHANGES using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/docs/RELEASE_NOTES chora-1.2.2/docs/RELEASE_NOTES
|--- chora-1.2.1/docs/RELEASE_NOTES 2004-03-14 13:03:53.000000000 +0100
|+++ chora-1.2.2/docs/RELEASE_NOTES 2004-06-12 23:29:50.000000000 +0200
--------------------------
Patching file chora-1.2.2/docs/RELEASE_NOTES using Plan A...
Hunk #1 succeeded at 12.
Hunk #2 succeeded at 25.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/history.php chora-1.2.2/history.php
|--- chora-1.2.1/history.php 2003-01-03 13:48:49.000000000 +0100
|+++ chora-1.2.2/history.php 2004-03-26 23:43:22.000000000 +0100
--------------------------
Patching file chora-1.2.2/history.php using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/index.php chora-1.2.2/index.php
|--- chora-1.2.1/index.php 2003-01-03 13:48:50.000000000 +0100
|+++ chora-1.2.2/index.php 2004-03-26 23:43:22.000000000 +0100
--------------------------
Patching file index.php using Plan A...
Hunk #1 failed at 1.
1 out of 1 hunks failed--saving rejects to index.php.rej
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/lib/CVSLib/Annotate.php chora-1.2.2/lib/CVSLib/Annotate.php
|--- chora-1.2.1/lib/CVSLib/Annotate.php 2002-12-28 19:53:05.000000000 +0100
|+++ chora-1.2.2/lib/CVSLib/Annotate.php 2004-05-17 11:15:41.000000000 +0200
--------------------------
Patching file chora-1.2.2/lib/CVSLib/Annotate.php using Plan A...
Hunk #1 succeeded at 4.
Hunk #2 succeeded at 93.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/lib/CVSLib/Diff.php chora-1.2.2/lib/CVSLib/Diff.php
|--- chora-1.2.1/lib/CVSLib/Diff.php 2002-12-28 19:54:02.000000000 +0100
|+++ chora-1.2.2/lib/CVSLib/Diff.php 2004-06-12 16:06:20.000000000 +0200
--------------------------
Patching file chora-1.2.2/lib/CVSLib/Diff.php using Plan A...
Hunk #1 succeeded at 7.
Hunk #2 succeeded at 56.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/lib/CVSLib/Directory.php chora-1.2.2/lib/CVSLib/Directory.php
|--- chora-1.2.1/lib/CVSLib/Directory.php 2003-02-14 11:55:58.000000000 +0100
|+++ chora-1.2.2/lib/CVSLib/Directory.php 2004-04-15 21:24:12.000000000 +0200
--------------------------
Patching file chora-1.2.2/lib/CVSLib/Directory.php using Plan A...
Hunk #1 succeeded at 7.
Hunk #2 succeeded at 93.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/lib/version.php chora-1.2.2/lib/version.php
|--- chora-1.2.1/lib/version.php 2004-03-14 13:15:17.000000000 +0100
|+++ chora-1.2.2/lib/version.php 2004-06-12 23:30:26.000000000 +0200
--------------------------
Patching file chora-1.2.2/lib/version.php using Plan A...
Hunk #1 succeeded at 1.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Binärdateien chora-1.2.1/locale/es_ES/LC_MESSAGES/chora.mo and chora-1.2.2/locale/es_ES/LC_MESSAGES/chora.mo sind verschieden.
|diff -uNr chora-1.2.1/menu.php chora-1.2.2/menu.php
|--- chora-1.2.1/menu.php 2003-01-03 13:48:48.000000000 +0100
|+++ chora-1.2.2/menu.php 2004-03-26 23:43:22.000000000 +0100
--------------------------
Patching file menu.php using Plan A...
Hunk #1 failed at 2.
1 out of 1 hunks failed--saving rejects to menu.php.rej
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/prefs.php chora-1.2.2/prefs.php
|--- chora-1.2.1/prefs.php 2003-01-03 13:48:49.000000000 +0100
|+++ chora-1.2.2/prefs.php 2004-03-26 23:43:22.000000000 +0100
--------------------------
Patching file prefs.php using Plan A...
Hunk #1 failed at 2.
1 out of 1 hunks failed--saving rejects to prefs.php.rej
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/status.php chora-1.2.2/status.php
|--- chora-1.2.1/status.php 2003-01-03 13:48:50.000000000 +0100
|+++ chora-1.2.2/status.php 2004-03-26 23:43:22.000000000 +0100
--------------------------
Patching file status.php using Plan A...
Hunk #1 failed at 1.
1 out of 1 hunks failed--saving rejects to status.php.rej
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -uNr chora-1.2.1/templates/common-header.inc chora-1.2.2/templates/common-header.inc
|--- chora-1.2.1/templates/common-header.inc 2002-09-25 01:42:14.000000000 +0200
|+++ chora-1.2.2/templates/common-header.inc 2004-03-26 23:43:23.000000000 +0100
--------------------------
Patching file chora-1.2.2/templates/common-header.inc using Plan A...
Hunk #1 succeeded at 5.
done
All I had to now do was fix my symlink for Chora to point to the correct place so that the web interface of Chora can work the way I was expecting.
root@*snip*:*snip*/horde# rm chora
root@*snip*:*snip*/horde# ln -s chora-1.2.2 chora