Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hg.py @ 638:35f7adfefa69
Add a scheme for handling remote locking
This adds an object that remembers to unlock the remote repo on
destruction and lock/unlock functions for the ssh protocol. The remote
repository should also unlock itself when the connection goes down.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 06 Jul 2005 22:23:27 -0800 |
parents | 31e090c34d3b |
children | 31cebba881a0 |
line wrap: on
line diff
--- a/mercurial/hg.py Wed Jul 06 22:21:23 2005 -0800 +++ b/mercurial/hg.py Wed Jul 06 22:23:27 2005 -0800 @@ -1620,6 +1620,15 @@ return zread(f) +class remotelock: + def __init__(self, repo): + self.repo = repo + def release(self): + self.repo.unlock() + self.repo = None + def __del__(self): + if self.repo: + self.release() class sshrepository: def __init__(self, ui, path): @@ -1666,6 +1675,13 @@ l = int(r.readline()) return r.read(l) + def lock(self): + self.call("lock") + return remotelock(self) + + def unlock(self): + self.call("unlock") + def heads(self): d = self.call("heads") try: