typing: add assertions to localrepo.py to appease pytype
Differential Revision: https://phab.mercurial-scm.org/D10214
--- a/mercurial/localrepo.py Fri Mar 12 21:19:17 2021 -0500
+++ b/mercurial/localrepo.py Sat Mar 13 02:07:34 2021 -0500
@@ -2303,6 +2303,7 @@
def tracktags(tr2):
repo = reporef()
+ assert repo is not None # help pytype
oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
newheads = repo.changelog.headrevs()
newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
@@ -2339,6 +2340,7 @@
# gating.
tracktags(tr2)
repo = reporef()
+ assert repo is not None # help pytype
singleheadopt = (b'experimental', b'single-head-per-branch')
singlehead = repo.ui.configbool(*singleheadopt)
@@ -2442,6 +2444,8 @@
def hookfunc(unused_success):
repo = reporef()
+ assert repo is not None # help pytype
+
if hook.hashook(repo.ui, b'txnclose-bookmark'):
bmchanges = sorted(tr.changes[b'bookmarks'].items())
for name, (old, new) in bmchanges:
@@ -2473,7 +2477,9 @@
b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
)
- reporef()._afterlock(hookfunc)
+ repo = reporef()
+ assert repo is not None # help pytype
+ repo._afterlock(hookfunc)
tr.addfinalize(b'txnclose-hook', txnclosehook)
# Include a leading "-" to make it happen before the transaction summary
@@ -2484,7 +2490,9 @@
def txnaborthook(tr2):
"""To be run if transaction is aborted"""
- reporef().hook(
+ repo = reporef()
+ assert repo is not None # help pytype
+ repo.hook(
b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
)
@@ -2667,6 +2675,7 @@
def updater(tr):
repo = reporef()
+ assert repo is not None # help pytype
repo.updatecaches(tr)
return updater