comparison mercurial/localrepo.py @ 10428:e553a425751d stable

convert: differentiate between IOError and OSError on commitctx() The IOError exception is overloaded to mean 'this file was deleted in the current commit'. Separate the code that handles IOError and file deletion from general OSError exceptions. The latter are real errors, but IOError is not always a throwable error. This solves the accidental marking of files as 'deleted' in commits that try to write for example in .hg/store/data revlogs that the current user has no permission to modify (a normal OSError that should abort the current commit). Changed by pmezard: use getattr() to be on the safe side.
author Giorgos Keramidas <keramida@ceid.upatras.gr>
date Thu, 11 Feb 2010 23:15:42 +0200
parents 25e572394f5c
children 1c50a954a524
comparison
equal deleted inserted replaced
10417:58e040c51231 10428:e553a425751d
874 try: 874 try:
875 fctx = ctx[f] 875 fctx = ctx[f]
876 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp, 876 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp,
877 changed) 877 changed)
878 m1.set(f, fctx.flags()) 878 m1.set(f, fctx.flags())
879 except (OSError, IOError): 879 except OSError, inst:
880 if error: 880 self.ui.warn(_("trouble committing %s!\n") % f)
881 raise
882 except IOError, inst:
883 errcode = getattr(inst, 'errno', errno.ENOENT)
884 if error or errcode and errcode != errno.ENOENT:
881 self.ui.warn(_("trouble committing %s!\n") % f) 885 self.ui.warn(_("trouble committing %s!\n") % f)
882 raise 886 raise
883 else: 887 else:
884 removed.append(f) 888 removed.append(f)
885 889