--- a/hgext3rd/evolve/__init__.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/evolve/__init__.py Wed Nov 13 13:47:55 2019 +0700
@@ -527,14 +527,14 @@
def _precursors(repo, s, includeidentical=False):
"""Precursor of a changeset"""
cs = set()
- nm = repo.changelog.nodemap
+ getrev = compat.getgetrev(repo.changelog)
markerbysubj = repo.obsstore.predecessors
node = repo.changelog.node
for r in s:
for p in markerbysubj.get(node(r), ()):
if not includeidentical and p[2] & rewind.identicalflag:
continue
- pr = nm.get(p[0])
+ pr = getrev(p[0])
if pr is not None:
cs.add(pr)
cs -= repo.changelog.filteredrevs # nodemap has no filtering
@@ -553,10 +553,10 @@
if np not in seen:
seen.add(np)
toproceed.append(np)
- nm = repo.changelog.nodemap
+ getrev = compat.getgetrev(repo.changelog)
cs = set()
for p in seen:
- pr = nm.get(p)
+ pr = getrev(p)
if pr is not None:
cs.add(pr)
cs -= repo.changelog.filteredrevs # nodemap has no filtering
@@ -566,12 +566,12 @@
"""Successors of a changeset"""
cs = set()
node = repo.changelog.node
- nm = repo.changelog.nodemap
+ getrev = compat.getgetrev(repo.changelog)
markerbyobj = repo.obsstore.successors
for r in s:
for p in markerbyobj.get(node(r), ()):
for sub in p[1]:
- sr = nm.get(sub)
+ sr = getrev(sub)
if sr is not None:
cs.add(sr)
cs -= repo.changelog.filteredrevs # nodemap has no filtering
@@ -597,10 +597,10 @@
if sub not in seen:
seen.add(sub)
toproceed.append(sub)
- nm = repo.changelog.nodemap
+ getrev = compat.getgetrev(repo.changelog)
cs = set()
for s in seen:
- sr = nm.get(s)
+ sr = getrev(s)
if sr is not None:
cs.add(sr)
cs -= repo.changelog.filteredrevs # nodemap has no filtering
--- a/hgext3rd/evolve/compat.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/evolve/compat.py Wed Nov 13 13:47:55 2019 +0700
@@ -532,3 +532,11 @@
if not category:
return {}
return {'helpcategory': category}
+
+# nodemap.get and index.[has_node|rev|get_rev]
+# hg <= 5.3 (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
--- a/hgext3rd/evolve/dagutil.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/evolve/dagutil.py Wed Nov 13 13:47:55 2019 +0700
@@ -13,6 +13,8 @@
from mercurial.i18n import _
from mercurial.node import nullrev
+from . import compat
+
class basedag(object):
'''generic interface for DAGs
@@ -145,8 +147,9 @@
def _internalizeall(self, ids, filterunknown):
rl = self._revlog
+ getrev = compat.getgetrev(rl)
if filterunknown:
- return [r for r in map(rl.nodemap.get, ids)
+ return [r for r in map(getrev, ids)
if (r is not None
and r != nullrev
and r not in rl.filteredrevs)]
--- a/hgext3rd/evolve/debugcmd.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/evolve/debugcmd.py Wed Nov 13 13:47:55 2019 +0700
@@ -17,7 +17,10 @@
from mercurial.i18n import _
-from . import exthelper
+from . import (
+ compat,
+ exthelper,
+)
eh = exthelper.exthelper()
@@ -43,7 +46,7 @@
store = repo.obsstore
unfi = repo.unfiltered()
- nm = unfi.changelog.nodemap
+ getrev = compat.getgetrev(unfi.changelog)
nbmarkers = len(store._all)
ui.write(_(b'markers total: %9i\n') % nbmarkers)
sucscount = [0, 0, 0, 0]
@@ -58,7 +61,7 @@
size_v0 = []
size_v1 = []
for mark in store:
- if mark[0] in nm:
+ if getrev(mark[0]) is not None:
known += 1
nbsucs = len(mark[1])
sucscount[min(nbsucs, 3)] += 1
@@ -133,7 +136,7 @@
ui.write(b' any known node: %9i\n'
% len([c for c in allclusters
- if [n for n in c[0] if nm.get(n) is not None]]))
+ if [n for n in c[0] if getrev(n) is not None]]))
if allclusters:
nbcluster = len(allclusters)
ui.write((b' smallest length: %9i\n' % len(allclusters[0][1])))
@@ -148,7 +151,7 @@
ui.write((b' using parents data: %9i\n' % len(allpclusters)))
ui.write(b' any known node: %9i\n'
% len([c for c in allclusters
- if [n for n in c[0] if nm.get(n) is not None]]))
+ if [n for n in c[0] if getrev(n) is not None]]))
if allpclusters:
nbcluster = len(allpclusters)
ui.write((b' smallest length: %9i\n'
--- a/hgext3rd/evolve/obscache.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/evolve/obscache.py Wed Nov 13 13:47:55 2019 +0700
@@ -20,6 +20,7 @@
)
from . import (
+ compat,
exthelper,
)
@@ -389,9 +390,9 @@
def _updatemarkers(self, repo, obsmarkers):
"""update the cache with new markers"""
- rev = repo.changelog.nodemap.get
+ getrev = compat.getgetrev(repo.changelog)
for m in obsmarkers:
- r = rev(m[0])
+ r = getrev(m[0])
if r is not None:
self._data[r] = 1
--- a/hgext3rd/evolve/obsdiscovery.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/evolve/obsdiscovery.py Wed Nov 13 13:47:55 2019 +0700
@@ -414,8 +414,8 @@
max_stored = con.execute(_query_max_stored).fetchall()[0][0]
affected_nodes = _affectedby(repo, obsmarkers)
- rev = repo.changelog.nodemap.get
- affected = [rev(n) for n in affected_nodes]
+ getrev = compat.getgetrev(repo.changelog)
+ affected = [getrev(n) for n in affected_nodes]
affected = [r for r in affected
if r is not None and r <= max_stored]
@@ -646,8 +646,8 @@
The range have the id encoded as a node
return 'wdirid' for unknown range"""
- nm = repo.changelog.nodemap
- ranges = [(nm.get(n), idx) for n, idx in ranges]
+ getrev = compat.getgetrev(repo.changelog)
+ ranges = [(getrev(n), idx) for n, idx in ranges]
if ranges:
maxrev = max(r for r, i in ranges)
if maxrev is not None:
--- a/hgext3rd/pullbundle.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/pullbundle.py Wed Nov 13 13:47:55 2019 +0700
@@ -180,7 +180,7 @@
def sliceoutgoing(repo, outgoing):
cl = repo.changelog
- rev = cl.nodemap.get
+ rev = getgetrev(cl)
node = cl.node
revsort = repo.stablesort
@@ -623,3 +623,11 @@
def fmtdist(name, data):
return STATSFORMAT.format(name=name, **data)
+
+# nodemap.get and index.[has_node|rev|get_rev]
+# hg <= 5.3 (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
--- a/hgext3rd/topic/compat.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/topic/compat.py Wed Nov 13 13:47:55 2019 +0700
@@ -11,6 +11,7 @@
obsolete,
pycompat,
registrar,
+ util,
)
getmarkers = None
@@ -44,3 +45,11 @@
if not category:
return {}
return {'helpcategory': category}
+
+# nodemap.get and index.[has_node|rev|get_rev]
+# hg <= 5.3 (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
--- a/hgext3rd/topic/discovery.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/topic/discovery.py Wed Nov 13 13:47:55 2019 +0700
@@ -45,7 +45,7 @@
publishednode,
pushop.remotephases.publicheads)
- rev = repo.unfiltered().changelog.nodemap.get
+ getrev = compat.getgetrev(repo.unfiltered().changelog)
def remotebranchmap():
# drop topic information from changeset about to be published
@@ -56,7 +56,7 @@
else:
namedbranch = branch.split(b':', 1)[0]
for h in heads:
- r = rev(h)
+ r = getrev(h)
if r is not None and r in publishedset:
result[namedbranch].append(h)
else:
--- a/hgext3rd/topic/topicmap.py Wed Nov 13 13:43:46 2019 +0700
+++ b/hgext3rd/topic/topicmap.py Wed Nov 13 13:47:55 2019 +0700
@@ -14,6 +14,7 @@
from . import (
common,
+ compat,
)
basefilter = set([b'base', b'immutable'])
@@ -69,10 +70,10 @@
revs = set()
cl = repo.changelog
fr = cl.filteredrevs
- nm = cl.nodemap
+ getrev = compat.getgetrev(cl)
for roots in repo._phasecache.phaseroots[1:]:
for n in roots:
- r = nm.get(n)
+ r = getrev(n)
if r not in fr and r < maxrev:
revs.add(r)
key = nullid