in production when upgrading you would need to keep a backup of your web.config file and restore customizations after upgrading.
for development you would need to do the same thing if updating from mercurial, you would discard local changes pull new changes and update then re-apply the local custom changes. there is no way around that.
best bet is only pull new changes if you know there are new changes that you want, ie you could keep an eye on our history page for new changes and update less frequently to reduce the work in changing the web.config