Mercurial > hg
changeset 7444:f792c7bb2fb3
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
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Nov 2008 11:38:41 +0100 |
parents | 1e0677756f60 |
children | 29c6e71b1c73 |
files | hgext/convert/cvs.py |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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))