Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Mercurial stuck on Git subrepo push?

  1. I have root Mercurial repo (web site).
  2. I clone WordPress from GitHub mirror into /wp subdirectory.
  3. Since I want very specific (stable) version of WP, but no ongoing development I do git checkout 3.4.1 (where 3.4.1 is tag).
  4. I setup it as subrepo in root Mercurial repo and commit (WP revision gets captured fine in .hgsubstate).

And here trouble starts. I do hg push and when it gets to WP:

no branch checked out in subrepo wp
cannot push revision e9bc63e25dc40c07ac3a6778dc2b48e1aa486e36

And then it just quits. Push for root repo is not even attempted.

I understand why Mercurial tries to push subrepo (intended behavior), but I can't make sense why it manages to fail completely on subrepo that:

  1. has no changes
  2. has read-only origin anyway

How to make it understand that I want this specific revision and I don't want it messing with Git subrepo?

like image 905
Rarst Avatar asked Jul 11 '12 16:07

Rarst


1 Answers

You are going to run into a couple problems with this setup.

First, it seems that mercurial cannot handle git subrepos with a detached HEAD.

When you execute git checkout 3.4.1, your repo enters a detached HEAD state (you should have seen a warning to that effect when you executed the command). At that point, if you run git branch, you see that (no branch) is listed as the active branch. When mercurial attempts to push, it chokes on this state. You could ask the mercurial developer list why this happens, but it probably a limitation of the existing subrepo implementation.

Second, mercurial uses a push command to synchronize git subrepos.

If you were to run git checkout -b <integration_branch> 3.4.1, it moves git out of the detached HEAD state. However, when you try to hg push, it will attempt to actually push to the remote git repo. For a mercurial subrepo, it can check for outgoing changes even if you don't have push access to the remote. However, GitHub requires you to authenticate before it will tell you if the two repos are synchronized. So, if you don't have push access to the git remote then this will fail. This is part of the design of mercurial's subrepo strategy.

If you need to continue with this setup, you should probably do the following:

  1. Create your own fork of the WordPress repo on GitHub.
  2. Clone your fork into the mercurial subrepo directory.
  3. git checkout -b <branch_name> 3.4.1
  4. Continue from there

There is some additional info in this related question.

like image 190
Tim Henigan Avatar answered Oct 06 '22 00:10

Tim Henigan