continue: ensure we hold the wlock before writing file to disk
A hack in 'hg evolve --continue' involve writing a 'graftstate' file. We take
the wlock before doing so.
--- a/hgext/evolve.py Tue Aug 09 00:37:58 2016 +0200
+++ b/hgext/evolve.py Thu Aug 11 23:00:46 2016 +0200
@@ -1794,14 +1794,18 @@
raise error.Abort('no evolve to continue')
orig = repo[state['current']]
# XXX This is a terrible terrible hack, please get rid of it.
- repo.opener.write('graftstate', orig.hex() + '\n')
+ lock = repo.wlock()
try:
- graftcmd = commands.table['graft'][0]
- ret = graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
- _evolvestatedelete(repo)
- return ret
+ repo.opener.write('graftstate', orig.hex() + '\n')
+ try:
+ graftcmd = commands.table['graft'][0]
+ ret = graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
+ _evolvestatedelete(repo)
+ return ret
+ finally:
+ util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
finally:
- util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
+ lock.release()
cmdutil.bailifchanged(repo)