<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: patch code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 01:51:46 GMT</pubDate>
    <description>DZone Snippets: patch code</description>
    <item>
      <title>Capistrano : apply local patches when deploying from an external source code repository</title>
      <link>http://snippets.dzone.com/posts/show/3147</link>
      <description>I've submitted patches to a couple rails apps, and want to run off of their SCM's trunk code, but with my local patches applied. These Capistrano tasks will take any files matching &lt;pre&gt;patches/*.diff&lt;/pre&gt; in your local directory, and apply them before restarting your app.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;task :after_setup do&lt;br /&gt;  patches_setup&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;task :after_update_code do&lt;br /&gt;  send_and_apply_patches&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;task :patches_setup do&lt;br /&gt;  run "mkdir -p #{deploy_to}/#{shared_dir}/patches" &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;task :send_and_apply_patches do&lt;br /&gt;  Dir[File.join(File.dirname(__FILE__), '../patches/*.diff')].sort.each do |patch|&lt;br /&gt;    puts "sending #{File.basename(patch)}"&lt;br /&gt;    put(File.read(patch),&lt;br /&gt;       "#{deploy_to}/#{shared_dir}/patches/#{File.basename(patch)}",&lt;br /&gt;       :mode =&gt; 0777)&lt;br /&gt;    puts "applying #{File.basename(patch)}"&lt;br /&gt;    run "cd #{release_path}; patch -p0 &lt; #{deploy_to}/#{shared_dir}/patches/#{File.basename(patch)}"&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 13 Dec 2006 20:51:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3147</guid>
      <author>jnewland (Jesse Newland)</author>
    </item>
    <item>
      <title>patching source</title>
      <link>http://snippets.dzone.com/posts/show/2682</link>
      <description>Making Patch -- to represent the addition of a new file, diff it against /dev/null. &lt;br /&gt;&lt;code&gt;&lt;br /&gt;diff -Naur test.old test.cpp &gt; test.patch&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Apply Patch&lt;br /&gt;&lt;code&gt;&lt;br /&gt;patch test.cpp test.patch&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Undo Patch &lt;br /&gt;&lt;code&gt;&lt;br /&gt;patch -R test.cpp test.patch&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 23 Sep 2006 17:55:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2682</guid>
      <author>nevadalife (nevada)</author>
    </item>
    <item>
      <title>rpatch XOR diff/patch script</title>
      <link>http://snippets.dzone.com/posts/show/1149</link>
      <description>&lt;code&gt;&lt;br /&gt;REBOL []&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;do-by-type: func [&lt;br /&gt;    value&lt;br /&gt;    actions [block!]&lt;br /&gt;    /default&lt;br /&gt;        def-action [block!]&lt;br /&gt;    /local action&lt;br /&gt;][&lt;br /&gt;    either action: select actions type?/word value [&lt;br /&gt;        ;print mold action&lt;br /&gt;        do bind/copy action 'value&lt;br /&gt;    ][&lt;br /&gt;        if default [do bind/copy def-action 'value]&lt;br /&gt;    ]&lt;br /&gt;]&lt;br /&gt;&lt;br /&gt;to-binary-ex: func [value] [&lt;br /&gt;    do-by-type value [&lt;br /&gt;        binary! [value]&lt;br /&gt;        string! [to-binary value]&lt;br /&gt;        file!   [read/binary value]&lt;br /&gt;    ]&lt;br /&gt;]&lt;br /&gt;&lt;br /&gt;xor-diff: func [&lt;br /&gt;    a [binary! string! file!]&lt;br /&gt;    b [binary! string! file!]&lt;br /&gt;    /local bin-a bin-b&lt;br /&gt;][&lt;br /&gt;    bin-a: to-binary-ex a&lt;br /&gt;    bin-b: to-binary-ex b&lt;br /&gt;    bin-a xor bin-b&lt;br /&gt;]&lt;br /&gt;&lt;br /&gt;make-patch: func [&lt;br /&gt;    a [binary! string! file!]&lt;br /&gt;    b [binary! string! file!]&lt;br /&gt;][&lt;br /&gt;    compress xor-diff a b&lt;br /&gt;]&lt;br /&gt;&lt;br /&gt;apply-patch: func [&lt;br /&gt;    data  [binary! string! file!]&lt;br /&gt;    patch [binary! string!]&lt;br /&gt;    /local result&lt;br /&gt;][&lt;br /&gt;    result: xor-diff data decompress patch&lt;br /&gt;    ; If they gave us a string as the source, return a string.&lt;br /&gt;    ;?? If they give us a file, should we write back out to it?&lt;br /&gt;    either string? data [to-string result][result]&lt;br /&gt;]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;a: "Now is the time for all good men to come to the aid of their country..."&lt;br /&gt;b: {Now is the time for all good men to come to the aid of their country...&lt;br /&gt;whether 'tis nolber to suffer the slings and arrows...}&lt;br /&gt;;d1: xor-diff a b&lt;br /&gt;p1: make-patch a b&lt;br /&gt;bp: apply-patch a p1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;change-dir %./test-files&lt;br /&gt;&lt;br /&gt;files: sort read %.&lt;br /&gt;print mold files&lt;br /&gt;print [files/1 files/2]&lt;br /&gt;fp-1-2: make-patch files/1 files/2&lt;br /&gt;fp-2-3: make-patch files/2 files/3&lt;br /&gt;fp-3-4: make-patch files/3 files/4&lt;br /&gt;fp-a-b: make-patch files/5 files/6&lt;br /&gt;&lt;br /&gt;pp-a-b: apply-patch files/5 fp-a-b&lt;br /&gt;&lt;br /&gt;change-dir %..&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;halt&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 13 Jan 2006 04:15:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1149</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
    <item>
      <title>Release description</title>
      <link>http://snippets.dzone.com/posts/show/1002</link>
      <description>// Release description&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#                                 1.1.0 patchlevel 1&lt;br /&gt;#                                 | | |            |&lt;br /&gt;#          Code base version -----/ | |            |&lt;br /&gt;#          Major version -----------/ |            |&lt;br /&gt;#          Minor version -------------/            |&lt;br /&gt;#          Patchlevel -----------------------------/&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 22 Dec 2005 00:16:53 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1002</guid>
      <author>levysoft (Antonio)</author>
    </item>
  </channel>
</rss>
