2011-11-13 85 views
12

我正在尝试使用hg push到git存储库,但它默默地失败。我发现a single post on the mailing lista registered hg-git issue,但都是大约半年没有太多活动。所以我开始认为我误解/错误配置了某些东西。 我~/.hgrc包含hg-git默默推送失败

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

这个片段重现问题:

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 

我都尝试hg-git 0.2.6-2附带的Ubuntu 11.10,以及最新的标记的形式,0.3.1。我的mercurial是版本1.9.1

我甚至尝试了两个建议的解决方法,hg update master之前承诺,和hg bookmark -f master承诺后,但都给出了一个错误。

UPDATE:

我创建了一个new issue for this

回答

19

这里有两个问题:推应该明确地失败,HG-混帐应该报告(但事实并非如此)。

推送失败,给"abort: git remote error: refs/heads/master failed to update" when pushing to local clone,因为它是推送到非裸仓库(请参阅more on that from a mercurial user's perspective)。上面的代码片段的工作版本是这样的(请注意使用Bare存储库)。

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 

至于,为什么hg-git隐藏这个错误,我怀疑这是用随Ubuntu的最新版本中的问题。我所做的是

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

它可以除去dulwich 0.7.1,并安装它根据hg-git网站需要0.8。现在,它适用于我。 mercurial版本(1.9.1)似乎工作正常。