hg-git plugin, problem with local cloning: bookmarks

Simon King simon at simonking.org.uk
Thu Sep 1 08:53:18 UTC 2016


On Thu, Sep 1, 2016 at 9:06 AM, Uwe Brauer <oub at mat.ucm.es> wrote:
>
>
>    > Ahh, it looks like cloning a repo only creates bookmarks for the
>    > remote's own branches. So if you were to `git checkout` each of the
>    > branches in your local clone, and then re-clone locally with hg, you'd
>    > get all the branches.
>
> GNU emacs which I am interested about has ~20 branches, so I have to
> checkout each of them, and of each of them reclone? Cumbersome I say,
> and even then I am not sure how re-clone is supposed to work.
>
> I am still puzzled why this is *not* necessary when I clone directly
> from the git repo, but only when I clone locally.
>

git distinguishes between remote tracking branches (refs that live in
the "remotes/<remotename>" namespace) and local branches. Remote
branches automatically update whenever you fetch from or push to the
server. Local branches only update when you ask them to (eg. via "git
merge"). When you cloned the auctex repository from the server using
git, the local repository ended up with 3 remote branches
(remotes/origin/gendocspatch, remotes/origin/master and
remotes/origin/simplify-TeX-parse-error) and 1 local branch (master).

Core mercurial doesn't make this distinction, but there is an
experimental extension which is trying to improve the situation
(https://bitbucket.org/seanfarley/hgremotenames)

As Kevin said, it looks like hg-git is only creating bookmarks for the
*local* branches in the repository. When you cloned from the server,
that meant you got all the branches (because from the server's
perspective, those branches were local). Since your local git
repository only has a single local branch (master), that's the only
bookmark that hg-git created.

Checking out each of the branches in your emacs git repo will create
local branches for each. (There's no need to re-clone; the operation
is approximately equivalent to "hg update <revision>; hg bookmark
<new-branch-name>"). However, I'm not sure that it will help you much,
because those local branches will never advance when the git
repository is updated. They will stay on the same revisions that they
were created at, and so the corresponding hg bookmarks will also stay
at the same point.

I'm not much of an hg-git user, so I may be wrong here, but I would
guess that you need to get the git repository that is being managed by
hg-git (which I think is stored at <repo>/.hg/git) to point at the
server, rather than at the local repo that you originally cloned it
from. Then you can run "git fetch" in it to fetch all the branches
from the server. I think the commands should be:

  cd <auctex-hg-repo>/.hg/git
  git remote set-url origin git://git.savannah.gnu.org/auctex.git
  cd ../..
  hg pull

Hope that helps,

Simon



More information about the Mercurial mailing list