compat: drop compatibility layer for updatecaches
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 18 Aug 2018 00:53:12 +0200
changeset 3968 37178a2d3557
parent 3967 d54925819f34
child 3969 e854bf1e703f
compat: drop compatibility layer for updatecaches The `repo.updatecaches` method is support since Mercurial 4.2
hgext3rd/evolve/depthcache.py
hgext3rd/evolve/firstmergecache.py
hgext3rd/evolve/obscache.py
hgext3rd/evolve/obsdiscovery.py
hgext3rd/evolve/stablerangecache.py
hgext3rd/evolve/stablesort.py
--- a/hgext3rd/evolve/depthcache.py	Sat Aug 18 00:48:05 2018 +0200
+++ b/hgext3rd/evolve/depthcache.py	Sat Aug 18 00:53:12 2018 +0200
@@ -85,30 +85,12 @@
                 self.depthcache.clear()
             super(depthcacherepo, self).destroyed()
 
-        if util.safehasattr(repo, 'updatecaches'):
-            @localrepo.unfilteredmethod
-            def updatecaches(self, tr=None, **kwargs):
-                if utility.shouldwarmcache(self, tr):
-                    self.depthcache.update(self)
-                    self.depthcache.save(self)
-                super(depthcacherepo, self).updatecaches(tr, **kwargs)
-
-        else:
-            def transaction(self, *args, **kwargs):
-                tr = super(depthcacherepo, self).transaction(*args, **kwargs)
-                reporef = weakref.ref(self)
-
-                def _warmcache(tr):
-                    repo = reporef()
-                    if repo is None:
-                        return
-                    repo = repo.unfiltered()
-                    repo.depthcache.update(repo)
-                    repo.depthcache.save(repo)
-
-                if utility.shouldwarmcache(self, tr):
-                    tr.addpostclose('warmcache-00depthcache', _warmcache)
-                return tr
+        @localrepo.unfilteredmethod
+        def updatecaches(self, tr=None, **kwargs):
+            if utility.shouldwarmcache(self, tr):
+                self.depthcache.update(self)
+                self.depthcache.save(self)
+            super(depthcacherepo, self).updatecaches(tr, **kwargs)
 
     repo.__class__ = depthcacherepo
 
--- a/hgext3rd/evolve/firstmergecache.py	Sat Aug 18 00:48:05 2018 +0200
+++ b/hgext3rd/evolve/firstmergecache.py	Sat Aug 18 00:53:12 2018 +0200
@@ -47,30 +47,12 @@
                 self.firstmergecache.clear()
             super(firstmergecacherepo, self).destroyed()
 
-        if util.safehasattr(repo, 'updatecaches'):
-            @localrepo.unfilteredmethod
-            def updatecaches(self, tr=None, **kwargs):
-                if utility.shouldwarmcache(self, tr):
-                    self.firstmergecache.update(self)
-                    self.firstmergecache.save(self)
-                super(firstmergecacherepo, self).updatecaches(tr, **kwargs)
-
-        else:
-            def transaction(self, *args, **kwargs):
-                tr = super(firstmergecacherepo, self).transaction(*args, **kwargs)
-                reporef = weakref.ref(self)
-
-                def _warmcache(tr):
-                    repo = reporef()
-                    if repo is None:
-                        return
-                    repo = repo.unfiltered()
-                    repo.firstmergecache.update(repo)
-                    repo.firstmergecache.save(repo)
-
-                if utility.shouldwarmcache(self, tr):
-                    tr.addpostclose('warmcache-01-firstparentcache', _warmcache)
-                return tr
+        @localrepo.unfilteredmethod
+        def updatecaches(self, tr=None, **kwargs):
+            if utility.shouldwarmcache(self, tr):
+                self.firstmergecache.update(self)
+                self.firstmergecache.save(self)
+            super(firstmergecacherepo, self).updatecaches(tr, **kwargs)
 
     repo.__class__ = firstmergecacherepo
 
--- a/hgext3rd/evolve/obscache.py	Sat Aug 18 00:48:05 2018 +0200
+++ b/hgext3rd/evolve/obscache.py	Sat Aug 18 00:53:12 2018 +0200
@@ -478,31 +478,10 @@
                 self.obsstore.obscache.clear()
             super(obscacherepo, self).destroyed()
 
-        if util.safehasattr(repo, 'updatecaches'):
-            @localrepo.unfilteredmethod
-            def updatecaches(self, tr=None, **kwargs):
-                super(obscacherepo, self).updatecaches(tr, **kwargs)
-                self.obsstore.obscache.update(self)
-                self.obsstore.obscache.save(self)
-
-        else:
-            def transaction(self, *args, **kwargs):
-                tr = super(obscacherepo, self).transaction(*args, **kwargs)
-                reporef = weakref.ref(self)
-
-                def _warmcache(tr):
-                    repo = reporef()
-                    if repo is None:
-                        return
-                    repo = repo.unfiltered()
-                    # As pointed in 'obscache.update', we could have the changelog
-                    # and the obsstore in charge of updating the cache when new
-                    # items goes it. The tranaction logic would then only be
-                    # involved for the 'pending' and final writing on disk.
-                    self.obsstore.obscache.update(repo)
-                    self.obsstore.obscache.save(repo)
-
-                tr.addpostclose('warmcache-obscache', _warmcache)
-                return tr
+        @localrepo.unfilteredmethod
+        def updatecaches(self, tr=None, **kwargs):
+            super(obscacherepo, self).updatecaches(tr, **kwargs)
+            self.obsstore.obscache.update(self)
+            self.obsstore.obscache.save(self)
 
     repo.__class__ = obscacherepo
--- a/hgext3rd/evolve/obsdiscovery.py	Sat Aug 18 00:48:05 2018 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Sat Aug 18 00:53:12 2018 +0200
@@ -631,30 +631,12 @@
                 self.obsstore.rangeobshashcache.clear()
             super(obshashrepo, self).destroyed()
 
-        if util.safehasattr(repo, 'updatecaches'):
-            @localrepo.unfilteredmethod
-            def updatecaches(self, tr=None, **kwargs):
-                if utility.shouldwarmcache(self, tr):
-                    self.obsstore.rangeobshashcache.update(self)
-                    self.obsstore.rangeobshashcache.save(self)
-                super(obshashrepo, self).updatecaches(tr, **kwargs)
-
-        else:
-            def transaction(self, *args, **kwargs):
-                tr = super(obshashrepo, self).transaction(*args, **kwargs)
-                reporef = weakref.ref(self)
-
-                def _warmcache(tr):
-                    repo = reporef()
-                    if repo is None:
-                        return
-                    repo = repo.unfiltered()
-                    repo.obsstore.rangeobshashcache.update(repo)
-                    repo.obsstore.rangeobshashcache.save(repo)
-
-                if utility.shouldwarmcache(self, tr):
-                    tr.addpostclose('warmcache-20obshashrange', _warmcache)
-                return tr
+        @localrepo.unfilteredmethod
+        def updatecaches(self, tr=None, **kwargs):
+            if utility.shouldwarmcache(self, tr):
+                self.obsstore.rangeobshashcache.update(self)
+                self.obsstore.rangeobshashcache.save(self)
+            super(obshashrepo, self).updatecaches(tr, **kwargs)
 
     repo.__class__ = obshashrepo
 
--- a/hgext3rd/evolve/stablerangecache.py	Sat Aug 18 00:48:05 2018 +0200
+++ b/hgext3rd/evolve/stablerangecache.py	Sat Aug 18 00:53:12 2018 +0200
@@ -378,30 +378,12 @@
                 del self.stablerange
             super(stablerangerepo, self).destroyed()
 
-        if util.safehasattr(repo, 'updatecaches'):
-            @localrepo.unfilteredmethod
-            def updatecaches(self, tr=None, **kwargs):
-                if utility.shouldwarmcache(self, tr):
-                    self.stablerange.update(self)
-                    self.stablerange.save(self)
-                super(stablerangerepo, self).updatecaches(tr, **kwargs)
-
-        else:
-            def transaction(self, *args, **kwargs):
-                tr = super(stablerangerepo, self).transaction(*args, **kwargs)
-                reporef = weakref.ref(self)
-
-                def _warmcache(tr):
-                    repo = reporef()
-                    if repo is None:
-                        return
-                    repo = repo.unfiltered()
-                    repo.stablerange.update(repo)
-                    repo.stablerange.save(repo)
-
-                if utility.shouldwarmcache(self, tr):
-                    tr.addpostclose('warmcache-10stablerange', _warmcache)
-                return tr
+        @localrepo.unfilteredmethod
+        def updatecaches(self, tr=None, **kwargs):
+            if utility.shouldwarmcache(self, tr):
+                self.stablerange.update(self)
+                self.stablerange.save(self)
+            super(stablerangerepo, self).updatecaches(tr, **kwargs)
 
     repo.__class__ = stablerangerepo
 
--- a/hgext3rd/evolve/stablesort.py	Sat Aug 18 00:48:05 2018 +0200
+++ b/hgext3rd/evolve/stablesort.py	Sat Aug 18 00:53:12 2018 +0200
@@ -669,30 +669,12 @@
                 self.stablesort.clear()
             super(stablesortrepo, self).destroyed()
 
-        if util.safehasattr(repo, 'updatecaches'):
-            @localrepo.unfilteredmethod
-            def updatecaches(self, tr=None, **kwargs):
-                if utility.shouldwarmcache(self, tr):
-                    self.stablesort.update(self)
-                    self.stablesort.save(self)
-                super(stablesortrepo, self).updatecaches(tr, **kwargs)
-
-        else:
-            def transaction(self, *args, **kwargs):
-                tr = super(stablesortrepo, self).transaction(*args, **kwargs)
-                reporef = weakref.ref(self)
-
-                def _warmcache(tr):
-                    repo = reporef()
-                    if repo is None:
-                        return
-                    repo = repo.unfiltered()
-                    repo.stablesort.update(repo)
-                    repo.stablesort.save(repo)
-
-                if utility.shouldwarmcache(self, tr):
-                    tr.addpostclose('warmcache-02stablesort', _warmcache)
-                return tr
+        @localrepo.unfilteredmethod
+        def updatecaches(self, tr=None, **kwargs):
+            if utility.shouldwarmcache(self, tr):
+                self.stablesort.update(self)
+                self.stablesort.save(self)
+            super(stablesortrepo, self).updatecaches(tr, **kwargs)
 
     repo.__class__ = stablesortrepo