changeset 6114:1b57516a9a56

serverminitopic: compatibility for cl.nodemap.get vs cl.index.get_rev
author Raphaël Gomès <rgomes@octobus.net>
date Fri, 07 Jan 2022 12:26:53 +0100
parents 7eb5b33868bc
children ba316ce15040
files hgext3rd/serverminitopic.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/serverminitopic.py	Tue Dec 14 19:09:49 2021 +0300
+++ b/hgext3rd/serverminitopic.py	Fri Jan 07 12:26:53 2022 +0100
@@ -33,6 +33,14 @@
                default=False,
     )
 
+# nodemap.get and index.[has_node|rev|get_rev]
+# hg <= 5.2 (02802fa87b74)
+def getgetrev(cl):
+    """Returns index.get_rev or nodemap.get (for pre-5.3 Mercurial)."""
+    if util.safehasattr(cl.index, 'get_rev'):
+        return cl.index.get_rev
+    return cl.nodemap.get
+
 # hg <= 5.4 (e2d17974a869)
 def nonpublicphaseroots(repo):
     if util.safehasattr(repo._phasecache, 'nonpublicphaseroots'):
@@ -113,9 +121,9 @@
     revs = set()
     cl = repo.changelog
     fr = cl.filteredrevs
-    nm = cl.nodemap
+    getrev = getgetrev(cl)
     for n in nonpublicphaseroots(repo):
-        r = nm.get(n)
+        r = getrev(n)
         if r not in fr and r < maxrev:
             revs.add(r)
     key = node.nullid