AmbroseChapel
AmbroseChapel

Reputation: 12097

Please explain this from the Subversion FAQ? "Don't use a file, use a template"

http://subversion.apache.org/faq.html#ignore-commit

I have a file in my project that every developer must change, but I don't want those local mods to ever be committed. How can I make 'svn commit' ignore the file?

The answer is: don't put that file under version control. Instead, put a template of the file under version control, something like "file.tmpl".

Then, after the initial 'svn checkout', have your users (or your build system) do a normal OS copy of the template to the proper filename, and have users customize the copy. The file is unversioned, so it will never be committed. And if you wish, you can add the file to its parent directory's svn:ignore property, so it doesn't show up as '?' in the 'svn status' command.

http://subversion.apache.org/faq.html#ignore-commit

The only use of .tmpl files I've come across in learning about Subversion are the hook files, where they give you a template say post-commit.tmpl which has an example shell script in it, and you're supposed to rename it without the .tmpl and put it in the hooks folder.

I'm afraid I don't get what this FAQ answer means. Are files with .tmpl extensions somehow ignored by Subversion? Do I have to rename the file?

Say my system has database-config.php in a file on the server, and I want to develop on my local machine with a different database-config.php reflecting local conditions. Do I have to call it database-config.php.tmpl?

Can someone talk me step-by-step through how I would follow the instructions in the answer?

By the way, I'm aware there are other similar questions, but I don't believe any of them addresses this specific FAQ question, or asks for it to be spelled out.

Upvotes: 1

Views: 396

Answers (1)

Ujjwal Singh
Ujjwal Singh

Reputation: 5008

As stated by @Wrikken - Add the most standard file with common preferred settings and "Store" it in the repository. Now when the user checks it out - before anything elese - He must first:

  1. Edit it (eg. ooga_Template.cpp) according to his local environment
  2. Save it as a copy - with the original(expected) file name (eg. ooga.cpp)
  3. and NOT version this(ooga.cpp) file (i.e. not attach it to the SVN).

You can name the template file anything - but yes naming it different from the Original file name - is highly recommended. This way that file can harmlessly sit along the local version of that file, and it will make it compulsory for the user to modify the file before he can use it.

Upvotes: 2

Related Questions