mercurial/localrepo.py
changeset 46794 e2f7b2695ba1
parent 46780 6266d19556ad
parent 46793 86b47ec1960a
child 46819 d4ba4d51f85f
equal deleted inserted replaced
46782:6b52cffd8d0a 46794:e2f7b2695ba1
  2334         if desc != b'strip' and shouldtracktags:
  2334         if desc != b'strip' and shouldtracktags:
  2335             oldheads = self.changelog.headrevs()
  2335             oldheads = self.changelog.headrevs()
  2336 
  2336 
  2337             def tracktags(tr2):
  2337             def tracktags(tr2):
  2338                 repo = reporef()
  2338                 repo = reporef()
       
  2339                 assert repo is not None  # help pytype
  2339                 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
  2340                 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
  2340                 newheads = repo.changelog.headrevs()
  2341                 newheads = repo.changelog.headrevs()
  2341                 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
  2342                 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
  2342                 # notes: we compare lists here.
  2343                 # notes: we compare lists here.
  2343                 # As we do it only once buiding set would not be cheaper
  2344                 # As we do it only once buiding set would not be cheaper
  2370             #
  2371             #
  2371             # This will have to be fixed before we remove the experimental
  2372             # This will have to be fixed before we remove the experimental
  2372             # gating.
  2373             # gating.
  2373             tracktags(tr2)
  2374             tracktags(tr2)
  2374             repo = reporef()
  2375             repo = reporef()
       
  2376             assert repo is not None  # help pytype
  2375 
  2377 
  2376             singleheadopt = (b'experimental', b'single-head-per-branch')
  2378             singleheadopt = (b'experimental', b'single-head-per-branch')
  2377             singlehead = repo.ui.configbool(*singleheadopt)
  2379             singlehead = repo.ui.configbool(*singleheadopt)
  2378             if singlehead:
  2380             if singlehead:
  2379                 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
  2381                 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
  2473             # fixes the function accumulation.
  2475             # fixes the function accumulation.
  2474             hookargs = tr2.hookargs
  2476             hookargs = tr2.hookargs
  2475 
  2477 
  2476             def hookfunc(unused_success):
  2478             def hookfunc(unused_success):
  2477                 repo = reporef()
  2479                 repo = reporef()
       
  2480                 assert repo is not None  # help pytype
       
  2481 
  2478                 if hook.hashook(repo.ui, b'txnclose-bookmark'):
  2482                 if hook.hashook(repo.ui, b'txnclose-bookmark'):
  2479                     bmchanges = sorted(tr.changes[b'bookmarks'].items())
  2483                     bmchanges = sorted(tr.changes[b'bookmarks'].items())
  2480                     for name, (old, new) in bmchanges:
  2484                     for name, (old, new) in bmchanges:
  2481                         args = tr.hookargs.copy()
  2485                         args = tr.hookargs.copy()
  2482                         args.update(bookmarks.preparehookargs(name, old, new))
  2486                         args.update(bookmarks.preparehookargs(name, old, new))
  2504 
  2508 
  2505                 repo.hook(
  2509                 repo.hook(
  2506                     b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
  2510                     b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
  2507                 )
  2511                 )
  2508 
  2512 
  2509             reporef()._afterlock(hookfunc)
  2513             repo = reporef()
       
  2514             assert repo is not None  # help pytype
       
  2515             repo._afterlock(hookfunc)
  2510 
  2516 
  2511         tr.addfinalize(b'txnclose-hook', txnclosehook)
  2517         tr.addfinalize(b'txnclose-hook', txnclosehook)
  2512         # Include a leading "-" to make it happen before the transaction summary
  2518         # Include a leading "-" to make it happen before the transaction summary
  2513         # reports registered via scmutil.registersummarycallback() whose names
  2519         # reports registered via scmutil.registersummarycallback() whose names
  2514         # are 00-txnreport etc. That way, the caches will be warm when the
  2520         # are 00-txnreport etc. That way, the caches will be warm when the
  2515         # callbacks run.
  2521         # callbacks run.
  2516         tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
  2522         tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
  2517 
  2523 
  2518         def txnaborthook(tr2):
  2524         def txnaborthook(tr2):
  2519             """To be run if transaction is aborted"""
  2525             """To be run if transaction is aborted"""
  2520             reporef().hook(
  2526             repo = reporef()
       
  2527             assert repo is not None  # help pytype
       
  2528             repo.hook(
  2521                 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
  2529                 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
  2522             )
  2530             )
  2523 
  2531 
  2524         tr.addabort(b'txnabort-hook', txnaborthook)
  2532         tr.addabort(b'txnabort-hook', txnaborthook)
  2525         # avoid eager cache invalidation. in-memory data should be identical
  2533         # avoid eager cache invalidation. in-memory data should be identical
  2698         # we must avoid cyclic reference between repo and transaction.
  2706         # we must avoid cyclic reference between repo and transaction.
  2699         reporef = weakref.ref(self)
  2707         reporef = weakref.ref(self)
  2700 
  2708 
  2701         def updater(tr):
  2709         def updater(tr):
  2702             repo = reporef()
  2710             repo = reporef()
       
  2711             assert repo is not None  # help pytype
  2703             repo.updatecaches(tr)
  2712             repo.updatecaches(tr)
  2704 
  2713 
  2705         return updater
  2714         return updater
  2706 
  2715 
  2707     @unfilteredmethod
  2716     @unfilteredmethod
  2913 
  2922 
  2914         Use this before modifying files in .hg.
  2923         Use this before modifying files in .hg.
  2915 
  2924 
  2916         If both 'lock' and 'wlock' must be acquired, ensure you always acquires
  2925         If both 'lock' and 'wlock' must be acquired, ensure you always acquires
  2917         'wlock' first to avoid a dead-lock hazard."""
  2926         'wlock' first to avoid a dead-lock hazard."""
  2918         l = self._wlockref and self._wlockref()
  2927         l = self._wlockref() if self._wlockref else None
  2919         if l is not None and l.held:
  2928         if l is not None and l.held:
  2920             l.lock()
  2929             l.lock()
  2921             return l
  2930             return l
  2922 
  2931 
  2923         # We do not need to check for non-waiting lock acquisition.  Such
  2932         # We do not need to check for non-waiting lock acquisition.  Such