I document all code changes in a text file that lists the file/path changed.
The files themselves (PHP, templates, CSS, etc) all include inline comments showing the original code and changes. Use some common value in you comments so you can instantly search your files for your changes (like Q EDIT).
Then I can upgrade and reapply as necessary.
In V4, I think it is also beneficial to make a copy/clone of your Layout before upgrades and particularly before switching to a Responsive Theme.