If you need additional functionality, you must patch the program's source code with diff files. I don't think this principle scales well. If you change the source code, all patches will become invalid. How is it supposed to work?
Patch applying is quite robust, you do not need the code to be identical, the line numbers don't need to match exactly, it's most sensitive to the few lines of context.