changeset 18464:a2e9fe93d9ea stable

changectx: fix the handling of `tip` We can not use `len(repo,changelog)`, it may be a filtered revision. We now use `repo,changelog.tip()` to fetch this information. The `tip` command is also fixed and tested Thanks goes to Idan Kamara for the initial report.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 22 Jan 2013 11:39:14 +0100
parents 07771e233cf1
children 3aa8b4b36b64 63de17206ec8
files mercurial/commands.py mercurial/context.py tests/test-obsolete.t
diffstat 3 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Jan 22 03:23:02 2013 +0100
+++ b/mercurial/commands.py	Tue Jan 22 11:39:14 2013 +0100
@@ -5866,7 +5866,7 @@
     Returns 0 on success.
     """
     displayer = cmdutil.show_changeset(ui, repo, opts)
-    displayer.show(repo[len(repo) - 1])
+    displayer.show(repo['tip'])
     displayer.close()
 
 @command('unbundle',
--- a/mercurial/context.py	Tue Jan 22 03:23:02 2013 +0100
+++ b/mercurial/context.py	Tue Jan 22 11:39:14 2013 +0100
@@ -44,8 +44,8 @@
             self._rev = nullrev
             return
         if changeid == 'tip':
-            self._rev = len(repo.changelog) - 1
-            self._node = repo.changelog.node(self._rev)
+            self._node = repo.changelog.tip()
+            self._rev = repo.changelog.rev(self._node)
             return
         if len(changeid) == 20:
             try:
--- a/tests/test-obsolete.t	Tue Jan 22 03:23:02 2013 +0100
+++ b/tests/test-obsolete.t	Tue Jan 22 11:39:14 2013 +0100
@@ -55,6 +55,17 @@
   $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
   $ hg debugobsolete
   97b7c2d76b1845ed3eb988cd612611e72406cef0 0 {'date': '0 0', 'user': 'babar'}
+
+(test that mercurial is not confused)
+
+  $ hg up null --quiet # having 0 as parent prevents it to be hidden
+  $ hg tip
+  changeset:   -1:000000000000
+  tag:         tip
+  user:        
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  
+  $ hg up --hidden tip --quiet
   $ cd ..
 
 Killing a single changeset with replacement