How do I only commit a subrepo's changes?
Asked Answered
A

1

9

I have a master repo, which has some changes I do not want to commit.

I have a subrepo, which has changes that have already been committed.

I want to commit the changes subrepo revision in my master repo, without committing the changes to the files in the master repo.

I cannot seem to do this. I can't commit .hgsubstate, and making a trivial change to a file to commit that does not commit the subrepo changes to the master repo.

Amylo answered 19/6, 2012 at 2:16 Comment(1)
If your modified files are named foo and bar, have you tried doing hg ci -S -X foo -X bar?Sunstroke
P
11

Pass the name of the subrepo itself to commit and Mercurial will update .hgsubstate and commit it.

ry4an@four:~$ hg init main
ry4an@four:~$ cd main
ry4an@four:~/main$ hg init sub
ry4an@four:~/main$ echo sub = sub > .hgsub
ry4an@four:~/main$ hg add .hgsub
ry4an@four:~/main$ hg commit
ry4an@four:~/main$ cd sub
ry4an@four:~/main/sub$ echo text > afile
ry4an@four:~/main/sub$ hg commit -Am first-in-sub
adding afile
ry4an@four:~/main/sub$ cd ..
ry4an@four:~/main$ hg status
ry4an@four:~/main$ echo text > dont-commit-me
ry4an@four:~/main$ hg add dont-commit-me
ry4an@four:~/main$ hg status
A dont-commit-me
ry4an@four:~/main$ cat .hgsubstate
0000000000000000000000000000000000000000 sub
ry4an@four:~/main$ hg commit -m 'subrepo only' sub
ry4an@four:~/main$ hg status
A dont-commit-me
ry4an@four:~/main$ cat .hgsubstate
dec5eaa9e22cd0a05cbba3ba02fdb0e1f243e07e sub

Note that the file in main dont-commit-me never got committed, but the .hgsubstate was updated.

Prepotency answered 19/6, 2012 at 13:29 Comment(4)
That did the trick. I can't believe I didn't think to try that!Amylo
This is a little misleading, since dont-commit-me wouldn't have been committed anyway. If it had been added, then the argument to commit would make a difference. (I defer to Ry4an, though, as I know he is a Mercurial master.)Harlot
You're right, @Harlot . I should've added it for it to be a better example.Prepotency
In Hg (without a dummy file), I am getting "nothing changed". When I add a dummy file I get an error "uncommitted changes in subrepository". Seems like failed use-case handling..Hochheimer

© 2022 - 2024 — McMap. All rights reserved.