##// END OF EJS Templates
tags: use try/except/finally
Matt Mackall -
r25087:559f24e3 default
parent child Browse files
Show More
@@ -509,26 +509,25 b' class hgtagsfnodescache(object):'
509 509 return
510 510
511 511 try:
512 f = repo.vfs.open(_fnodescachefile, 'ab')
512 513 try:
513 f = repo.vfs.open(_fnodescachefile, 'ab')
514 try:
515 # if the file has been truncated
516 actualoffset = f.tell()
517 if actualoffset < self._dirtyoffset:
518 self._dirtyoffset = actualoffset
519 data = self._raw[self._dirtyoffset:]
520 f.seek(self._dirtyoffset)
521 f.truncate()
522 repo.ui.log('tagscache',
523 'writing %d bytes to %s\n' % (
524 len(data), _fnodescachefile))
525 f.write(data)
526 self._dirtyoffset = None
527 finally:
528 f.close()
529 except (IOError, OSError), inst:
514 # if the file has been truncated
515 actualoffset = f.tell()
516 if actualoffset < self._dirtyoffset:
517 self._dirtyoffset = actualoffset
518 data = self._raw[self._dirtyoffset:]
519 f.seek(self._dirtyoffset)
520 f.truncate()
530 521 repo.ui.log('tagscache',
531 "couldn't write %s: %s\n" % (
532 _fnodescachefile, inst))
522 'writing %d bytes to %s\n' % (
523 len(data), _fnodescachefile))
524 f.write(data)
525 self._dirtyoffset = None
526 finally:
527 f.close()
528 except (IOError, OSError), inst:
529 repo.ui.log('tagscache',
530 "couldn't write %s: %s\n" % (
531 _fnodescachefile, inst))
533 532 finally:
534 533 lock.release()
General Comments 0
You need to be logged in to leave comments. Login now