mercurial/repoview.py
branchstable
changeset 47010 76ae43d5b1db
parent 47009 42eb8b7881b8
child 47011 b7e623ac98b6
equal deleted inserted replaced
47009:42eb8b7881b8 47010:76ae43d5b1db
   470 _filteredrepotypes = weakref.WeakKeyDictionary()
   470 _filteredrepotypes = weakref.WeakKeyDictionary()
   471 
   471 
   472 
   472 
   473 def newtype(base):
   473 def newtype(base):
   474     """Create a new type with the repoview mixin and the given base class"""
   474     """Create a new type with the repoview mixin and the given base class"""
   475     cls = _filteredrepotypes.get(base)
   475     ref = _filteredrepotypes.get(base)
   476     if cls is not None:
   476     if ref is not None:
   477         return cls
   477         cls = ref()
       
   478         if cls is not None:
       
   479             return cls
   478 
   480 
   479     class filteredrepo(repoview, base):
   481     class filteredrepo(repoview, base):
   480         pass
   482         pass
   481 
   483 
   482     _filteredrepotypes[base] = filteredrepo
   484     _filteredrepotypes[base] = weakref.ref(filteredrepo)
       
   485     # do not reread from weakref to be 100% sure not to return None
   483     return filteredrepo
   486     return filteredrepo