开发者

Importing a Mercurial repository automatically (e.g. SVN Externals)

I have a project that I am developing built off CodeIgniter. The main part of the project is a private system I am creating, but I want to add it to source control, to gain all the associated goodies. Now I'm using Mercurial, so I did the whole hg init bit, so I've got the repository set up.

Now, one of the things I've done is to make a library for CodeIgniter, which I use in this project. Now I want to make this library open, so I need a separate repo for that.

For anyone unfamiliar with CodeIgniter library development, here's a reference:

application
  /config <- configuration files
  /libraries <- library logic in here

Now I wi开发者_Go百科ll probably develop a few more libraries in the course of this project, so I can't just dump a repo in the application folder without clumping them all together.

What I did was this:

dev/ci/library <- library here
dev/project <- project here

Now in both of those folders, I have made a repository. What I want to do is make the project repository automatically reference the library repository, so I can have a private and a public repository, as I explained earlier.

The main way to do this, I have read, is to use subrepositories, but I can only find examples on nested ones (which are unclear anyway, I find). How do I make it reference another repository like svn:externals?


You are correct, subrepos in Mercurial (or submodules in Git) are based on a nested organization.
But in your specific case you need:

  • two separate repos,
  • not nested

A way to reconcile both organizations (yours and the nested "subrepo") would be to have three repos

  • a parent repo (private one, as in can be pushed to a private repo)
  • the project (private one, as in can be pushed to a private repo)
  • the library (public one, as in can be pushed to a public repo)

That would give the following:

/dev
  .hg (private repo)
  .hgsubs (declare the two nested repos 'project' and 'ci/library')
  project
    .hg (private repo for your project)
    config
    .hgignore (for ignoring anyhting from libraries)
    libraries (private directory, not version)
      (symlink to /dev/ci/library)
  ci
    library
      .hg (public repo 

That way, you keep:

  • your two repo separate as you want
  • a link between the two in order to be able to get back those two repo at the exact reference you left them (i.e. you last pushed each of those repos).


Implemented in Mercurial 1.3, here's the instructions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜