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
. Use svn:ignore
to 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."
And how do you know if you have the latest generated file?
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.
One solution we've looked at is to exclude the code generated files
Yes! A thousand times yes! Never do version control of files you can generate from other files. Instead, add the generation rules to your makefile (or other build script).
they are automatically added to the repository
What is automatically adding them? As far as I can recall, I've always had to add files manually. If the tool that automatically adds is wrong, then maybe fixing that tool is the right way to go?
unless we remember to exclude it
Have you generation tool add a comment saying "file autogenerated by $TOOL", and add a subversion hook which greps the files for that comment and rejects them. Make suitable provisions for the code generation tools; such as: if the file contains the "autogenerated" comment, add it anyways if it also has "svn rejection except" in a comment on the same line(s).
And how do you know if you have the latest generated file?
By generating it from the latest recipe, which is in the latest subversion commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With