schacon/hg-git

hg gexport dies in export_hg_tags due to lack of null checking

rnewman opened this issue · 0 comments

Apparently some hg tags end up not mapping to a git ref. That means the output of map_git_get is None, and hg-git just passes this into a setter, which tries to concat a newline and dies.

Fix coming momentarily which checks that there's a ref and raises a warning otherwise.

importing Hg objects into Git
** unknown exception encountered, please report by visiting
**  http://mercurial.selenic.com/wiki/BugTracker
** Python 2.7.1 (r271:86832, Apr 28 2011, 16:30:19) [GCC 4.2.1 (Apple Inc. build 5664)]
** Mercurial Distributed SCM (version 1.8.2)
** Extensions loaded: transplant, extdiff, mq, hggit, hgk, patchbomb, rebase
Traceback (most recent call last):
  File "/usr/local/share/python/hg", line 38, in <module>
    mercurial.dispatch.run()
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 16, in run
    sys.exit(dispatch(sys.argv[1:]))
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 36, in dispatch
    return _runcatch(u, args)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 58, in _runcatch
    return _dispatch(ui, args)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 601, in _dispatch
    cmdpats, cmdoptions)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 406, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 655, in _runcommand
    return checkargs()
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 609, in checkargs
    return cmdfunc()
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/dispatch.py", line 598, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/util.py", line 433, in check
    return func(*args, **kwargs)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/extensions.py", line 133, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/util.py", line 433, in check
    return func(*args, **kwargs)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/hgext/mq.py", line 3049, in mqcommand
    return orig(ui, repo, *args, **kwargs)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/mercurial/util.py", line 433, in check
    return func(*args, **kwargs)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/hg_git-0.2.6-py2.7.egg/hggit/__init__.py", line 88, in gexport
    git.export_commits()
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/hg_git-0.2.6-py2.7.egg/hggit/git_handler.py", line 120, in export_commits
    self.export_hg_tags()
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/hg_git-0.2.6-py2.7.egg/hggit/git_handler.py", line 679, in export_hg_tags
    self.git.refs['refs/tags/' + tag] = self.map_git_get(hex(sha))
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/dulwich-0.7.1-py2.7-macosx-10.4-x86_64.egg/dulwich/repo.py", line 304, in __setitem__
    self.set_if_equals(name, None, ref)
  File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/dulwich-0.7.1-py2.7-macosx-10.4-x86_64.egg/dulwich/repo.py", line 599, in set_if_equals
    f.write(new_ref+"\n")
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'