How can I prevent mercurial from pushing subrepos?
Asked Answered
H

2

28

In my repository I've added several sub-repositories for modules that I'm using. I'm always going to treat these subrepos as "pull only". I don't plan to make any changes to them but want to retain the ability to easily pull new changes if a new version is released.

When I push the main repository, Mercurial tries to push the sub-repositories. Is there any setting to prevent this?

Hovis answered 31/5, 2011 at 0:53 Comment(3)
@Mercurial Does Mercurial not have something similar to Git .gitignore file?Requite
Of course it does, but he's talking subrepos not per-file ignoring. Git has the same subrepo content, and it similarly wouldn't be solved with .gitignore.Moguel
I don't want to ignore the subrepos, I simply don't want them to be part of the push since they'll never change.Hovis
M
7

There are a few things you can do, depending on which behavior you're looking for.

Are you actually editing and committing inside the subrepo? If so, you should create a separate vendor-branch-like repo where you merge your changes with the upstream ("their") changes, and have your subrepo point to that. Something like this perhaps:

repos
  main
    subrepo
    .hgsub # contains: "subrepo=../theirproject"
  theirproject  # clone of remote, upstream repo

The idea being that the subrepo entry not point directly to the pull-only upstream repo, but to one of your own where you merge your changes with "theirs"

Another option is to stop making changes in the subrepo. If there are no changes, and no commits, then push will pass that repo right by. If you switch to that work mode you can set the commitsubrepos = false in the [ui] section in a hgrc file to avoid accidentally committing in that repo.

The bottom line is that if you're changing things in there then you need to commit them (for safety!) and if you're commit them then they'll be pushed if the parent is pushed, so just control to where they're pushed and you're good to go.

Moguel answered 31/5, 2011 at 2:43 Comment(4)
I'm not editing or changing the sub-repo in any way. It's strictly there as a library for me to reference. I want them to remain sub-repos so that I can pull updates, but I don't want them constantly trying to push when nothing will ever change.Hovis
If you've changed nothing in the subrepos then Mercurial won't try to push them. Or rather it'll detect no changes and push will exit immediately. If you go down into that repo and hg outgoing shows you any content then you've changed (and committed) something. Can you update your question with the specific output you're seeing when you do a hg push in the parent repo?Moguel
Just hg push on the parent repo. I was hoping to basically just prevent the subrepo check since it seems to be slower than a normal push.Hovis
Have the subrepo point to a local clone of that remote repo. (1) clone the slow, remote, read-only repo to local; (2) point your .hgsub file to your local clone instead of remote. Then the push-check with no changes should be instantaneous.Moguel
I
-2

Depends which mercurial client you use. I use tortoisehg, and I have found that right clicking the folder and selecting the files in tortoisehg >> forget is all that it takes. Select the files and you won't need to bother again.

Industrialism answered 31/5, 2011 at 0:56 Comment(1)
You're thinking about ignoring files, but soviut is asking about not pushing in subrepos.Moguel

© 2022 - 2024 — McMap. All rights reserved.