# HG changeset patch # User Pierre-Yves David # Date 1345684443 -7200 # Node ID cd1d5b7308be199313b9c1783cec3ad21d339183 # Parent b63da0fb8ee589a27ad60f25ae9c504380aaf390 obsolete: ignore hidden changeset when resolving `branchname` revision diff -r b63da0fb8ee5 -r cd1d5b7308be hgext/obsolete.py --- 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 ### ##################################################################### diff -r b63da0fb8ee5 -r cd1d5b7308be tests/test-obsolete.t --- a/tests/test-obsolete.t Thu Aug 23 12:23:34 2012 +0200 +++ b/tests/test-obsolete.t Thu Aug 23 03:14:03 2012 +0200 @@ -446,6 +446,13 @@ $ hg id -n 8 +Check that named update do too + + $ hg update default + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg id -n + 8 + $ hg up null -q # to be not based on 9 anymore check rebase compat