mercurial/localrepo.py
branchstable
changeset 46792 7e08fa9b3d13
parent 46572 d5d9177c0045
child 46793 86b47ec1960a
equal deleted inserted replaced
46791:d35063ebd761 46792:7e08fa9b3d13
  2301         if desc != b'strip' and shouldtracktags:
  2301         if desc != b'strip' and shouldtracktags:
  2302             oldheads = self.changelog.headrevs()
  2302             oldheads = self.changelog.headrevs()
  2303 
  2303 
  2304             def tracktags(tr2):
  2304             def tracktags(tr2):
  2305                 repo = reporef()
  2305                 repo = reporef()
       
  2306                 assert repo is not None  # help pytype
  2306                 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
  2307                 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
  2307                 newheads = repo.changelog.headrevs()
  2308                 newheads = repo.changelog.headrevs()
  2308                 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
  2309                 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
  2309                 # notes: we compare lists here.
  2310                 # notes: we compare lists here.
  2310                 # As we do it only once buiding set would not be cheaper
  2311                 # As we do it only once buiding set would not be cheaper
  2337             #
  2338             #
  2338             # This will have to be fixed before we remove the experimental
  2339             # This will have to be fixed before we remove the experimental
  2339             # gating.
  2340             # gating.
  2340             tracktags(tr2)
  2341             tracktags(tr2)
  2341             repo = reporef()
  2342             repo = reporef()
       
  2343             assert repo is not None  # help pytype
  2342 
  2344 
  2343             singleheadopt = (b'experimental', b'single-head-per-branch')
  2345             singleheadopt = (b'experimental', b'single-head-per-branch')
  2344             singlehead = repo.ui.configbool(*singleheadopt)
  2346             singlehead = repo.ui.configbool(*singleheadopt)
  2345             if singlehead:
  2347             if singlehead:
  2346                 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
  2348                 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
  2440             # fixes the function accumulation.
  2442             # fixes the function accumulation.
  2441             hookargs = tr2.hookargs
  2443             hookargs = tr2.hookargs
  2442 
  2444 
  2443             def hookfunc(unused_success):
  2445             def hookfunc(unused_success):
  2444                 repo = reporef()
  2446                 repo = reporef()
       
  2447                 assert repo is not None  # help pytype
       
  2448 
  2445                 if hook.hashook(repo.ui, b'txnclose-bookmark'):
  2449                 if hook.hashook(repo.ui, b'txnclose-bookmark'):
  2446                     bmchanges = sorted(tr.changes[b'bookmarks'].items())
  2450                     bmchanges = sorted(tr.changes[b'bookmarks'].items())
  2447                     for name, (old, new) in bmchanges:
  2451                     for name, (old, new) in bmchanges:
  2448                         args = tr.hookargs.copy()
  2452                         args = tr.hookargs.copy()
  2449                         args.update(bookmarks.preparehookargs(name, old, new))
  2453                         args.update(bookmarks.preparehookargs(name, old, new))
  2471 
  2475 
  2472                 repo.hook(
  2476                 repo.hook(
  2473                     b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
  2477                     b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
  2474                 )
  2478                 )
  2475 
  2479 
  2476             reporef()._afterlock(hookfunc)
  2480             repo = reporef()
       
  2481             assert repo is not None  # help pytype
       
  2482             repo._afterlock(hookfunc)
  2477 
  2483 
  2478         tr.addfinalize(b'txnclose-hook', txnclosehook)
  2484         tr.addfinalize(b'txnclose-hook', txnclosehook)
  2479         # Include a leading "-" to make it happen before the transaction summary
  2485         # Include a leading "-" to make it happen before the transaction summary
  2480         # reports registered via scmutil.registersummarycallback() whose names
  2486         # reports registered via scmutil.registersummarycallback() whose names
  2481         # are 00-txnreport etc. That way, the caches will be warm when the
  2487         # are 00-txnreport etc. That way, the caches will be warm when the
  2482         # callbacks run.
  2488         # callbacks run.
  2483         tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
  2489         tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
  2484 
  2490 
  2485         def txnaborthook(tr2):
  2491         def txnaborthook(tr2):
  2486             """To be run if transaction is aborted"""
  2492             """To be run if transaction is aborted"""
  2487             reporef().hook(
  2493             repo = reporef()
       
  2494             assert repo is not None  # help pytype
       
  2495             repo.hook(
  2488                 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
  2496                 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
  2489             )
  2497             )
  2490 
  2498 
  2491         tr.addabort(b'txnabort-hook', txnaborthook)
  2499         tr.addabort(b'txnabort-hook', txnaborthook)
  2492         # avoid eager cache invalidation. in-memory data should be identical
  2500         # avoid eager cache invalidation. in-memory data should be identical
  2665         # we must avoid cyclic reference between repo and transaction.
  2673         # we must avoid cyclic reference between repo and transaction.
  2666         reporef = weakref.ref(self)
  2674         reporef = weakref.ref(self)
  2667 
  2675 
  2668         def updater(tr):
  2676         def updater(tr):
  2669             repo = reporef()
  2677             repo = reporef()
       
  2678             assert repo is not None  # help pytype
  2670             repo.updatecaches(tr)
  2679             repo.updatecaches(tr)
  2671 
  2680 
  2672         return updater
  2681         return updater
  2673 
  2682 
  2674     @unfilteredmethod
  2683     @unfilteredmethod