1

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?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Liam Dawson
  • 1,189
  • 13
  • 27

2 Answers2

3

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).
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Aha, I think I have a brilliant idea with that, must go and brush up my symlinks though. Definitely marking as answer. – Liam Dawson Dec 28 '10 at 00:27
  • Yes, if I set it up like you said, then do a symlink from /dev/project to /www/project, it'd allow me to do debug testing, then make it easier for me to migrate to a main/debug version later (which I should, but never do). – Liam Dawson Dec 28 '10 at 00:45
  • @dawmail333: the only problem with my proposition is the OS must support symlink, which would exclude Windows. But in your case, that can work. – VonC Dec 28 '10 at 07:46
  • @VonC Vista and higher can symlink, fyi. – Liam Dawson Dec 31 '10 at 04:56
  • @dawmail333: right! http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-vista/ and http://en.wikipedia.org/wiki/NTFS_symbolic_link ... except for: "The default security settings in Windows Vista disallow non-elevated administrators and all non-administrators from creating symbolic links" and we are not admin on our workstations at work :( – VonC Dec 31 '10 at 10:54
  • @VonC Default settings seems to indicate that you could work around that... Maybe group policy? There'd have to be a way to do it. – Liam Dawson Dec 31 '10 at 15:02
  • @dawmail333: not if your IT support team make sure you cannot modify anything within gpedit.msc ;) – VonC Dec 31 '10 at 15:08
  • @VonC well I would sorta hope that was the case :P But if it's innocent (which it is), can't they edit the GP? I mean, it's not like you could compromise the network with it, really. – Liam Dawson Dec 31 '10 at 15:21
  • @dawmail333: for a couple hundreds PC to manage, I couldn't agree more with you. But when you get to 14K+ workstation (for France alone, I don't count other countries)... enterprise-wide policies just get more stricter (and simpler to manage and deploy). – VonC Dec 31 '10 at 15:33
  • @VonC Pity. PITA too. Well then, I suppose the search continues :P – Liam Dawson Jan 02 '11 at 06:37
0

Implemented in Mercurial 1.3, here's the instructions.

Matt Joiner
  • 112,946
  • 110
  • 377
  • 526