repoview: extract a function for wrapping changelog
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 05 Nov 2019 14:00:46 -0800
changeset 43493 d630c5710801
parent 43492 ec7ba79bf3db
child 43494 625e7d1ffd1c
repoview: extract a function for wrapping changelog I would like to clean up the changelog class by moving out knowledge of filtering. The filtering will instead be done in a class that wraps the changelog. This patch prepares for that. Differential Revision: https://phab.mercurial-scm.org/D7235
mercurial/repoview.py
--- a/mercurial/repoview.py	Tue Nov 05 14:42:08 2019 -0800
+++ b/mercurial/repoview.py	Tue Nov 05 14:00:46 2019 -0800
@@ -218,6 +218,12 @@
     return repo.filteredrevcache[filtername]
 
 
+def wrapchangelog(unfichangelog, filteredrevs):
+    cl = copy.copy(unfichangelog)
+    cl.filteredrevs = filteredrevs
+    return cl
+
+
 class repoview(object):
     """Provide a read/write view of a repo through a filtered changelog
 
@@ -286,8 +292,7 @@
             cl = None
         # could have been made None by the previous if
         if cl is None:
-            cl = copy.copy(unfichangelog)
-            cl.filteredrevs = revs
+            cl = wrapchangelog(unfichangelog, revs)
             object.__setattr__(self, r'_clcache', cl)
             object.__setattr__(self, r'_clcachekey', newkey)
         return cl