Mercurial > hg
comparison mercurial/localrepo.py @ 26488:df2dc5141721
localrepo: add a way to get the current lock if it's held
We'll use this in upcoming patches to return a reference to the wlock if it's
held.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 05 Oct 2015 14:26:53 -0700 |
parents | efd57cd6fd1d |
children | 2a3fc0272e3f |
comparison
equal
deleted
inserted
replaced
26487:3f234db6fe8d | 26488:df2dc5141721 |
---|---|
1298 self.invalidatedirstate, _('working directory of %s') % | 1298 self.invalidatedirstate, _('working directory of %s') % |
1299 self.origroot, parentenvvar='HG_WLOCK_LOCKER') | 1299 self.origroot, parentenvvar='HG_WLOCK_LOCKER') |
1300 self._wlockref = weakref.ref(l) | 1300 self._wlockref = weakref.ref(l) |
1301 return l | 1301 return l |
1302 | 1302 |
1303 def _currentlock(self, lockref): | |
1304 """Returns the lock if it's held, or None if it's not.""" | |
1305 if lockref is None: | |
1306 return None | |
1307 l = lockref() | |
1308 if l is None or not l.held: | |
1309 return None | |
1310 return l | |
1311 | |
1303 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): | 1312 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): |
1304 """ | 1313 """ |
1305 commit an individual file as part of a larger transaction | 1314 commit an individual file as part of a larger transaction |
1306 """ | 1315 """ |
1307 | 1316 |