We have a web application framework that we want to use with Subversion. We’ve tried a couple of times before to set it up, but the code generation part of our application is causing problems.
The problem is that the generated code from one developer can be in a newer file than from another developer, but the content of the newer file can be older, because the code and xml files that are the basis for the code generation has been update by developer nr2.
One solution we’ve looked at is to exclude the code generated files, but we often get new files that are generated, and they are automatically added to the repository unless we remember to exclude it, and we have to manually check in the latest generated files. And how do you know if you have the latest generated file?
Any suggestion on how to solve this in Subversion?
The best way to decide to whether something should be in Subversion is to remember that it’s a version control system. If you don’t need to remember how it changed over time, it doesn’t need to be in
svn. Usesvn:ignoreto exclude files from such consideration.That’s the case here: you don’t care how the generated files changed over time, only the original code used to produce them. That means they should be excluded from Subversion. You can do this with a pre-commit hook — enforcing, for example, that all code-generated files shouldn’t ever be committed. I have a favorite phrase for this tactic: “Version the recipe, not the cake.”
Exactly; you don’t, because the generated files were dependent on the source used to create them. Your next step is to make sure that your build process automatically generates these files given the initial source code, but that’s probably a separate StackOverflow question if you don’t know how to do that already.