##// END OF EJS Templates
lock: pass "success" boolean to _afterlock callbacks...
Kyle Lippincott -
r44217:888bd39e default
parent child Browse files
Show More
@@ -1063,7 +1063,7 b' def wcpprefetch(ui, repo, **kwargs):'
1063 # update a revset with a date limit
1063 # update a revset with a date limit
1064 bgprefetchrevs = revdatelimit(ui, bgprefetchrevs)
1064 bgprefetchrevs = revdatelimit(ui, bgprefetchrevs)
1065
1065
1066 def anon():
1066 def anon(unused_success):
1067 if util.safehasattr(repo, b'ranprefetch') and repo.ranprefetch:
1067 if util.safehasattr(repo, b'ranprefetch') and repo.ranprefetch:
1068 return
1068 return
1069 repo.ranprefetch = True
1069 repo.ranprefetch = True
@@ -2372,7 +2372,7 b' def handlebookmark(op, inpart):'
2372
2372
2373 if pushkeycompat:
2373 if pushkeycompat:
2374
2374
2375 def runhook():
2375 def runhook(unused_success):
2376 for hookargs in allhooks:
2376 for hookargs in allhooks:
2377 op.repo.hook(b'pushkey', **pycompat.strkwargs(hookargs))
2377 op.repo.hook(b'pushkey', **pycompat.strkwargs(hookargs))
2378
2378
@@ -436,7 +436,7 b' class cg1unpacker(object):'
436
436
437 if changesets > 0:
437 if changesets > 0:
438
438
439 def runhooks():
439 def runhooks(unused_success):
440 # These hooks run when the lock releases, not when the
440 # These hooks run when the lock releases, not when the
441 # transaction closes. So it's possible for the changelog
441 # transaction closes. So it's possible for the changelog
442 # to have changed since we last saw it.
442 # to have changed since we last saw it.
@@ -2203,7 +2203,7 b' class localrepository(object):'
2203 # fixes the function accumulation.
2203 # fixes the function accumulation.
2204 hookargs = tr2.hookargs
2204 hookargs = tr2.hookargs
2205
2205
2206 def hookfunc():
2206 def hookfunc(unused_success):
2207 repo = reporef()
2207 repo = reporef()
2208 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2208 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2209 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2209 bmchanges = sorted(tr.changes[b'bookmarks'].items())
@@ -2615,7 +2615,7 b' class localrepository(object):'
2615 l.postrelease.append(callback)
2615 l.postrelease.append(callback)
2616 break
2616 break
2617 else: # no lock have been found.
2617 else: # no lock have been found.
2618 callback()
2618 callback(True)
2619
2619
2620 def lock(self, wait=True):
2620 def lock(self, wait=True):
2621 '''Lock the repository store (.hg/store) and return a weak reference
2621 '''Lock the repository store (.hg/store) and return a weak reference
@@ -2953,7 +2953,7 b' class localrepository(object):'
2953 )
2953 )
2954 raise
2954 raise
2955
2955
2956 def commithook():
2956 def commithook(unused_success):
2957 # hack for command that use a temporary commit (eg: histedit)
2957 # hack for command that use a temporary commit (eg: histedit)
2958 # temporary commit got stripped before hook release
2958 # temporary commit got stripped before hook release
2959 if self.changelog.hasnode(ret):
2959 if self.changelog.hasnode(ret):
@@ -3399,7 +3399,7 b' class localrepository(object):'
3399 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3399 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3400 ret = pushkey.push(self, namespace, key, old, new)
3400 ret = pushkey.push(self, namespace, key, old, new)
3401
3401
3402 def runhook():
3402 def runhook(unused_success):
3403 self.hook(
3403 self.hook(
3404 b'pushkey',
3404 b'pushkey',
3405 namespace=namespace,
3405 namespace=namespace,
@@ -233,7 +233,8 b' class lock(object):'
233 return self
233 return self
234
234
235 def __exit__(self, exc_type, exc_value, exc_tb):
235 def __exit__(self, exc_type, exc_value, exc_tb):
236 self.release()
236 success = all(a is None for a in (exc_type, exc_value, exc_tb))
237 self.release(success=success)
237
238
238 def __del__(self):
239 def __del__(self):
239 if self.held:
240 if self.held:
@@ -408,7 +409,7 b' class lock(object):'
408 self.acquirefn()
409 self.acquirefn()
409 self._inherited = False
410 self._inherited = False
410
411
411 def release(self):
412 def release(self, success=True):
412 """release the lock and execute callback function if any
413 """release the lock and execute callback function if any
413
414
414 If the lock has been acquired multiple times, the actual release is
415 If the lock has been acquired multiple times, the actual release is
@@ -433,7 +434,7 b' class lock(object):'
433 # at all.
434 # at all.
434 if not self._parentheld:
435 if not self._parentheld:
435 for callback in self.postrelease:
436 for callback in self.postrelease:
436 callback()
437 callback(success)
437 # Prevent double usage and help clear cycles.
438 # Prevent double usage and help clear cycles.
438 self.postrelease = None
439 self.postrelease = None
439
440
@@ -1572,7 +1572,11 b' class manifestrevlog(object):'
1572 reporef = weakref.ref(repo)
1572 reporef = weakref.ref(repo)
1573 manifestrevlogref = weakref.ref(self)
1573 manifestrevlogref = weakref.ref(self)
1574
1574
1575 def persistmanifestcache():
1575 def persistmanifestcache(success):
1576 # Repo is in an unknown state, do not persist.
1577 if not success:
1578 return
1579
1576 repo = reporef()
1580 repo = reporef()
1577 self = manifestrevlogref()
1581 self = manifestrevlogref()
1578 if repo is None or self is None:
1582 if repo is None or self is None:
@@ -65,7 +65,7 b' class teststate(object):'
65 def releasefn(self):
65 def releasefn(self):
66 self._releasecalled = True
66 self._releasecalled = True
67
67
68 def postreleasefn(self):
68 def postreleasefn(self, success):
69 self._postreleasecalled = True
69 self._postreleasecalled = True
70
70
71 def assertacquirecalled(self, called):
71 def assertacquirecalled(self, called):
General Comments 0
You need to be logged in to leave comments. Login now