changeset 43636:9c1eccdd7ed8

branchmap: annotate constructor type for branchcache This type signature is...big. But it's correct as far as I can tell, and it detected a bug. Differential Revision: https://phab.mercurial-scm.org/D7389
author Augie Fackler <augie@google.com>
date Thu, 14 Nov 2019 13:13:36 -0500
parents 72b454fae92e
children 7edc07fb890c
files mercurial/branchmap.py
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Wed Nov 13 22:30:33 2019 -0500
+++ b/mercurial/branchmap.py	Thu Nov 14 13:13:36 2019 -0500
@@ -27,6 +27,23 @@
     stringutil,
 )
 
+if not globals():
+    from typing import (
+        Any,
+        Callable,
+        Dict,
+        Iterable,
+        List,
+        Optional,
+        Set,
+        Tuple,
+        Union,
+    )
+
+    assert any(
+        (Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Union,)
+    )
+
 subsettable = repoviewutil.subsettable
 
 calcsize = struct.calcsize
@@ -165,6 +182,7 @@
         closednodes=None,
         hasnode=None,
     ):
+        # type: (Union[Dict[bytes, List[bytes]], Iterable[Tuple[bytes, List[bytes]]]], bytes,  int, Optional[bytes], Optional[Set[bytes]], Optional[Callable[[bytes], bool]]) -> None
         """ hasnode is a function which can be used to verify whether changelog
         has a given node or not. If it's not provided, we assume that every node
         we have exists in changelog """
@@ -177,7 +195,7 @@
         if closednodes is None:
             self._closednodes = set()
         else:
-            self._closednodes = set(closednodes)
+            self._closednodes = closednodes
         self._entries = dict(entries)
         # whether closed nodes are verified or not
         self._closedverified = False