changeset 473:1f8f8dd75d18

obsolete: prevent bare hg update to select hidden changeset The issue remain with branch name.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 21 Aug 2012 04:36:25 +0200
parents 641e0cd43d6d
children fded4d945f87
files hgext/obsolete.py tests/test-obsolete.t
diffstat 2 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/obsolete.py	Tue Aug 21 02:50:11 2012 +0200
+++ b/hgext/obsolete.py	Tue Aug 21 04:36:25 2012 +0200
@@ -61,6 +61,7 @@
 from mercurial import revset
 from mercurial import scmutil
 from mercurial import templatekw
+from mercurial import merge
 from mercurial.node import bin, short, nullid
 
 # This extension contains the following code
@@ -575,6 +576,18 @@
                              % ctx)
     return orig(repo, remote, outgoing, *args, **kwargs)
 
+#####################################################################
+### Filter extinct changeset from common operation                ###
+#####################################################################
+
+@eh.wrapfunction(merge, 'update')
+def wrapmergeupdate(orig, repo, node, *args, **kwargs):
+    """ensure we don't automatically update on hidden changeset"""
+    if node is None:
+        # tip of current branch
+        branch = repo[None].branch()
+        node = repo.revs('last((.:: and branch(%s)) - hidden())', branch)[0]
+    return orig(repo, node, *args, **kwargs)
 
 #####################################################################
 ### Additional Utilities                                          ###
--- a/tests/test-obsolete.t	Tue Aug 21 02:50:11 2012 +0200
+++ b/tests/test-obsolete.t	Tue Aug 21 04:36:25 2012 +0200
@@ -436,6 +436,16 @@
   0
   - 1f0dee641bb7
 
+Check that auto update ignore hidden changeset
+  $ hg up 0
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg up 
+  3 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
 
   $ hg glog -r 'not extinct()'  --template='{rev} - {node|short}\n'