Skip to content
Snippets Groups Projects
Commit 559f24e3 authored by Matt Mackall's avatar Matt Mackall
Browse files

tags: use try/except/finally

parent 140c2d1e
No related branches found
No related tags found
No related merge requests found
......@@ -509,4 +509,5 @@
return
try:
f = repo.vfs.open(_fnodescachefile, 'ab')
try:
......@@ -512,19 +513,9 @@
try:
f = repo.vfs.open(_fnodescachefile, 'ab')
try:
# if the file has been truncated
actualoffset = f.tell()
if actualoffset < self._dirtyoffset:
self._dirtyoffset = actualoffset
data = self._raw[self._dirtyoffset:]
f.seek(self._dirtyoffset)
f.truncate()
repo.ui.log('tagscache',
'writing %d bytes to %s\n' % (
len(data), _fnodescachefile))
f.write(data)
self._dirtyoffset = None
finally:
f.close()
except (IOError, OSError), inst:
# if the file has been truncated
actualoffset = f.tell()
if actualoffset < self._dirtyoffset:
self._dirtyoffset = actualoffset
data = self._raw[self._dirtyoffset:]
f.seek(self._dirtyoffset)
f.truncate()
repo.ui.log('tagscache',
......@@ -530,5 +521,13 @@
repo.ui.log('tagscache',
"couldn't write %s: %s\n" % (
_fnodescachefile, inst))
'writing %d bytes to %s\n' % (
len(data), _fnodescachefile))
f.write(data)
self._dirtyoffset = None
finally:
f.close()
except (IOError, OSError), inst:
repo.ui.log('tagscache',
"couldn't write %s: %s\n" % (
_fnodescachefile, inst))
finally:
lock.release()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment