Home > bzr, php, symfony > Ignored files in Bazaar in a Symfony project

Ignored files in Bazaar in a Symfony project

October 23rd, 2009 pablo Leave a comment Go to comments

Recently, I’ve been doing a few projects using Symfony PHP framework and Bazaar for version control. One of the great features of Symfony is that it generates base classes automatically to interact with the database from a pre-defined schema file. While this is a great feature, every time the schema gets changed, Symfony regenerates all the files thus flagging them as modified in Bazaar. To avoid committing those files all the time, I created a .bzrignore file to ignore them and leave my repository nice and clean.

Firstly, init bazaar for your new project:

bzr init

Next edit your .bzrignore file located in the root dir of your project

vi .bzrignore

And add the following lines:

trunk/cache/*
trunk/log/*
trunk/config/*schema-transformed.xml
trunk/plugins/.*

The above lines are pretty much self-explanatory, the only important thing here to keep in mind is that if you want to ignore all the files inside a directory you firstly have to add the directory to bazaar (bzr add dir) and then ignore everything inside them.
The magic really happens in the following line.
For Doctrine users:

trunk/lib/**/base/*

And Propel

 **/om/*. 
 **/map/*.

This tells bzr to ignore anything inside any directory named base inside the lib directory, and om and map if you’re using propel, which is where all base classes are stored.

This way, your repository will only store the files that you edit. All files generated automatically by Symfony or plugins are ignored, so when checking out a Symfony project you will have to execute:

./symfony doctrine-build-all

or

./symfony propel-build-all

To see which files are currently being ignored use the following command:

bzr ignored

And the output should be something like this:

The first column tells which file is ignored and the second one informs the rule (pattern) used for the match.

trunk/cache/admin                                  trunk/cache/*
trunk/cache/frontend                               trunk/cache/*
trunk/cache/project_autoload.cache                 trunk/cache/*
trunk/lib/filter/doctrine/base/BaseMyClassFormFilter.class.php trunk/lib/**/base/*
trunk/lib/form/doctrine/base/BaseMyClassForm.class.php trunk/lib/**/base/*
trunk/lib/model/doctrine/base/BaseMyClass.class.php trunk/lib/**/base/*
trunk/log/admin_dev.log                            trunk/log/*
trunk/log/frontend_dev.log                         trunk/log/*
trunk/plugins/.channels                            trunk/plugins/.*
trunk/plugins/.depdb                               trunk/plugins/.*
trunk/plugins/.depdblock                           trunk/plugins/.*
trunk/plugins/.filemap                             trunk/plugins/.*
trunk/plugins/.lock                                trunk/plugins/.*
trunk/plugins/.registry                            trunk/plugins/.*
trunk/web/uploads/                     trunk/web/uploads/*

Comments are very much appreciated!

http://blog.melimato.com/wp-content/plugins/sociofluid/images/digg_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/reddit_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/stumbleupon_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/delicious_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/technorati_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/google_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/myspace_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/facebook_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/yahoobuzz_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/twitter_24.png http://blog.melimato.com/wp-content/plugins/sociofluid/images/meneame_24.png
Categories: bzr, php, symfony Tags: , , , , , ,
  1. lzap
    November 3rd, 2009 at 15:23 | #1

    I think its a good idea not to ignore mapping file and classes. Its not really big and you do not need to regenerate over and over. Also you keep a history in the SCM. Its not big deal to store in there. Version of the library can change and voila – you have a problem.

    Also I am in doubt with plugins directory – why not to store them in there…

    On the other side I would highly recommend ignoring trunk/data/*.db if you use SQLite.

  2. lzap
    November 3rd, 2009 at 15:34 | #2

    One more thing – ignoring trunk/web/uploads/ is also not good for the current version of the Symfony. It should contain subdir “assets”.

  3. pablo
    November 3rd, 2009 at 18:04 | #3

    The reason I like to ignore auto-generated files is because they are auto-generated..Duh! :-) I have the habbit of committing only the files I change for a specific issue in some kind of issue tracker (currently using redmine). This way I know exactly what files I’ve touched to implement a specific feature or fix a bug. If the version of the library changes you will need to re-generate those files anyway, whether they are stored in your SCM or not.

    About the plugins, I do store them all in there, what I’m ignoring there are just the files that start with a “.” like .lock or .filemap etc…

    I completely agree with you on the assets dir…just updated the post. Thanks!!

  4. kevin
    November 5th, 2009 at 11:48 | #4

    Don Pinkster just published the ignore rules he uses when working on his symfony projects with Mercurial : http://www.pinkster.eu/2009/11/04/using-mercurial-as-vcs-for-symfony/

    Also for those who prefer Git, Matt Daum from setfive.com published a plugin which “Automatically generates and optionally add ‘ignores’ for your SCM : http://www.symfony-project.org/plugins/sfSCMIgnoresTaskPlugin (it apparently also works for CVS, toh!).

  5. November 19th, 2009 at 22:58 | #5

    ,..] blog.melimato.com is one great source of tips on this issue,..]

  1. No trackbacks yet.

Comment moderation is enabled. Your comment may take some time to appear.

Additional comments powered by BackType