Mercurial > hg
changeset 27798:8953e963ce8c
sshpeer: make remotelock a context manager
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Fri, 15 Jan 2016 13:14:50 -0800 |
parents | 054abf2377e8 |
children | 24b4dbb16c60 |
files | mercurial/sshpeer.py |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/sshpeer.py Fri Jan 15 13:14:45 2016 -0800 +++ b/mercurial/sshpeer.py Fri Jan 15 13:14:50 2016 -0800 @@ -22,6 +22,11 @@ def release(self): self.repo.unlock() self.repo = None + def __enter__(self): + return self + def __exit__(self, exc_type, exc_val, exc_tb): + if self.repo: + self.release() def __del__(self): if self.repo: self.release()