# HG changeset patch # User Bryan O'Sullivan # Date 1452638841 28800 # Node ID 3ea35a0769fe3d2401f5399e6cf80fa0b8f8998d # Parent 8ceaaf63ca803c96922aa1bf0563752d062d77a1 shelve: use a context manager for file I/O in listcmd diff -r 8ceaaf63ca80 -r 3ea35a0769fe hgext/shelve.py --- a/hgext/shelve.py Tue Jan 12 14:31:02 2016 -0800 +++ b/hgext/shelve.py Tue Jan 12 14:47:21 2016 -0800 @@ -424,8 +424,7 @@ ui.write(age, label='shelve.age') ui.write(' ' * (12 - len(age))) used += 12 - fp = open(name + '.patch', 'rb') - try: + with open(name + '.patch', 'rb') as fp: while True: line = fp.readline() if not line: @@ -447,8 +446,6 @@ for chunk, label in patch.diffstatui(difflines, width=width, git=True): ui.write(chunk, label=label) - finally: - fp.close() def singlepatchcmds(ui, repo, pats, opts, subcommand): """subcommand that displays a single shelf"""