[PATCH 1 of 7] share: use context manager or utility function to write file
Yuya Nishihara
yuya at tcha.org
Sat Jan 13 05:02:52 UTC 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1515817396 -32400
# Sat Jan 13 13:23:16 2018 +0900
# Node ID 2eeaf96c20fce19c8edccf4936aceee4ce651de9
# Parent 991f0be9dc39c402d63a4a8f19cde052095c4689
share: use context manager or utility function to write file
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -307,16 +307,13 @@ def postshare(sourcerepo, destrepo, book
"""
default = defaultpath or sourcerepo.ui.config('paths', 'default')
if default:
- fp = destrepo.vfs("hgrc", "w", text=True)
- fp.write("[paths]\n")
- fp.write("default = %s\n" % default)
- fp.close()
+ with destrepo.vfs("hgrc", "w", text=True) as fp:
+ fp.write("[paths]\n")
+ fp.write("default = %s\n" % default)
with destrepo.wlock():
if bookmarks:
- fp = destrepo.vfs('shared', 'w')
- fp.write(sharedbookmarks + '\n')
- fp.close()
+ destrepo.vfs.write('shared', sharedbookmarks + '\n')
def _postshareupdate(repo, update, checkout=None):
"""Maybe perform a working directory update after a shared repo is created.
More information about the Mercurial-devel
mailing list