obsolete: prevent bare hg update to select hidden changeset
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 21 Aug 2012 04:36:25 +0200
changeset 473 1f8f8dd75d18
parent 472 641e0cd43d6d
child 477 fded4d945f87
obsolete: prevent bare hg update to select hidden changeset The issue remain with branch name.
hgext/obsolete.py
tests/test-obsolete.t
--- 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'