This is the historical archive of the now-inactive 'grubstreet' list.
Discussion on OpenGuides development has now moved to OpenGuides-Dev. Discussion on The Open Guide to London now takes place on OpenGuides-London.

[grubstreet] Parallelogram of merges

[prev] [thread] [next] [lurker] [Date index for 2003/1/7]

From: Ivor Williams
Subject: [grubstreet] Parallelogram of merges
Date: 15:15 on 07 Jan 2003
------ =_NextPart_000_01C2B65F.CACB88C0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Attached is a script I wrote a year ago, which works as it stands. (Pod is not 
complete, but there is enough t be going on)

 

The idea is to merge two sets of changes to the same file - without needing to 
install a VCS. I think that this has applications for Grubstreet, both in terms 
of Perl patches, and in terms of wiki content.

The parallelogram comes from considering the following picture of what is 
happening:

         Base source file (starting point)
         /                                \
        /                                  \
       /                                    \
   Patch A                          Patch B
       \                                    /
        \                                  /
         \                                /
    File with combination of both patches

I am working on an OO interface, which will have capabilities of diff, patch 
and merge. This could be useful if we have offline content that needs merging 
between wikis.

Ivor.

------ =_NextPart_000_01C2B65F.CACB88C0
Content-Type: application/x-perl; name="merge.pl"
Content-Transfer-Encoding: base64

IyEvdXNyL2xvY2FsL2Jpbi9wZXJsCgojIEdlbmVyYWwgbWVyZ2UgZmFjaWxpdHkKIwojCUkuIFdp
bGxpYW1zCUphbnVhcnkgMjAwMgoKdXNlIHN0cmljdDsKdXNlIEFsZ29yaXRobTo6RGlmZiBxdyh0
cmF2ZXJzZV9zZXF1ZW5jZXMpOwoKewoJaWYgKEBBUkdWICE9IDMpCgl7CgkJcHJpbnQgPDxFTkQK
ClVzYWdlOiBtZXJnZSA8YmFzZV9wb2ludD4gPGNoYW5nZWQxPiA8Y2hhbmdlZDI+CgpiYXNlX3Bv
aW50IGhlcmUgaXMgdGhlIGZpbGUgYmVmb3JlIGVpdGhlciBzZXQgb2YgY2hhbmdlcyB3YXMgYXBw
bGllZC4KCkVORAoKOwoJCWV4aXQ7Cgl9CgoJbXkgKCRwYXJlbnQsJGZpbGUxLCRmaWx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UuIFRoaXMgZW11bGF0ZXMgc29tZQpvZiB0aGUgZnVuY3Rp
b25hbGl0eSBvZiBhIHZlcnNpb24gY29udHJvbCBzeXN0ZW0uIENoYW5nZXMgYXJlIGNvbWJpbmVk
LCBhbmQgdGhlIHJlc3VsdAptYXkgaW5jbHVkZSBCPGNvbmZsaWN0cz4gd2hpY2ggcmVxdWlyZSBt
YW51YWwgcmVzb2x1dGlvbiB3aXRoIGEgdGV4dCBlZGl0b3IuIAo=

------ =_NextPart_000_01C2B65F.CACB88C0--


-- 
grubstreet mailing list
http://london.openguides.org/old-list-archives/