Version control for code generation, changing, regenerating and merging

I have an sql file which I used to generate models. I made changes to the model files.

Then I made changes to the sql file.

Now I want to regenrate the model files and then merge the new files with the changes I had made to the model earlier.

How should I do this?

I’m using Netbeans and its Mercurial plugin.