diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5866,7 +5866,7 @@ def tip(ui, repo, **opts): 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', diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -44,8 +44,8 @@ class changectx(object): 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: diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -55,6 +55,17 @@ Killing a single changeset without repla $ 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