commands: get rid of empty try/finally block from _dograft
This diff is purely an indentation change to clean up a block that
was kept in place to make
77995317b374 easier to read.
commands: get rid of empty try/finally block from _dobackout
This diff is purely an indentation change to clean up a block that
was kept in place to make
c7217f1458bf easier to read.
commands: get rid of empty try/finally block from import_
This diff is purely an indentation change to clean up a block that
was kept in place to make
713b09fc9fbb easier to read.
streamclone: use context manager for writing files
These are the file writes that have the most to gain from background
I/O. Plug in a context manager so I can design the background I/O
mechanism with context managers in mind.
scmutil: use context managers for file handles
Now that we dropped support for Python 2.4, we are able to use context
managers. Let's replace the try..finally pattern in scmutil.py with
context managers, which close files automatically when the context
manager is exited.
There should be no change in behavior with this patch.
Why convert to context managers if nothing is broken? I'm working on
closing file handles in background threads to improve performance on
Windows. As part of this, I realized there could be some future issues
if the background file closing code isn't designed with context
managers in mind. So, I'd like to switch some code to context managers
so I can design an API that works with context managers.
statichttprepo: implement __enter__ and __exit__ on httprangeheader
httprangeheader behaves like a file object. Implement __enter__ and
__exit__ so it can be used as a context manager, just like file objects.
osutil: implement __enter__ and __exit__ on posixfile
So they can be used as context managers.