Hi all,

I need to apply a patch on a module but I don't know how.
The documentation I found on Drupal is mainly not on Windows. The video I watched here http://drupal.org/patch/apply is on MAC.

I am not particularly happy installing apps like tortoise as I'm not a developer. I just want to apply a simple patch.

Any ideas please?

Comments

marcvangend’s picture

It's amazing, but AFAIK (and yes, I searched, often!) there is not a simple stand-alone patch apply tool for Windows. Many people will recommend you to install a linux command line environment like Cygwin, but that's not what you're looking for I think. If you're looking for some kind of a graphical user interface, I recommend either Tortoise SVN (ok, it's a developer tool with lots of functions that you won't need, but it's not as scary as it seems) or Aptana (an IDE which probably looks more familiar than Tortoise, but is larger and bulkier than Tortoise).

CAZephyr’s picture

I guess this is where we put a gibe at Windows that they obviously don't want to make patching too easy.

On a more serious note: a lot of those types of tools on Windows include everything except the kitchen sink. Whereas the smaller, targeted tools were created by people trying to scratch their own itch, who were mostly working on Anything But Windows.

WorldFallz’s picture

There's 2 child pages below the main patch/apply page that have less bulky patching tools for windows-- i use the gnuwin32 patch utility all time, works fine.

marcvangend’s picture

Yes, I'm afraid that we have to conclude that patching on windows is either bulky or techy.

WorldFallz’s picture

patch < name-of-file-to-patch.patch

techy?

marcvangend’s picture

Yes, believe it or not, to people who are only used to GUI's, every command line feels techy - not matter how simple the command is.

WorldFallz’s picture

lol, true that-- sometimes i forget. In this particular case though, the wincvs gui makes my brain bleed and the command line is actually the simpler option. ;-)

sp_key’s picture

In my case the techy bit is not the command.
I'm just not sure how to use this tool (gnuwin32) but I'll give it a second try.

btw, is it possible to move the patch and the "to-be-patched" files on a linux box, patch them there and move them back to my Windows machine?

WorldFallz’s picture

Yep-- you can do it that way as well. But seriously, patching on windows really isn't that bad:

  1. download the patch binary and put it somewhere in your path.
  2. place the patch in the appropriate location (drupal root for core patches, module root for module patches, assuming the patch was rolled properly).
  3. open a command prompt in the same location as the patch.
  4. type the command patch < name-of-file-to-patch.patch.

If you get errors, make sure the line endings of your site and the patch match-- on windows they need to be carriage return and line feed. I use notepad++ which makes checking them and converting them very simple (from the format menu).

EDIT:
Also good to know that patch --help will print out the help text for the app.

Heine’s picture

On Vista & Windows 7, you'll get prompted to grant patch the right to elevation (because of its name). Unfortunately, patch seems to lose its commandline arguments the moment you approve elevation via the UAC dialog.

Either rename the binary to apply_diff.exe or write a manifest file that specifies the requestedExecutionLevel as "asInvoker" (see Microsoft Technet).

Here's a sample manifest from the unxutils tracker. Simply drop it as patch.exe.manifest in the same directory as the patch binary.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="2.5.0.0" processorArchitecture="X86" name="Patch" type="win32" />
  <description>A tool for applying diff-generated patches.</description>
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
      <security>
        <requestedPrivileges>
          <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
        </requestedPrivileges>
      </security>
    </trustInfo>
 </assembly>
matdab’s picture

WorldFallz thanks for instruction. For me - the techy thing is when problem appears. In my case:
- both multi-file patch
- and for not existing files also (? creating new ones?) u can see here the patch: http://drupal.org/node/156783#comment-3623848

Also - the problem with Patch is... how to install it? just put the only one file - patch.exe in the root, where u've got .patch file and patched files? I did all your steps and after hitting command get new cmd blank window named with path .../patch.exe. After hitting patch --help the command line is refreshing...

You see, it's not that easy...:(
help... please
Mat

ricardobabe’s picture

patch < context-2742913-11.patch

This worked for me using Aptana.
Thanks

sidja’s picture

The easiest way to apply a patch is using TortoiseSVN

1. Install TortoiseSVN

2. Copy patch file to root of drupal project directory ( for ex c:\wamp\www\btrain\ )

3. Right click on patch file > SVN Apply Patch

4. Chose project folder ( for ex c:\wamp\www\btrain\ )

5. TortoiseMerge appears : Right click on any file on 'File patches' window and select ' Patch All '

ricardobabe’s picture

patch < context-2742913-11.patch

This worked for me using Aptana