Search code examples
gitmercurialhg-git

hg-git push silently fails


I'm trying to use hg push to a git repository, but it silently fails. I found a single post on the mailing list and a registered hg-git issue, but both are about half a year old without much activity. So I started to think I misunderstand/misconfigure something. My ~/.hgrc contains

[extensions]
hgext.bookmarks =
hgext.git =
#hggit = /path/to/hg-git-0.3.1/hggit
[bookmarks]
track.current = True

This snippet reproduces the problem:

mkdir /tmp/Git
cd /tmp/Git
git init
echo 'something' > myfile
git add .
git commit -m 'Started'
cd ..
hg clone /tmp/Git /tmp/Hg
cd /tmp/Hg
echo 'another thing' >> myfile
hg ci -m 'Working'
hg log
# Two items listed
hg push
cd ../Git
git log
# Only one item listed, but two expected

I tried both hg-git 0.2.6-2 shipped with Ubuntu 11.10, and the latest tagged version, 0.3.1. My mercurial is version 1.9.1

I even tried two proposed workarounds, hg update master before commiting, and hg bookmark -f master after commiting, but both gave an error.

UPDATE:

I created a new issue for this


Solution

  • There are two issues here: push should explicitly fail, and hg-git should report it (but it doesn't).

    Pushing should fail, giving "abort: git remote error: refs/heads/master failed to update" when pushing to local clone, because it's a push to a non-bare repository (see more on that from a mercurial user's perspective). A working version of the above snippet is this (note the use of the Bare repository).

    mkdir /tmp/Git
    cd /tmp/Git
    git init
    echo 'something' > myfile
    git add .
    git commit -m 'Started'
    cd ..
    git clone --bare -l /tmp/Git /tmp/Bare
    hg clone /tmp/Bare/ /tmp/Hg
    cd /tmp/Hg
    echo 'another thing' >> myfile
    hg ci -m 'Working'
    hg log
    # Two items listed
    hg push
    cd ../Bare
    git log
    # Two items listed
    

    Regarding, why hg-git hides this error, I suspect it's a problem with the most recent versions shipped with Ubuntu. What I did was

    apt-get remove mercurial-git python-dulwich
    easy_install hg-git
    

    It removed dulwich 0.7.1, and installed 0.8 which is required according to the hg-git site. Now, it works for me. The mercurial version (1.9.1) seems to work fine.