##// 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 return
509 return
510
510
511 try:
511 try:
512 f = repo.vfs.open(_fnodescachefile, 'ab')
512 try:
513 try:
513 f = repo.vfs.open(_fnodescachefile, 'ab')
514 # if the file has been truncated
514 try:
515 actualoffset = f.tell()
515 # if the file has been truncated
516 if actualoffset < self._dirtyoffset:
516 actualoffset = f.tell()
517 self._dirtyoffset = actualoffset
517 if actualoffset < self._dirtyoffset:
518 data = self._raw[self._dirtyoffset:]
518 self._dirtyoffset = actualoffset
519 f.seek(self._dirtyoffset)
519 data = self._raw[self._dirtyoffset:]
520 f.truncate()
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:
530 repo.ui.log('tagscache',
521 repo.ui.log('tagscache',
531 "couldn't write %s: %s\n" % (
522 'writing %d bytes to %s\n' % (
532 _fnodescachefile, inst))
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 finally:
532 finally:
534 lock.release()
533 lock.release()
General Comments 0
You need to be logged in to leave comments. Login now