Created
April 1, 2010 05:50
-
-
Save alehmann/351435 to your computer and use it in GitHub Desktop.
Script to reproduce hg-git KeyError exception and suggested fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script tests the following repo workflow: | |
# | |
# git-mirror -- clone --> git-contribs | |
# ^ / | |
# | / | |
# push pull | |
# | / | |
# hg-main <------------/ | |
# | |
# Main development is in hg-main, which is mirrored in git-mirror. Git | |
# contributors fork git-mirror. Pulling from git-contribs into hg-main fails as | |
# shown by the script below. | |
# | |
# configure git | |
GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME | |
GIT_AUTHOR_EMAIL='[email protected]'; export GIT_AUTHOR_EMAIL | |
GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE | |
GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME | |
GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL | |
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE | |
# directory for testing repos | |
rm -rf tenv | |
mkdir tenv | |
cd tenv | |
# start with a main hg repo | |
hg init hg-main | |
# do some commits in the hg repo | |
cd hg-main | |
echo a > a | |
hg ci -Am "Add a in hg-main" -d "0 0" -u "tester" | |
hg tag "0.1" -d "0 0" -u "tester" # without this everything works !! | |
echo b > b | |
hg ci -Am "Add b in hg-main" -d "0 0" -u "tester" | |
cd .. | |
# create empty git repo | |
mkdir git-mirror | |
cd git-mirror | |
git init | |
cd .. | |
# push hg repo to git repo | |
cd hg-main | |
ls ../git-mirror | |
hg push ../git-mirror | |
cd .. | |
# create a contributor clone of the git repo and commit some changes | |
git clone git-mirror git-contribs | |
cd git-contribs | |
echo c > c | |
git add c | |
git commit -m "Add c in git-contribs" | |
cd .. | |
# pull from the git contributor into the hg base repo | |
cd hg-main | |
hg pull -u ../git-contribs # <- fails | |
# pulling from ../git-contribs | |
# importing Hg objects into Git | |
# Counting objects: 4, done. | |
# Compressing objects: 100% (2/2), done. | |
# Total 3 (delta 1), reused 0 (delta 0) | |
# ** unknown exception encountered, details follow | |
# ** report bug details to http://mercurial.selenic.com/bts/ | |
# ** or [email protected] | |
# ** Mercurial Distributed SCM (version 1.4.1) | |
# ** Extensions loaded: graphlog, mq, convert, bookmarks, fetch, color, hgk, hg-git, autopager, compass, autosync | |
# Traceback (most recent call last): | |
# File "/usr/bin/hg", line 27, in <module> | |
# mercurial.dispatch.run() | |
# File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 16, in run | |
# sys.exit(dispatch(sys.argv[1:])) | |
# File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 30, in dispatch | |
# return _runcatch(u, args) | |
# File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 46, in _runcatch | |
# return _dispatch(ui, args) | |
# File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 449, in _dispatch | |
# return runcommand(lui, repo, cmd, fullargs, ui, options, d) | |
# File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 319, in runcommand | |
# ret = _runcommand(ui, options, cmd, d) | |
# File "/var/lib/python-support/python2.5/mercurial/extensions.py", line 128, in wrap | |
# return wrapper(origfn, *args, **kwargs) | |
# File "/home/obs/opt/hg-autopager/autopager.py", line 225, in pagecmd | |
# return orig(ui, options, cmd, cmdfunc) | |
# File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 500, in _runcommand | |
# return checkargs() | |
# File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 454, in checkargs | |
# return cmdfunc() | |
# File "/var/lib/python-support/python2.5/mercurial/dispatch.py", line 448, in <lambda> | |
# d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) | |
# File "/var/lib/python-support/python2.5/mercurial/util.py", line 386, in check | |
# return func(*args, **kwargs) | |
# File "/var/lib/python-support/python2.5/mercurial/commands.py", line 2318, in pull | |
# modheads = repo.pull(other, heads=revs, force=opts.get('force')) | |
# File "/home/obs/opt/hg-git/hgrepo.py", line 12, in pull | |
# File "/home/obs/opt/hg-git/git_handler.py", line 102, in fetch | |
# File "/home/obs/opt/hg-git/git_handler.py", line 672, in fetch_pack | |
# File "/home/obs/local/lib/python2.5/site-packages/dulwich-0.4.1-py2.5-linux-i686.egg/dulwich/object_store.py", line 400, in commit | |
# self.move_in_pack(path) | |
# File "/home/obs/local/lib/python2.5/site-packages/dulwich-0.4.1-py2.5-linux-i686.egg/dulwich/object_store.py", line 365, in move_in_pack | |
# entries = p.sorted_entries() | |
# File "/home/obs/local/lib/python2.5/site-packages/dulwich-0.4.1-py2.5-linux-i686.egg/dulwich/pack.py", line 646, in sorted_entries | |
# ret = list(self.iterentries(resolve_ext_ref, progress=progress)) | |
# File "/home/obs/local/lib/python2.5/site-packages/dulwich-0.4.1-py2.5-linux-i686.egg/dulwich/pack.py", line 635, in iterentries | |
# raise KeyError([sha_to_hex(h) for h in postponed.keys()]) | |
# KeyError: ['f4b9c4795186531a06eb2292737b40595d53f78c'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index b1e4c27..faece5c 100644 | |
--- a/hggit/git_handler.py | |
+++ b/hggit/git_handler.py | |
@@ -608,7 +608,7 @@ class GitHandler(object): | |
want = [sha for ref, sha in refs.iteritems() | |
if not ref.endswith('^{}')] | |
return want | |
- f, commit = self.git.object_store.add_pack() | |
+ f, commit = self.git.object_store.add_thin_pack() | |
try: | |
try: | |
return client.fetch_pack(path, determine_wants, graphwalker, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment