[Luarocks-developers] use of the patch tool

David Manura dm.lua at math2.org
Fri Sep 5 03:32:05 GMT+2 2008


On Mon, Aug 25, 2008 at 3:23 PM, Hisham wrote: [1]
> I have mixed feelings about the "patches" feature, because it assumes
> the availability of a complex tool.

We could rewrite the patch tool in Lua.  It might support restricted
subset of patch formats, namely unified diff[2][3].  This doesn't seem
that it would be that complicated.  A Python implementation of "patch"
for unified diff is just over 400 lines[4].

phpBB takes a different approach.  phpBB has a standard format for
defining "mods"[5], which are custom patches to the software.  The
mods, however, are not in the unified diff format but rather in its
own format (see example [6] paraphrased below):

  <open src="index.php">
  	<edit>
  		<find>text to find</find>
  		<action type="replace-with">text to be replaced with</action>
  	</edit>
  	<edit>
  		<find>text to find</find>
  		<action type="after-add">text to be added on the line after</action>
  	</edit>
  	<edit>
  		<find>text to find</find>
  		<inline-edit>
  			<inline-find>find</inline-find>
  			<inline-action type="after-add">, err have a string appended
to</inline-action>
  		</inline-edit>
  	</edit>
  </open>

I suspect the reason for this format is so that the mods are more
robust to changes in the mainline source (i.e. avoiding the need to
update the mod upon each update to the mainline).  Some operations,
such as moving a file, may also avoid large diffs in this format.
However, I don't think those concerns would apply in LuaRocks.
Patches are used in LuaRocks only as a temporary measure to fix an
already released module to allow it to work with LuaRocks.  Assuming
the module author is actively maintaining the source, the rockspec
author and module author can collaborate to eliminate the need for
rockspec patches.

So, I think writing a unified diff patch function in Lua is the way to go.

[1] http://lists.luaforge.net/pipermail/luarocks-developers/2008-August/000858.html
[2] http://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
[3] http://www.artima.com/weblogs/viewpost.jsp?thread=164293
[4] http://code.google.com/p/python-patch/wiki/README
[5] http://www.phpbb.com/mods/
[6] http://www.phpbb.com/mods/modx/sample-30-120.xml



More information about the Luarocks-developers mailing list