--- a/hgext/obsolete.py Tue Jun 26 11:13:46 2012 +0200
+++ b/hgext/obsolete.py Tue Jun 26 11:33:39 2012 +0200
@@ -138,6 +138,14 @@
context.changectx.extinct = extinct
+def latecomer(ctx):
+ """is the changeset latecomer (Try to succeed to public change)"""
+ if ctx.node() is None:
+ return False
+ return ctx.rev() in ctx._repo._latecomerset
+
+context.changectx.latecomer = latecomer
+
### revset
#############################
@@ -170,6 +178,10 @@
args = revset.getargs(x, 0, 0, 'unstable takes no arguments')
return [r for r in subset if r in repo._extinctset]
+def revsetlatecomer(repo, subset, x):
+ """latecomer, Try to succeed to public change"""
+ args = revset.getargs(x, 0, 0, 'unstable takes no arguments')
+ return [r for r in subset if r in repo._latecomerset]
def _precursors(repo, s):
"""Precursor of a changeset"""
@@ -367,6 +379,7 @@
revset.symbols["unstable"] = revsetunstable
revset.symbols["suspended"] = revsetsuspended
revset.symbols["extinct"] = revsetextinct
+ revset.symbols["latecomer"] = revsetlatecomer
revset.symbols["obsparents"] = revsetprecursors # DEPR
revset.symbols["precursors"] = revsetprecursors
revset.symbols["obsancestors"] = revsetallprecursors # DEPR
@@ -509,6 +522,12 @@
else:
return None # break recursion
+def wrapclearcache(orig, repo, *args, **kwargs):
+ try:
+ return orig(repo, *args, **kwargs)
+ finally:
+ repo._clearobsoletecache()
+
### New commands
#############################
@@ -606,6 +625,7 @@
extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing)
extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads)
extensions.wrapfunction(phases, 'visibleheads', noextinctsvisibleheads)
+ extensions.wrapfunction(phases, 'advanceboundary', wrapclearcache)
if util.safehasattr(phases, 'visiblebranchmap'):
extensions.wrapfunction(phases, 'visiblebranchmap', wrapvisiblebranchmap)
@@ -840,6 +860,11 @@
"""the set of obsolete parent without non obsolete descendant"""
return set(self.revs('obsolete() - obsolete()::unstable()'))
+ @util.propertycache
+ def _latecomerset(self):
+ """the set of rev trying to obsolete public revision"""
+ return set(self.revs('allsuccessors(public()) - obsolete()'))
+
def _clearobsoletecache(self):
if '_obsoleteset' in vars(self):
del self._obsoleteset
@@ -856,6 +881,8 @@
del self._suspendedset
if '_extinctset' in vars(self):
del self._extinctset
+ if '_latecomerset' in vars(self):
+ del self._latecomerset
def addobsolete(self, sub, obj):
"""Add a relation marking that node <sub> is a new version of <obj>"""
--- a/tests/test-obsolete.t Tue Jun 26 11:13:46 2012 +0200
+++ b/tests/test-obsolete.t Tue Jun 26 11:33:39 2012 +0200
@@ -482,3 +482,30 @@
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
$ cd ..
+
+check latecomer detection
+(make an obsolete changeset public)
+
+ $ cd local
+ $ hg phase --public 11
+ $ hg --config extensions.graphlog=glog glog --template='{rev} - ({phase}) {node|short} {desc}\n'
+ @ 12 - (draft) 6db5e282cb91 add obsol_d'''
+ |
+ | o 11 - (public) 9468a5f5d8b2 add obsol_d''
+ |/
+ o 10 - (public) 2033b4e49474 add obsol_c
+ |
+ o 4 - (public) 725c380fe99b add obsol_c'
+ |
+ o 1 - (public) 7c3bad9141dc add b
+ |
+ o 0 - (public) 1f0dee641bb7 add a
+
+ $ hg log -r 'latecomer()'
+ changeset: 12:6db5e282cb91
+ tag: tip
+ parent: 10:2033b4e49474
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: add obsol_d'''
+