comparison mercurial/util.py @ 2220:6d3cc2a982f3

add filename to IOError if read of file fails. if file replaced with directory or symlink, IOError not fully filled out.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Mon, 08 May 2006 08:20:56 -0700
parents fb28ce04b349
children 4a069064a39b
comparison
equal deleted inserted replaced
2219:ec82cff7d2c4 2220:6d3cc2a982f3
685 d, fn = os.path.split(name) 685 d, fn = os.path.split(name)
686 fd, temp = tempfile.mkstemp(prefix='.%s-' % fn, dir=d) 686 fd, temp = tempfile.mkstemp(prefix='.%s-' % fn, dir=d)
687 os.close(fd) 687 os.close(fd)
688 fp = posixfile(temp, "wb") 688 fp = posixfile(temp, "wb")
689 try: 689 try:
690 fp.write(posixfile(name, "rb").read()) 690 try:
691 s = posixfile(name, "rb").read()
692 except IOError, inst:
693 if not getattr(inst, 'filename', None):
694 inst.filename = name
695 raise
696 fp.write(s)
691 except: 697 except:
692 try: os.unlink(temp) 698 try: os.unlink(temp)
693 except: pass 699 except: pass
694 raise 700 raise
695 fp.close() 701 fp.close()