I'm working on a couple of PHP projects. One is an application, the other is a library that supports that application. Previously I've used a mercurial setup where the library was a subrepository within the application repository. This meant that any changes to the library code got committed to the subrepository and could be merged with the library project separately (so as to keep the library code's history separate from the app).
I've been struggling to find examples or docs on how to do this with Bazaar (my current DVCS of choice). Has anyone tried/done it? Is it worth doing in Bzr, or should I perhaps look at a different DVCS system that meets this need better?
Bazaar does not have a subrepository feature. [Correction: Apparently there's a bzr-externals plugin, available at lp:bzr-externals, though it emulates the svn:externals feature, not Git submodules or Mercurial subrepos.]
However, this can fairly easily be worked around if you do not want to switch version control systems.
Put the application and the library in two directories, say
appandlib(I'll assume here that they are side-by-side, though they need not be). The following two scripts,lib-snapshotandlib-synccan then be used to link the current version of the application to a specific version of the library, which will be checked out in a subdirectory (also calledlib) of theappcheckout:lib-snapshot:
lib-sync:
The current version of the library is stored in
libversion.txt, which you need to put under version control (so that each version of the application is synced to the version you tested against).The
lib-snapshotscript will fetch the currently checked out version of your library and store it inlibversion.txt. Use it whenever you think the library is stable enough that you want your application to use the new version. Thelib-syncscript can then be used to update the library subdirectory to contain the snapshot version; ideally, this script should also be used as part of the build/deployment process.Bazaar will automatically skip directories that contain repositories when adding files, but you may want to still add the library subdirectory to
.bzrignoreso that you don't get annoying warnings.