Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 26321:db4c192cb9b3
lock: move acquirefn call to inside the lock
We're going to need to call it again as part of reinitialization after a
subprocess inherits the lock.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 22 Sep 2015 14:09:42 -0700 |
parents | 3ac7acb99b04 |
children | 2cd19782d2d4 |
comparison
equal
deleted
inserted
replaced
26320:3ac7acb99b04 | 26321:db4c192cb9b3 |
---|---|
1208 continue | 1208 continue |
1209 ce.refresh() | 1209 ce.refresh() |
1210 | 1210 |
1211 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc): | 1211 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc): |
1212 try: | 1212 try: |
1213 l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn, desc=desc) | 1213 l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn, |
1214 acquirefn=acquirefn, desc=desc) | |
1214 except error.LockHeld as inst: | 1215 except error.LockHeld as inst: |
1215 if not wait: | 1216 if not wait: |
1216 raise | 1217 raise |
1217 self.ui.warn(_("waiting for lock on %s held by %r\n") % | 1218 self.ui.warn(_("waiting for lock on %s held by %r\n") % |
1218 (desc, inst.locker)) | 1219 (desc, inst.locker)) |
1219 # default to 600 seconds timeout | 1220 # default to 600 seconds timeout |
1220 l = lockmod.lock(vfs, lockname, | 1221 l = lockmod.lock(vfs, lockname, |
1221 int(self.ui.config("ui", "timeout", "600")), | 1222 int(self.ui.config("ui", "timeout", "600")), |
1222 releasefn=releasefn, desc=desc) | 1223 releasefn=releasefn, acquirefn=acquirefn, |
1224 desc=desc) | |
1223 self.ui.warn(_("got lock after %s seconds\n") % l.delay) | 1225 self.ui.warn(_("got lock after %s seconds\n") % l.delay) |
1224 if acquirefn: | |
1225 acquirefn() | |
1226 return l | 1226 return l |
1227 | 1227 |
1228 def _afterlock(self, callback): | 1228 def _afterlock(self, callback): |
1229 """add a callback to be run when the repository is fully unlocked | 1229 """add a callback to be run when the repository is fully unlocked |
1230 | 1230 |