schacon / hg-git

mercurial to git bridge, pushed to directly from the hg-git plugin in Hg
GNU General Public License v2.0
620 stars 71 forks source link

pack.py fails to load with python 2.4 #4

Closed johnsonm closed 15 years ago

johnsonm commented 15 years ago

When I tried to use hg-git on a system with python 2.4, I got:

*** failed to import extension hg-git: 'yield' not allowed in a 'try' block with a 'finally' clause (pack.py, line 499)

The following patch seems to resolve that issue (or would, if I could figure out the magic for making patches pasteable from GitHub Flavored Markdown...):

http://gist.github.com/104785

If python 2.4 support is out of scope for hg-git, then go ahead and close this issue as a simple record of a workaround...

defunkt commented 15 years ago

(I edited your post and am checking out the Markdown bug.)

johnsonm commented 15 years ago

Thanks! Now I know what a gist is. :)

stepancheg commented 15 years ago

Still does not work after applying patch:

Traceback (most recent call last):
  File "/usr/bin/hg", line 20, in ?
    mercurial.dispatch.run()
  File "/usr/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-linux-i686.egg/mercurial/dispatch.py", line 20, in run
    sys.exit(dispatch(sys.argv[1:]))
  File "/usr/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-linux-i686.egg/mercurial/dispatch.py", line 29, in dispatch
    return _runcatch(u, args)
  File "/usr/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-linux-i686.egg/mercurial/dispatch.py", line 45, in _runcatch
    return _dispatch(ui, args)
  File "/usr/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-linux-i686.egg/mercurial/dispatch.py", line 367, in _dispatch
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-linux-i686.egg/mercurial/dispatch.py", line 416, in _runcommand
    return checkargs()
  File "/usr/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-linux-i686.egg/mercurial/dispatch.py", line 376, in checkargs
    return cmdfunc()
  File "/usr/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-linux-i686.egg/mercurial/dispatch.py", line 361, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-linux-i686.egg/mercurial/util.py", line 715, in check
    return func(*args, **kwargs)
  File "/home/nga/usr/hg-git/__init__.py", line 84, in gfetch
    git.fetch(remote_name)
  File "/home/nga/usr/hg-git/git_handler.py", line 119, in fetch
    refs = self.fetch_pack(remote_name)
  File "/home/nga/usr/hg-git/git_handler.py", line 411, in fetch_pack
    commit()
  File "/home/nga/usr/hg-git/dulwich/object_store.py", line 213, in commit
    self.move_in_pack(path)
  File "/home/nga/usr/hg-git/dulwich/object_store.py", line 178, in move_in_pack
    p = PackData(path)
  File "/home/nga/usr/hg-git/dulwich/pack.py", line 434, in __init__
    self._read_header()
  File "/home/nga/usr/hg-git/dulwich/pack.py", line 442, in _read_header
    (version, self._num_objects) = read_pack_header(self._file)
  File "/home/nga/usr/hg-git/dulwich/pack.py", line 345, in read_pack_header
    (version,) = unpack_from(">L", header, 4)
  File "/usr/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-linux-i686.egg/mercurial/demandimport.py", line 70, in __call__
    raise TypeError("%s object is not callable" % repr(self))
TypeError: <unloaded module 'unpack_from'> object is not callable
stepancheg commented 15 years ago

Workaround is disabling demandimport: http://gist.github.com/105561

stepancheg commented 15 years ago

Proper patches. except/finally:

http://bitbucket.org/stepancheg/hg-git-patches/src/tip/py1.4

demandimport:

http://bitbucket.org/stepancheg/hg-git-patches/src/tip/demandimport

johnsonm commented 15 years ago

The second trace (addressed by the demandimport patch) is what I reported as issue #5

jelmer commented 15 years ago

The except/finally issue is also fixed upstream in dulwich fwiw

schacon commented 15 years ago

i pulled in the demandimport patch - i'll look at upstream dulwich for other issue fixes

johnsonm commented 15 years ago

I tested 9c97c35bc205 successfully, I confirm fixed.

turian commented 13 years ago

I still have this issue, using dulwich 0.6.1 and the most recent hg-git. What is the issue?

turian commented 13 years ago

This issue still exists using the most recent hg-git and dulwich 0.6.1 under CentOS 5, Python 2.4 and mercurial 1.5