hg2git.py: Don't complain die for non-existent heads
authorRocco Rutte <pdmef@gmx.net>
Mon, 12 Mar 2007 11:13:48 +0000 (11:13 +0000)
committerRocco Rutte <pdmef@gmx.net>
Mon, 12 Mar 2007 11:13:48 +0000 (11:13 +0000)
Previously, when no head was present under .git/refs/heads, we simply
died as we couldn't open the file. Now, simply return None in case we
cannot read from it.

Signed-off-by: Rocco Rutte <pdmef@gmx.net>
hg2git.py

index 9ac395b..e098c3d 100644 (file)
--- a/hg2git.py
+++ b/hg2git.py
@@ -307,10 +307,13 @@ def save_cache(filename,cache):
 
 def verify_heads(ui,repo,cache):
   def getsha1(branch):
-    f=open(os.getenv('GIT_DIR','/dev/null')+'/refs/heads/'+branch)
-    sha1=f.readlines()[0].split('\n')[0]
-    f.close()
-    return sha1
+    try:
+      f=open(os.getenv('GIT_DIR','/dev/null')+'/refs/heads/'+branch)
+      sha1=f.readlines()[0].split('\n')[0]
+      f.close()
+      return sha1
+    except IOError:
+      return None
 
   # get list of hg's branches to verify, don't take all git has
   branches=repo.branchtags()