Skip to content
Snippets Groups Projects
Commit df76808d authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

dirstate: use a context manager to handle the file used for writing the branch

This is more modern.
parent 444fa55f
No related branches found
No related tags found
3 merge requests!485branching: merge default into stable,!483cleanup branch hack in the transaction.,!482write branch in the transaction when applicable
......@@ -613,6 +613,6 @@
def setbranch(self, branch):
self.__class__._branch.set(self, encoding.fromlocal(branch))
f = self._opener(b'branch', b'w', atomictemp=True, checkambig=True)
try:
vfs = self._opener
with vfs(b'branch', b'w', atomictemp=True, checkambig=True) as f:
f.write(self._branch + b'\n')
......@@ -618,5 +618,3 @@
f.write(self._branch + b'\n')
f.close()
# make sure filecache has the correct stat info for _branch after
# replacing the underlying file
......@@ -621,5 +619,8 @@
# make sure filecache has the correct stat info for _branch after
# replacing the underlying file
#
# XXX do we actually need this,
# refreshing the attribute is quite cheap
ce = self._filecache[b'_branch']
if ce:
ce.refresh()
......@@ -623,9 +624,6 @@
ce = self._filecache[b'_branch']
if ce:
ce.refresh()
except: # re-raises
f.discard()
raise
def invalidate(self):
"""Causes the next access to reread the dirstate.
......
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