257 if clear: |
257 if clear: |
258 if repo.vfs.exists('topic'): |
258 if repo.vfs.exists('topic'): |
259 repo.vfs.unlink('topic') |
259 repo.vfs.unlink('topic') |
260 return |
260 return |
261 if topic: |
261 if topic: |
262 with repo.vfs.open('topic', 'w') as f: |
262 with repo.wlock(): |
263 f.write(topic) |
263 with repo.vfs.open('topic', 'w') as f: |
|
264 f.write(topic) |
264 return |
265 return |
265 current = repo.currenttopic |
266 current = repo.currenttopic |
266 for t in sorted(repo.topics): |
267 for t in sorted(repo.topics): |
267 marker = '*' if t == current else ' ' |
268 marker = '*' if t == current else ' ' |
268 ui.write(' %s %s\n' % (marker, t)) |
269 ui.write(' %s %s\n' % (marker, t)) |
273 return |
274 return |
274 # i18n: column positioning for "hg summary" |
275 # i18n: column positioning for "hg summary" |
275 ui.write(_("topic: %s\n") % t) |
276 ui.write(_("topic: %s\n") % t) |
276 |
277 |
277 def commitwrap(orig, ui, repo, *args, **opts): |
278 def commitwrap(orig, ui, repo, *args, **opts): |
278 if opts.get('topic'): |
279 with repo.wlock(): |
279 t = opts['topic'] |
280 if opts.get('topic'): |
280 with repo.vfs.open('topic', 'w') as f: |
281 t = opts['topic'] |
281 f.write(t) |
282 with repo.vfs.open('topic', 'w') as f: |
282 return orig(ui, repo, *args, **opts) |
283 f.write(t) |
|
284 return orig(ui, repo, *args, **opts) |
283 |
285 |
284 def committextwrap(orig, repo, ctx, subs, extramsg): |
286 def committextwrap(orig, repo, ctx, subs, extramsg): |
285 ret = orig(repo, ctx, subs, extramsg) |
287 ret = orig(repo, ctx, subs, extramsg) |
286 t = repo.currenttopic |
288 t = repo.currenttopic |
287 if t: |
289 if t: |