diff -r 52670eaa14b4 -r 678d760c71ff hgext/shelve.py --- a/hgext/shelve.py Thu Apr 12 22:39:43 2018 +0900 +++ b/hgext/shelve.py Thu Apr 12 22:59:49 2018 +0900 @@ -413,9 +413,8 @@ def _shelvecreatedcommit(repo, node, name): bases = list(mutableancestors(repo[node])) shelvedfile(repo, name, 'hg').writebundle(bases, node) - cmdutil.export(repo, [node], - fp=shelvedfile(repo, name, patchextension).opener('wb'), - opts=mdiff.diffopts(git=True)) + with shelvedfile(repo, name, patchextension).opener('wb') as fp: + cmdutil.exportfile(repo, [node], fp, opts=mdiff.diffopts(git=True)) def _includeunknownfiles(repo, pats, opts, extra): s = repo.status(match=scmutil.match(repo[None], pats, opts),