changeset 43441:d630c5710801

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
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 05 Nov 2019 14:00:46 -0800
parents ec7ba79bf3db
children 625e7d1ffd1c
files mercurial/repoview.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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