2

1

With the help of this post by Rob Sobers, I have set up my group of projects as a hierarchy of subrepositories and locally, on my own PC, everything seems to work so far. However, I'm having problems when I try to push my changesets to Kiln.

For example, I have a directory structure which looks something like this:

\Code\Visual Studio 2008\Projects\nCore (contains the Visual Studio project)

\Code\Source\Fortran\nCore (contains the actual source code, which is also used by other projects and makefiles)

[No snide comments about Fortran please; it's parallelised Fortran 2003 and runs blazingly fast.]

The \Fortran\nCore directory contains a repository which is linked to its counterpart in Kiln; the \Projects\nCore directory contains a repository of its own which is also linked to a counterpart in Kiln, PLUS a clone of the \Fortran\nCore repository which is identified as a sub-repository. The line in .hgsub is:

nCore = ..\..\..\Source\Fortran\nCore

Everything works until I try to push from the project directory:

> hg push https://my-account.kilnhg.com/Repo/nCore/nCore/Visual-Studio-Projects

pushing to https://my-account.kilnhg.com/Repo/nCore/nCore/Visual-Studio-Projects

pushing subrepo nCore to https://my-account.kilnhg.com/Repo/nCore/nCore/Visual-Studio-Projects/..\..\..\Source\Fortran\nCore

abort: HTTP Error 404: Not Found

If I understand correctly, the problem is that the 'parent repository' doesn't know where to push the subrepository to, and seems to send it straight to Kiln with a path that Kiln doesn't recognise because Kiln just has two separate standlone repositories - Visual-Studio-Projects and Fortran - and doesn't know that one is a subrepository of the other.

So, to cut to the chase: how do I tell Kiln that my 'Fortran' repository is a subrepository of 'Visual-Studio-Projects' (as well as several other projects)? I've been playing around with the 'Organise' and 'Configure' menus but haven't seen anything that looks like it does what I'm after. Or indeed, am I doing this completely wrong and need to start again?

flag

2 Answers

4

The problem you're running into is because you're using a relative, file-system path for your sub repository. Instead, you should set your .hgsub file to look something like this:

nCore = https://my-account.kilnhg.com/Repo/nCore/Fortran/nCore

(Or whatever the correct URL is.) This is because Mercurial assumes that if you're using relative paths, they are the same on disk and in the URL. (This is a poor assumption IMO, but that's what it does.) By using the URL, Mercurial will always know where to pull and push the subrepo to.

link|flag
I guess the intent behind my question was really "Can I set up a URL in Kiln with a path that corresponds to the path on my disk", which would have had the desired effect. I think the problem with: nCore = my-account.kilnhg.com/Repo/nCore/Fortran/nCore is that it would sever all connection with ..\..\..\Source\Fortran\nCore, which is where my actual code resides. I tried instead to replace my .hgsub with ..\..\..\Source\Fortran\nCore = my-account.kilnhg.com/Repo/nCore/Fortran/nCore ...but then when I try to commit it fails with (to be continued...) – smorriswxm Mar 23 2011 at 21:39
(continued) ...an error message saying "abort: path contains illegal component" when I try to commit. All in all, I feel I'm no nearer to my desired behaviour, which is to (1) Have a repository containing code which is shared between several applications, (2) have each application's repository linked to the same shared subrepository, and (3) ensure that if I alter code in the shared repository while working in an application's Visual Studio project, then the next 'hg commit' will commit the shared repository as well as the application's own. Is this even possible, or am I on the wrong track? – smorriswxm Mar 23 2011 at 21:45
You can't have a subrepo outside of the parent repo. So if you have two parent repos on disk, you'll also have two copies of the shared subrepo, one in each parent repo. You use Mercurial to keep the versions consistent between them. – Tyler Hicks-Wright Mar 24 2011 at 19:03
<Sound of penny dropping> Ah, I see. So every time I make a change in my current application's copy of the library, I need to push it to the "master repo" at the shared location. When I work in another of the applications that shares the library, I should pull an updated copy into my local subrepo first. From time to time, I should push the changes that have accumulated in the library's "master repo" up to Kiln. Thank you, I think I'm getting the hang of this. – smorriswxm Mar 25 2011 at 12:47
Yeah. Like I said in the answer, I think there could have been some better assumptions in the way subrepos were designed, but this is the way they work. – Tyler Hicks-Wright Mar 25 2011 at 15:10
1

A customer recently wrote us with sub-repo issues. The basic problem was that he had URLs for his sub-repos that were invalid. The invalid URLs were preventing him from cloning the parent repo. I spoke with engineering and found a solution if you are in this situation:

Say you have a repo that lives at http://somewhere/overthe/rainbow, with an .hgsub file that says subrepo = http://somewhere/overthe/subrepo. You've moved the repo to http://somewhereelse/overthe/rainbow and http://somewhereelse/overthe/subrepo, so clones don't work.

Add this to your hgrc / Mercurial.ini to fix:

[subpaths]
^http://somewhere/(.*)$ = http://somewhereelse/\1

or the appropriate regex for your URL changes. hg will then resolve the .hgsub to the new URL, by running the regex replacement on the old URL.


Going forward, here is the recommendation for setting up subrepos:

Mercurial recommends trivial paths, but Kiln needs absolute URLs, so you can use subpaths to reconcile:

Setup your .hgsub with trivial paths:

libfoo = libfoo
libbar = libbar

Now put this in your hgrc / Mercurial.ini:

[subpaths]
^libfoo$ = http://kiln/code/project/group/libfoo
^libbar$ = http://bitbucket.org/opensource/libbar

But if you have lots of subrepos, you'd probably want to use a smarter scheme to reduce the number of regexes. That's left as an exercise for the reader.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.