obsolete: ignore hidden changeset when resolving `branchname` revision
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Thu, 23 Aug 2012 03:14:03 +0200
changeset 480 cd1d5b7308be
parent 479 b63da0fb8ee5
child 481 4e0f1aae8d24
obsolete: ignore hidden changeset when resolving `branchname` revision
hgext/obsolete.py
tests/test-obsolete.t
--- 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                                          ###
 #####################################################################
--- 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