It probably doesn't make sense to do from Sugar's perspective but it's worth a try. I'd like to see a mechanism to merge custom code blocks in core files into the patch files. Here's how it could work:

1. Have a standard format to define custom code blocks such as
/** [Sugar Custom Code] [BEGIN] */
...code here....
/** [Sugar Custom Code] [END] */

2. During the patch install iterate through all Custom Code tags and display to the user whether that block should merge into the latest version.

3. If yes, take the line number for the current version of that block of code and put that block into the patch version where that line number corresponds in the patch version. So if the code was found on line 432 in 5.0.0c and that line is now 454 in 5.0.0d insert there instead. To get that to work correctly, however, code blocks would need to be found starting from the end of the file and working back to the start of the file. Otherwise line numbers could get messed up if working from start to finish. There are other ways to get around that issue I suppose.