WinMerge

Last modified: November 12, 2009 - 20:28

Where to download WinMerge

http://winmerge.sourceforge.net

A beginners guide for generating a patch.

Working with the files

  • Save a copy of the original file that you are working with for editing.(it will be your working copy)
  • Keep the original file to use for comparison by WinMerge and for use in generating the patch file.
  • Work on your copy of the original file, make the changes you need and use it for testing as needed.
  • When you are finished with your changes and are ready to generate a patch, save the edited file.
  • Note: Files from Windows systems usually have CRLF line endings and patches should be made with LF (Unix-style) line endings. If using WinMerge as your editor you should go to Edit -> Options... -> Editor -> Check Preserve original EOL characters. Patches may still need post-processing to convert line endings from CRLF to LF.
  • Two ways to generate the patch

    Both of these are very much the same. It just depends on whether you want to compare the file side by side before generating the patch.

    Compare the files visually before generating the patch

  • Open WinMerge, click on the folder Icon to open the 'Files and Folders' interface.
  • Click the top browse button and locate the original file. I make a habit of having it in the left. You can choose where you want it(left or right), but it's good to do it the same each time.
  • Click the second browse button and locate the file you have been editing.
  • When you click 'ok', the two files will load side by side in the WinMerge window. When your are satisfied with the changes as compared with the original.
  • Click Tools > Generate Patch which will open the patch generator interface.
  • Click the browse button next to the 'Result' field to select the file where the patch will be written.
  • In the file dialog that appears, navigate to where you want the patch to live and type the name of the patch e.g. "newpatch.patch". WinMerge will create the file if it doesn't exist.
  • In the format section, select 'unified'.
  • Unified will create the @@ -3,43 +3,95 @@ line numbers.
  • The context selection will set how many lines are shown above your changed line when the patch is generated.
  • If this is a readme file, 0 works well. If it is a code patch, 3 works better as it will let people find the section of code easier.
  • Now the patch generator is ready, Click 'Ok'
  • WinMerge will popup a dialog box 'Patch file successfully written'
  • Login to Drupal.org and submit the file to the project Issue Queue for review.
  • Generate the patch without loading the files for visual inspection

  • Open WinMerge, Click Tools > Generate Patch which will open the patch generator interface.
  • Click the browse button to choose File1: (this will be the original file)
  • Click the browse button to choose File2: (this will be the edited file you made the changes to.
  • Click the browse button next to the 'Result' field to select the file where the patch will be written.
  • In the file dialog that appears, navigate to where you want the patch to live and type the name of the patch e.g. "newpatch.patch". WinMerge will create the file if it doesn't exist.
  • In the format section, select 'unified'.
  • Unified will create the @@ -3,43 +3,95 @@ line numbers.
  • The context selection will set how many lines are shown above your changed line when the patch is generated.
  • If this is a readme file, 0 works well. If it is a code patch, 3 works better as it will let people find the section of code easier.
  • Now the patch generator is ready, Click 'Ok'
  • WinMerge will popup a dialog box 'Patch file successfully written'
  • Login to Drupal.org and submit the file to the project Issue Queue for review.
  • The resulting patch file will be formatted just like the pro's do it.

    --- node_gallery/node_gallery.admin.inc Fri Oct 09 15:36:52 2009
    +++ node_gallery/node_gallery.admin.inc Sat Oct 10 20:01:14 2009
    @@ -55,7 +55,7 @@
           '#type' => 'radios',
           '#title' => t('Gallery Type'),
           '#options' => $node_types,
    -      '#description' => t('Select which content type should be used as gallery type.'),
    +      '#description' => t('Select which content type should be used as the gallery type.'),
           '#default_value' => $gallery_config['gallery_type'],
           '#required' => TRUE,
         );

     
     

    Drupal is a registered trademark of Dries Buytaert.