Mercurial: Subrepo error -- "abort: commit with new subrepo [path] excluded"
Asked Answered
C

8

13

I'm trying to setup the subrepositories in my Mercurial project repo for the project's dependencies. But when I try to commit the .hgsub file I keep getting this error:

abort: commit with new subrepo lib/dependency-dir excluded

Details:

Inside my project's Mercurial repository directory (at the top level), I have a subdirectory, lib/, which will contain my dependencies.

It just so happens that all my dependencies live on github, where I've forked each library to create, e.g., https://github.com/mygithubaccount/forked-dependency

I created an .hgsub file and added it to the repository (also at the top level). It contains entries like the following (I've tried isolating each one individually as follows; it doesn't seem to make any difference):

lib/dependency-dir = [git]https://github.com/mygithubaccount/forked-dependency.git

Then I did the following, starting in my project repository's working directory:

$ cd lib
$ git clone https://github.com/mygithubaccount/forked-dependency.git dependency-dir
$ cd ..
$ hg commit .hgsub
abort: commit with new subrepo lib/dependency-dir excluded

Any ideas what I'm doing wrong?

Cassiecassil answered 28/5, 2013 at 20:54 Comment(1)
I don't believe I ever got this working, but gave up and went a different route instead. All the answers here were potentially useful, just too late. So I'm upvoting them all, but giving Carl the Accept as his was the earliest response.Cassiecassil
A
2

I had this issue too. I'm not sure if it matches your situation, but I was trying to add subrepositories to a new repo. Once I added other files and commited them I was then able to add the .hgsub file with the subrepos and commit it without getting this error.

Anemone answered 6/6, 2013 at 10:28 Comment(0)
G
15

The only way I got this work was to commit without specifying the .hgsub file

hg commit -m "message"

Grounder answered 19/11, 2013 at 19:16 Comment(1)
Thank you that worked for me. I tried most of the other suggestions on this page first. I didn't want to commit the new subrepository because it feels as though it shouldn't be in the main repository though I suspect that committing without specifying is the same as committing both.Electrochemistry
N
3

I just fixed the problem by adding the file first, and then committing:

$ hg add .hgsub
...
$ hg commit .hgsub
Nonpayment answered 18/7, 2013 at 20:36 Comment(0)
H
3

I had to commit both .hgsub and the new subrepository at the same time by explicitly selecting them in the commit command. I avoided hg commit all because I had other files that contained work in progress.

Hitt answered 29/12, 2014 at 13:28 Comment(0)
A
2

I had this issue too. I'm not sure if it matches your situation, but I was trying to add subrepositories to a new repo. Once I added other files and commited them I was then able to add the .hgsub file with the subrepos and commit it without getting this error.

Anemone answered 6/6, 2013 at 10:28 Comment(0)
D
1

For me, the problem was that git was not on my system path. Adding it allowed me to commit my git subrepository (note that I had to restart TortoiseHg workbench for it to get the updated system path).

Dragonhead answered 10/11, 2013 at 18:36 Comment(0)
D
1

I found your question when I had the same problem. I used TortoiseHG and it gave me the same error. Solutions here, were useless for me, but I found the answer.

In my case the problem was in the HG version: I found that my TortoiseHG uses hg ver. 2.5. When I use hg ver 3.9 .hgsub commited correctly.

P.S. I Understand that my answer does not help you, but I hope it will help other people like me.

Desiderate answered 5/4, 2018 at 9:14 Comment(1)
It works when I downgrade to 4.0 from 4.9. You're genius.Constringent
J
0

When I had this issue, the problem was that I had two slashes in the path to the subrepo directory.

Jaf answered 11/2, 2015 at 8:57 Comment(0)
M
0

If there is a case difference between the folder name for the subrepo and it's path in the .hgsub file this will also trigger this error message.

I experienced this by copying an .hgsub from another repo that had the same folder structure however the new repo used title casing for the folder names while the folders in the original repo were all lower case.

Changing either the .hgsub or the folder names themselves solved the problem.

Moneychanger answered 31/8, 2016 at 14:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.