From 191928202b5156a466f2c3ec200ae7058e4ea889 Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Mon, 12 Mar 2007 11:13:48 +0000 Subject: [PATCH] hg2git.py: Don't complain die for non-existent heads 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 --- hg2git.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hg2git.py b/hg2git.py index 9ac395b..e098c3d 100644 --- 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() -- 2.11.4.GIT