WinMerge
• you may find more here
Notes:
• While these programs do a nice job in showing file differences visually, side by side, non of them (as i can tell) allows to actually save the difference in unified format (most allow to save a standard diff, though) - update: TortoiseCVS lets you save patches. It does unified format by default. See its Make Patch option. Note that this 'Make Patch' option can make recursive patches when applied to directories.
• You cannot specify the "-u" in the External diff preferences (eg "diff -u") as this will result in "Unable to open 'diff -u' (The system cannot find the file specified.)". A workaround for this is to, in the preferences, specify a batch-file that calls the external diff with the -u option. Another workaround is meta-diff, which allows for launching of special diff programs for certain file types.)
line endings: an issue with using diff on windows is that generated patches have windows line endings, which makes them impossible to apply on unix boxes [1][2]. unfortunately, there seems to be no way to convince "cvs diff" to output unix line endings*. so the only way for making a proper patch on windows that i see is to convert / filter the output from "cvs diff" to unix line endings:
• filter: pipe "cvs diff's output through some dos2unix tool (like the one from Robert B. Clark, or like cygwins's dos2unix / d2u):
cvs diff [options] file_to_diff | unix2dos -u > file_to_diff.patch
• convert: save "cvs diff"s output to a file:
cvs diff [options] file_to_diff > file_to_diff.patch and manually convert file_to_diff.patch to unix line endings. every developers editor should be capable of this; besides, there are many dos2unix versions that operate on files.
Patching with Cygwin
1. Get the latest version of Cygwin at Cygwin.com. What you download is actually a small setup file that will reconnect to the web for more data when executed.
2. Run setup.exe. Chose "install from the internet", an appropriate directory, connection type etc. matching your system. In the next window, chose a server near to you (btw: no problem to cancel & restart with a different server, if the first choice is slow).
3. In the next window you get a list of available packages - now it's important to add "patch" to the list, since it is not included by default. You have to find it by pressing the "view"-Button once to see all of the packages (view cycles between "category", "all" and "updated"). Scroll down until you see "patch" in the column "Packages". Klick the small Icon with the text "skip" way to the left in the line - "skip" will change to a version number. This means the package will be installed. (at this point you could also deactivate a whole bunch of the other packages, if you don't need them. If you don't, the setup-process takes a while.)
4. Run cygwin. In the explorer, you will see that a unix-like directory-structure has been created inside the installation directory. when you run the program for the first time, a user-directory is created below the "home"-directory. This will be your default directory when working with cygwin - the easiest way is to put the original file & the patch there (so you don't have to enter a lengthy path to your commands).
5. Patch! :) In the open shell (command window) just enter the command: patch -p0 original.filename nameofyour.patch
6. If you get errors while patching, try to use the original file fresh from the drupal server. I used a module from my working server, and the patch command threw all kinds of errors. Seems as if the line-numbers have been messed up somehow by copying & viewing. Although I do not understand how this could happen.
7. Before you copy the patched file to your server, rename the old one... you never know if it really works in your environment.
Gnuwin32 diff and patch
An alternative for Windows only users is GnuWin32.
Got to the download link and get the patch and diffutil packages. They work well with standard *nix system examples found here.
Note: If you add the bin directory c:\Program Files\GnuWin32\bin to your Windows system path (go look up how to do this on a Windows how to site) then you will be able to run them at a CMD prompt anywhere on your system.
Patch on Windows
I haven't found any Windows-GUI for patch, so the only choice is a Windows port of the Unix command-line tool. If you know of a Windows GUI for patch, please let me know
• Cygwin - a UNIX environment for Windows, including many standard UNIX-tools (including diff and patch)
• pre-compiled binaries, available from various places. Some I've found:
O http://www.squirrel.nl/people/jvromans/tpj0403-0016b.html O http://www.gnu.org/software/emacs/windows/faq11.html#patch
Note:
I found many of the precompiled binaries have problems with pathnames etc. and do not work properly. So I would recommend installing cygwin - it takes a while, but after that, you have a nice Unix environment that works.
* and i tried a lot: checking out all files with unix line endings, various -kb options, external diffs, patched cvs versions ... nothing. for a discussion of this, check CVS and binary files
You can try also integrated diff/patch packages like GNU diffutils for Windows or get the GNU utilities for Win 32.
Using Cygwin to patch in Windows
To use Cygwin to patch in Windows:
1. In your c: drive, create two folders; one named C:\cygwinstuff and another named C:\patchfiles
2. Go to www.cygwin.com and download the setup file.
2. Click on the file downloaded in step 2 to start the install
The next few steps will walk you through the install process for Cygwin.
4. Choose Install from Internet
5. For Root Install Directory: Choose C:\cygwin
6. For Local package directory, choose c:\cygwinstuff -- the folder you created in step 1.
7. Choose the appropriate internet connection -- for most of us, that's the Direct Connection
8. Choose a download site -- I generally pick one at random, but for those of you who are more precise, you can use the domain names to try and choose a site on the same continent.
9. Select packages: This is where things can get tricky. Just make sure to select the patchutils under the Devel section.
10. Begin the install.
11. Once Cygwin has installed, move the file(s) you want to patch, and the patch file, into the C:\patchfiles folder you created in step one.
12. Open Cygwin. Cygwin gives you what you have been looking for: the command line. You will need the following commands:
• ls -al -- lists the contents of your current directory
• cd .. -- moves you up to the parent directory (note the space between cd and .. if you come from a DOS background!)
• cd foldername -- moves you to a specific folder visible from your current directory
13. When you open Cygwin and type ls -al, you will see the contents of your current directory. Different versions of Cygwin start you in different directories. Regardless of where you start, you can use cd c: to navigate to your C: drive (under Cygwin, this will be called /cygwin/c).
14. When you are at C:, you will be able to see the patchfiles folder you created in step one. Use cd patchfiles to navigate into this folder.
15. Type ls -al. You should see the files you moved into this folder in step 11.
16. Type patch filetobepatched < patchfile or patch -p0 < patchfile if there are many files to be patched.
These instructions ought to get you started.
For a more comprehensive overview of the options available while patching, see the patch manual (man) page.
HOWTO: Set up a test environment to help review patches
This guide is aimed at a developer or end user who would like to participate in the Drupal core patch review process, but is unsure of where to start. A similiar process will work for contributed modules, but this page's focus is on core. There are five main sections to this guide:
1. Retrieving a copy of Drupal HEAD from CVS
2. Configuring Drupal HEAD
3. Finding and applying patches
4. Testing patches for versions other than Drupal HEAD
5. Creating a test environment from an existing installation of Drupal
This document assumes the reader has shell access to some sort of Linux/Unix/BSD/Cygwin platform.
Post a comment