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

我怕爱的太早我们不能终老 提交于 2019-12-24 08:07:32

问题


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 will 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?


回答1:


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).



回答2:


Implemented in Mercurial 1.3, here's the instructions.



来源:https://stackoverflow.com/questions/4539449/importing-a-mercurial-repository-automatically-e-g-svn-externals

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!