Mercurial repository narrow clone?

Posted by Berry Langerak on Stack Overflow See other posts from Stack Overflow or by Berry Langerak
Published on 2011-01-14T12:56:21Z Indexed on 2011/01/15 0:53 UTC
Read the original article Hit count: 160

Filed under:
|

Hi.

I'm currently in the process of moving from Subversion to Mercurial, and I have to say I don't regret that decision. However, when trying to convert my project, I ran into a problem of Mercurial, which I can't seem to get fixed. I have two distinct projects: one is a framework, and the other is an application that relies on that framework. Here's what the repositories look like:

The Framework repository:

  • docs/
  • deploy/
  • lib/
  • tests/

The Application repository:

  • application/
  • config/
  • lib/
  • tests/
  • www/

What I'd like is for the application's lib directory to contain a copy of the frameworks' lib/ directory. I used to do this using svn:externals. Now, I am aware that Mercurial supports the concept of subrepositories, but that doesn't seem like the "correct" solution, as it doesn't actually pull in the lib/ directory like I wanted, as you'll still have to pull and push changes manually. That, plus once you clone the framework repository, you'll get all of it, not just the lib/ directory. I only need the lib/ directory, not the tests, or the docs.

Now, I thought up two different solutions to this problem, but I wonder which is the best. The first solution would be to clone the framework in a different directory altogether and create symlink in the application's lib/ directory which points to the framework's lib/ directory. Putting the symlink in .hgignore should make sure all is well, I think? That means that you could edit the frameworks code, and commit that, and you could edit the application's code and commit that, too.

The other option is to have multiple repositories. The framework gets pulled as a whole, which means you'll get the docs/, deploy/, test/ etc. directories, which are not needed for usage of the framework. I thought maybe creating a repository purely for the library might be a solution, although I sincerely doubt it, as the Unit Tests are very dependant upon the library itself.

Does anyone know a decent solution for this problem?

© Stack Overflow or respective owner

Related posts about mercurial

Related posts about repositories