--- a/hgext/obsolete.py Tue Jun 26 11:11:52 2012 +0200
+++ b/hgext/obsolete.py Tue Jun 26 11:13:46 2012 +0200
@@ -215,6 +215,51 @@
cs = _allprecursors(repo, s)
return [r for r in subset if r in cs]
+def _successors(repo, s):
+ """Successors of a changeset"""
+ cs = set()
+ nm = repo.changelog.nodemap
+ markerbyobj = repo.obsoletestore.objects
+ for r in s:
+ for p in markerbyobj.get(repo[r].node(), ()):
+ for sub in p['subjects']:
+ sr = nm.get(sub)
+ if sr is not None:
+ cs.add(sr)
+ return cs
+
+def revsetsuccessors(repo, subset, x):
+ """successors of a subset"""
+ s = revset.getset(repo, range(len(repo)), x)
+ cs = _successors(repo, s)
+ return [r for r in subset if r in cs]
+
+def _allsuccessors(repo, s): # XXX we need a better naming
+ """transitive successors of a subset"""
+ toproceed = [repo[r].node() for r in s]
+ seen = set()
+ allobjects = repo.obsoletestore.objects
+ while toproceed:
+ nc = toproceed.pop()
+ for mark in allobjects.get(nc, ()):
+ for sub in mark['subjects']:
+ if sub not in seen:
+ seen.add(sub)
+ toproceed.append(sub)
+ nm = repo.changelog.nodemap
+ cs = set()
+ for s in seen:
+ sr = nm.get(s)
+ if sr is not None:
+ cs.add(sr)
+ return cs
+
+def revsetallsuccessors(repo, subset, x):
+ """obsolete parents"""
+ s = revset.getset(repo, range(len(repo)), x)
+ cs = _allsuccessors(repo, s)
+ return [r for r in subset if r in cs]
+
### template keywords
#####################
@@ -326,6 +371,8 @@
revset.symbols["precursors"] = revsetprecursors
revset.symbols["obsancestors"] = revsetallprecursors # DEPR
revset.symbols["allprecursors"] = revsetallprecursors # bad name
+ revset.symbols["successors"] = revsetsuccessors
+ revset.symbols["allsuccessors"] = revsetallsuccessors # bad name
templatekw.keywords['obsolete'] = obsoletekw