Hi,
I'm currently trying to push a commit via hg-git to a running gerrit
instance, but the target branch selection doesn't work the way I hoped
it would.
The repository in question can be cloned either by
hg clone git+
https://review.coreboot.org/flashrom.git
or
hg clone hg clone git+ssh://<username>@
review.coreboot.org:29418/flashrom
The Gerrit instance is at
https://review.coreboot.org/q/project:flashrom
With git and a repo cloned via ssh, pushing a commit looks like this:
git push origin HEAD:refs/for/master
WIth mercurial and hg-git, I tried to translate that command, but
apparently specifying the remote branch doesn't work as I would like:
compiler@host:~/flashrom-hg$ hg book refs/for/master
compiler@host:~/flashrom-hg$ hg push --debug --traceback
pushing to git+ssh://
carl...@review.coreboot.org:29418/flashrom
finding hg commits to export
calling ssh: ssh -p 29418 '
carl...@review.coreboot.org' 'git-receive-pack '\''/flashrom'\'''
searching for changes
1 commits found
list of commits:
0cc3e992c8132ff1b99af39f1d5720652a4ae11c
adding objects
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mercurial/scmutil.py", line 154, in callcatch
return func()
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 314, in _runcatchfunc
return _dispatch(req)
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 918, in _dispatch
cmdpats, cmdoptions)
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 673, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 926, in _runcommand
return cmdfunc()
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 915, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 1197, in check
return func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/mercurial/commands.py", line 4194, in push
opargs=opargs)
File "/usr/lib/python2.7/dist-packages/hgext/git/util.py", line 56, in inner
return f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/hgext/git/__init__.py", line 384, in exchangepush
pushop.cgresult = repo.githandler.push(remote.path, revs, force)
File "/usr/lib/python2.7/dist-packages/hgext/git/git_handler.py", line 404, in push
old_refs, new_refs = self.upload_pack(remote, revs, force)
File "/usr/lib/python2.7/dist-packages/hgext/git/git_handler.py", line 1122, in upload_pack
raise hgutil.Abort(_("git remote error: ") + str(e))
Abort: git remote error: refs/heads/refs/for/master failed to update
abort: git remote error: refs/heads/refs/for/master failed to update
The remote target branch should in theory be refs/for/master, but
apparently something in the pipeline between hg and the remote side adds
the prefix refs/heads/ to any git branch specification.
Looking through the hg-git code and dulwich code, I can find quite a few
places where refs/heads/ is added as a prefix, but I haven't yet found
the instance which causes the problem I'm having.
The last mention of the same (or similar) issue I could find was here:
https://groups.google.com/forum/#!searchin/hg-git/gerrit%7Csort:date/hg-git/SH8g0oi8EWg/HgKG83Zn6T4J
I'm running hg-git 0.8.11 from Ubuntu 18.04. My apologies if this is
already fixed in some newer version. I looked through the changelogs and
couldn't find anything which looked related.
Regards,
Carl-Daniel