# HG changeset patch # User Anton Shestakov # Date 1647186254 -10800 # Node ID 364ef033da03d9c258b3ef7321dfece4166a60b3 # Parent fbbf69c71aa48820357e25837982275a4dcec11d topic: shorter code to write current topic diff -r fbbf69c71aa4 -r 364ef033da03 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Sun Mar 13 18:43:35 2022 +0300 +++ b/hgext3rd/topic/__init__.py Sun Mar 13 18:44:14 2022 +0300 @@ -1054,8 +1054,7 @@ if newtopic: with repo.wlock(): - with repo.vfs.open(b'topic', b'w') as f: - f.write(newtopic) + repo.vfs.write(b'topic', newtopic) else: if repo.vfs.exists(b'topic'): repo.vfs.unlink(b'topic') @@ -1317,8 +1316,7 @@ hint = _(b"see 'hg help -e topic.topic-mode' for details") if opts.get('topic'): t = opts['topic'] - with repo.vfs.open(b'topic', b'w') as f: - f.write(t) + repo.vfs.write(b'topic', t) elif opts.get('amend'): pass elif notopic and mayabort: @@ -1329,8 +1327,7 @@ if not ui.quiet: ui.warn((b"(%s)\n") % hint) elif notopic and mayrandom: - with repo.vfs.open(b'topic', b'w') as f: - f.write(randomname.randomtopicname(ui)) + repo.vfs.write(b'topic', randomname.randomtopicname(ui)) return orig(ui, repo, *args, **opts) def committextwrap(orig, repo, ctx, subs, extramsg): @@ -1407,8 +1404,7 @@ pctx = repo[node] if pctx.phase() > phases.public: t = pctx.topic() - with repo.vfs.open(b'topic', b'w') as f: - f.write(t) + repo.vfs.write(b'topic', t) if t and t != ot: repo.ui.status(_(b"switching to topic %s\n") % t) if ot and not t: