Mercurial > evolve
diff hgext3rd/topic/__init__.py @ 6204:364ef033da03
topic: shorter code to write current topic
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sun, 13 Mar 2022 18:44:14 +0300 |
parents | 5bd5a7ab32d3 |
children | 9d81041f735f |
line wrap: on
line diff
--- 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: