views:

174

answers:

3

I'm getting an error trying to convert a git repository to mercurial. When I run:

hg convert gitdir hgdir

I get this:

UnboundLocalError: local variable 'tz' referenced before assignment

Background: I just installed TortoiseHg and enabled the convert extension.

It looks like nmercurial convert is having a problem with the git repository. I've been managing the git repository with git-gui (under windows).

Here's the full output:

scanning source...
** 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: extdiff, convert
Traceback (most recent call last):
  File "hg", line 36, in <module>
  File "mercurial\dispatch.pyo", line 16, in run
  File "mercurial\dispatch.pyo", line 30, in dispatch
  File "mercurial\dispatch.pyo", line 46, in _runcatch
  File "mercurial\dispatch.pyo", line 449, in _dispatch
  File "mercurial\dispatch.pyo", line 319, in runcommand
  File "mercurial\dispatch.pyo", line 500, in _runcommand
  File "mercurial\dispatch.pyo", line 454, in checkargs
  File "mercurial\dispatch.pyo", line 448, in <lambda>
  File "mercurial\util.pyo", line 386, in check
  File "hgext\convert\__init__.pyo", line 229, in convert
  File "hgext\convert\convcmd.pyo", line 398, in convert
  File "hgext\convert\convcmd.pyo", line 312, in convert
  File "hgext\convert\convcmd.pyo", line 109, in walktree
  File "hgext\convert\convcmd.pyo", line 267, in cachecommit
  File "hgext\convert\git.pyo", line 112, in getcommit
UnboundLocalError: local variable 'tz' referenced before assignment
A: 

Looks to me like that convert extension is broken and needs fixing, so perhaps you should heed the advice right at the beginning of the message.

I have no experience at all with Mercurial, so all I can offer is a simple workaround: combine git's built-in fast-export and hg-fastimport. Good luck!

Jan Krüger
+1  A: 

It seems that this part of the convert extension expects either 'author' or 'committer' to be set at some point of the log parsing code. Can you try to track down which commit was being converted at the time and show us "git log" output for this commit?

Giorgos Keramidas
I've come to the same conclusion but I have not figured out how to determine which commit is causing the problem. It looks like hg convert is the scanning phase, not in the converting phase.
jdigital
+1  A: 

With help from Patrick (see the thread referenced by Martin Geisler above), I've discovered the cause of the problem: a cmd.exe AutoRun registry entry that output a line of text.

Mercurial convert was not expecting this extra line (which was output when mercurial ran git commands to traverse the existing repository) and it caused the convert program to choke. Removing the AutoRun entry (HKLM\Software\Microsoft\Command Processor\AutoRun) eliminated the exception.

jdigital