hgext/obsolete.py
changeset 480 cd1d5b7308be
parent 479 b63da0fb8ee5
child 483 b12ff7ef35b1
--- a/hgext/obsolete.py	Thu Aug 23 12:23:34 2012 +0200
+++ b/hgext/obsolete.py	Thu Aug 23 03:14:03 2012 +0200
@@ -589,6 +589,18 @@
         node = repo.revs('last((.:: and branch(%s)) - hidden())', branch)[0]
     return orig(repo, node, *args, **kwargs)
 
+@eh.wrapfunction(localrepo.localrepository, 'branchtip')
+def obsbranchtip(orig, repo, branch):
+    """ensure "stable" reference does not end on a hidden changeset"""
+    result = ()
+    heads = repo.branchmap().get(branch, ())
+    if heads:
+        result = list(repo.set('last(heads(branch(%n) - hidden()))', heads[0]))
+    if not result:
+        raise error.RepoLookupError(_("unknown branch '%s'") % branch)
+    return result[0].node()
+
+
 #####################################################################
 ### Additional Utilities                                          ###
 #####################################################################