views:

186

answers:

4

How do you manage common library source in a DVCS?

Currently, my team uses Perforce to manage our software projects. Using Perforce's "Workspace Mapping" feature, I am able to easily map common library source into dev application directories in a way that keeps the transformation between source management and dev project work transparent. For example, the Repository looks something like this:


SCM TREE STRUCTURE

  • root
    • apps
      • ForumSite
      • AdminTool
    • common
      • event.logger
      • json.parser
    • db
      • Users
      • SiteConfiguration

Due to the nifty P4 mapping feature, our developers can pull a complete set of source for the projects they work on in the form that makes the most sense using a workspace map. A typical dev project folder might look something like this:


DEV PROJECT FOLDER

/projects
    /FALL-2009
        /ForumSite
            /deps
                /event.logger
                /json.parser
        /AdminTool
            /deps
                /event.logger
                /json.parser
        /Users-db
        /SiteConfiguration-db
    /FALL-2009-PATCH-01
        /json.parser
        /SiteConfiguration-db
    /FALL-2009-PATCH-02
        /AdminTool
            /deps
                /event.logger
                /json.parser
        /SiteConfiguration-db

When a dev edits source in any of his/her components or applications, the changes are mapped back to the right source control directory at the right version point. This is transparent to the dev, reducing the complexity of management and time to set up new projects.

I'm researching Git, Bazaar and Mercurial as potential alternatives to Perforce. Can anyone provide insight into how common component source is handled in the DVCS world?

+1  A: 

we are using git, and are quite happy with its submodule feature. It let's you integrate other git-repositories into the current one, of course, with revision. What can I see, it works well :-)

moritz
+5  A: 

In Git, you would use git submodule for this purpose.

Git submodules are stored as references to a revision from another repository, along with a file providing a URL to find the other repository. When you perform a git submodule update, Git will clone a copy of the referenced repository (or you can configure it to point to a different copy of the same repository at a different URL, as it is a DVCS and so any clone of a repository that contains the referenced revision will also work), and then check out the referenced revision.

Sadly, it is not as seamless as one might wish. Checking out a new revision in the parent repository does not actually check out the submodule; you need to do an explicit git submodule update to accomplish this. We have tried wrapping git pull; git submodule update as a single command, but there are a lot of other commands (such as git rebase) that involve checking out files which can get you into a confusing state because they don't update the submodules as well. Once you get familiar with how submodules work, it will all work out, but it provides a bit of friction.

Brian Campbell
@Brian: Good information. Between you, Ry4an and bialix, I think I've got what I need to evaluate Git, Mercurial and Bazaar. Thanks!
Data Monk
+4  A: 

A very similar question was asked in a mercurial specific fashion two days ago:

http://stackoverflow.com/questions/1981457/how-do-people-manage-changes-to-common-library-files-stored-across-mutiple-mercu

Subrepo support, now well supported in Mercurial, seems to be the best option for your setup.

Ry4an
Interesting. McKoss had the same concern I did about Mercurial. The wiki page on Subrepos says that it's experimental. So, it's been fully integrated into Mercurial then?
Data Monk
Yeah, it was added late in 1.3 by Matt Mackall (mercurial's primary author) himself, and he declared them beta. By now it's at 1.4.2 and he's encouraging others to build new features on it (subversion and git sub-repos in mercurial main repos!), so it's not going to change substantially, and it has always worked.
Ry4an
Just to add on what Ry4an said, SVN subrepo support has landed: http://selenic.com/repo/hg/rev/cd477be6f2fc
Steve Losh
+2  A: 

In Bazaar I'm using plugin scmproj which allows me to specify required configuration of components, so I can provide any map between actual branches and their set on local disk, as you described.

bialix
@bialix: thanks for the link. I'll check it out.
Data Monk