mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
git_handler.save_remote_refs: use an atomic temp file to write
This bug becomes obvious now that the code is structured like this.
This commit is contained in:
parent
22561bae4b
commit
1a2929b055
@ -207,10 +207,11 @@ class GitHandler(object):
|
||||
self._remote_refs.update([(name, bin(sha)) for sha, name in td])
|
||||
|
||||
def save_remote_refs(self):
|
||||
tf = open(self.repo.join(self.remote_refs_file), 'wb')
|
||||
file = self.repo.opener(self.remote_refs_file, 'w+', atomictemp=True)
|
||||
for tag, node in self.remote_refs.iteritems():
|
||||
tf.write('%s %s\n' % (hex(node), tag))
|
||||
tf.close()
|
||||
file.write('%s %s\n' % (hex(node), tag))
|
||||
# If this complains, atomictempfile no longer has close
|
||||
file.close()
|
||||
|
||||
## END FILE LOAD AND SAVE METHODS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user