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?

Soviut
  • 88,194
  • 49
  • 192
  • 260
  • @Mercurial Does Mercurial not have something similar to Git .gitignore file? – Arlen May 31 '11 at 00:57
  • 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. – Ry4an Brase May 31 '11 at 02:36
  • 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. – Soviut May 31 '11 at 06:18

2 Answers2

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.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • 2
    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. – Soviut May 31 '11 at 06:16
  • 1
    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? – Ry4an Brase May 31 '11 at 21:46
  • 1
    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. – Soviut Jun 01 '11 at 05:24
  • 1
    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. – Ry4an Brase Jun 02 '11 at 13:58
-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.

ctrl-alt-delor
  • 7,506
  • 5
  • 40
  • 52
Jordan Wallwork
  • 3,116
  • 2
  • 24
  • 49