Mercurial subrepo and relative path

1.9k views Asked by At

I have a project, which I have a bitbucket repository for, and it is dependent on another project that I incorporate as a subrepo. Now, I don't have push access to the subrepository, nor do I want or need to--it's a pull-only relationship.

I realize that when you push the main repository, it will try to push the subrepositories, as well. Since I cannot do that, I pulled a local copy of the dependent project, at the same level as the main repository's directory. In essence, I have the following layout:

Main/           ; pushes to https://mine.org/Main
  .hg/
  .hgsub
  Lib/
    SubRepo/    ; clone of Main/../SubRepo/
      .hg/

SubRepo/        ; local copy of https://forbidden.org/SubRepo
  .hg/

The content of .hgsub is something like,

Lib/SubRepo = ../SubRepo

Then I cloned,

~/path/to/Main $ hg clone ../SubRepo/ Lib/SubRepo

So far, so good. The problem is, after I set this all up and committed the changes, when I try to push Main Mercurial will try to push SubRepo to https://mine.org/SubRepo, which does not exist, thereby failing the whole push operation.

Is there something I'm missing?

2

There are 2 answers

2
Ry4an Brase On BEST ANSWER

Why not just create a https://mine.org/SubRepo -- if you don't want to advertise it you can always turn on hide for it in the [web] section in its .hg/hgrc file. This is the pattern I'm used to, where you clone down the main repo and all the subrepos in the same layout at each place you'll use them: both your development box and your web-facing hgweb install.

Alternately, you could use a [subpaths] section in Main/.hg/hgrc with something like this in it:

[subpaths]
https://mine.org/SubRepo = https://forbidden.org/SubRepo

which should let you intercept the derrived target for the push and point it at a place that which it won't let you push, will let you see nothing has changed so push can continue.

0
dls On

It seems like what Mercurial is doing is legitimate: using the paths listed in your .hgsub it's attempting to push to a directory called 'SubRepo' that exists one level up from Main. This is obviously not what you want, so you'll probably have to work some magic here. I can think of two options:

  1. If you can support this, place the local copy of forbidden.org's repository at C:/Forbidden/Subrepo or something like that, and use this absolute path in your .hgsub. Mercurial will be able to push to this and it should work.

  2. There's no problem including the actual forbidden.org url as your subrepo address if you don't make any modifications to this repo. If there are no changes to the subrepo, your push should succeed. Of course, this is a fairly manual option and on a larger team it would be impossible to enforce. If you did accidentally commit some modification to the subrepo, you'd have to go through and use histedit or MQueues to pull it out, and that can be tricky with subrepos.