Thanks to ESR's very sloppy coding (who is surprised), this actually needs porting. Basically, ESR wrote a source comparator that can be used to find common portions of two source trees... not very sophisticated, but can still identify identical stuff easily. Port attached for whoever wants to play with it.
Attachment:
comparator.tgz
Description: comparator-1.2.tgz