The proper way to emulate wglShareLists is to recreate a context and to use glXCopyContext to restore all states. glXCopyContexts is not well known and for that reason very buggy (the nvidia drivers segfault) and dri drivers only offer it in case of indirect rendering.
I hadn't encountered a case like this before and I fear we have to live with the fact that it can mess up the states. The code itself is ok but please look at the indentation as we use spaces in wine and your patch introduces tabs.
Roderick
Homeworld 2 calls wglShareLists() to share two contexts having already called wglMakeCurrent() on both, thus forcing Wine to create both contexts. This causes wglShareLists() to bomb with a "already created" error. This patch instead deletes the destination context, if it exists, before sharing.