topic: make sure we have the 'wlock' when setting topic
We where writing the '.hg/topic' file without a lot. That was bad.
--- a/hgext3rd/topic/__init__.py Wed Jul 13 16:19:41 2016 +0200
+++ b/hgext3rd/topic/__init__.py Thu Aug 11 22:50:58 2016 +0200
@@ -259,8 +259,9 @@
repo.vfs.unlink('topic')
return
if topic:
- with repo.vfs.open('topic', 'w') as f:
- f.write(topic)
+ with repo.wlock():
+ with repo.vfs.open('topic', 'w') as f:
+ f.write(topic)
return
current = repo.currenttopic
for t in sorted(repo.topics):
@@ -275,11 +276,12 @@
ui.write(_("topic: %s\n") % t)
def commitwrap(orig, ui, repo, *args, **opts):
- if opts.get('topic'):
- t = opts['topic']
- with repo.vfs.open('topic', 'w') as f:
- f.write(t)
- return orig(ui, repo, *args, **opts)
+ with repo.wlock():
+ if opts.get('topic'):
+ t = opts['topic']
+ with repo.vfs.open('topic', 'w') as f:
+ f.write(t)
+ return orig(ui, repo, *args, **opts)
def committextwrap(orig, repo, ctx, subs, extramsg):
ret = orig(repo, ctx, subs, extramsg)