Commits

Pierre-Yves David  committed 1f8f8dd

obsolete: prevent bare hg update to select hidden changeset

The issue remain with branch name.

  • Participants
  • Parent commits 641e0cd
  • Branches default

Comments (0)

Files changed (2)

File hgext/obsolete.py

 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
                              % 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                                          ###

File tests/test-obsolete.t

   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'