Reputation: 1090
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?
Upvotes: 0
Views: 92
Reputation: 8730
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 app
and lib
(I'll assume here that they are side-by-side, though they need not be). The following two scripts, lib-snapshot
and lib-sync
can 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 called lib
) of the app
checkout:
lib-snapshot:
#!/bin/sh
libsrc=../lib
bzr revno --tree $libsrc >libversion.txt
lib-sync:
#!/bin/sh
ver=`cat libversion.txt`
libsrc=../lib
libdst=lib
test -d $libdst/.bzr && bzr update -q -r $ver $libdst || bzr checkout -q --lightweight -r $ver $libsrc $libdst
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-snapshot
script will fetch the currently checked out version of your library and store it in libversion.txt
. Use it whenever you think the library is stable enough that you want your application to use the new version. The lib-sync
script 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 .bzrignore
so that you don't get annoying warnings.
Upvotes: 1