# HG changeset patch # User Thomas Arendsen Hein # Date 1227868721 -3600 # Node ID f792c7bb2fb3fd022bf165cbc1e59ec1edad4452 # Parent 1e0677756f604aae2f689537cc59d0af2fb30072 Improvement to 14ce129cfcd: Use try/except and pass filename on errors Without the second part, the error message would be abort: Is a directory instead of abort: Is a directory: /home/user/.cvspass diff -r 1e0677756f60 -r f792c7bb2fb3 hgext/convert/cvs.py --- a/hgext/convert/cvs.py Fri Nov 28 09:50:30 2008 +0100 +++ b/hgext/convert/cvs.py Fri Nov 28 11:38:41 2008 +0100 @@ -1,6 +1,6 @@ # CVS conversion code inspired by hg-cvs-import and git-cvsimport -import os, locale, re, socket +import os, locale, re, socket, errno from cStringIO import StringIO from mercurial import util from mercurial.i18n import _ @@ -202,7 +202,7 @@ if not passw: passw = "A" cvspass = os.path.expanduser("~/.cvspass") - if os.path.exists(cvspass): + try: pf = open(cvspass) for line in pf.read().splitlines(): part1, part2 = line.split(' ', 1) @@ -217,6 +217,11 @@ passw = part2 break pf.close() + except IOError, inst: + if inst.errno != errno.ENOENT: + if not getattr(inst, 'filename', None): + inst.filename = cvspass + raise sck = socket.socket() sck.connect((serv, port))