tests/test_rev.py @ c4095c3519d6

Fixed bug that was thowing a KeyError when including "{bookmark}" in the output.

This resolves issue #17 (Bookmarks have moved into core for 1.8) on https://bitbucket.org/sjl/hg-prompt/.

The end of the stack track was....
-----------------------------
  File "/Users/dak180/Applications/Build/hgExtensions/hg-prompt/prompt.py", line 101, in _bookmark
    book = extensions.find('bookmarks').current(repo)
  File "/sw/lib/python2.6/site-packages/mercurial/extensions.py", line 30, in find
    raise KeyError(name)
KeyError: 'bookmarks'
-----------------------------

I personally was getting this error on mercurial versions 1.8.1 and 1.6.3 (although I am not exactly sure why I got it on 1.6.3).
author Shaun Ek <shaune@providentmetals.com>
date Wed, 23 Mar 2011 15:42:04 -0400
parents a85dc0c43f86
children (none)
'''Test output of {node}.'''

from nose import *
from util import *


def _parent_rev():
    opts = { 'template': '{rev}', 'rev': '.', 'date': None, 'user': None }
    
    _ui = get_sandbox_ui()
    _ui.pushbuffer()
    commands.log(_ui, get_sandbox_repo(), **opts)
    
    return _ui.popbuffer()


@with_setup(setup_sandbox, teardown_sandbox)
def test_nullrev():
    output = prompt(fs='{rev}')
    assert output == ''
    
    output = prompt(fs='{ at revision {rev}}')
    assert output == ''


@with_setup(setup_sandbox, teardown_sandbox)
def test_rev():
    hg_commit()
    
    output = prompt(fs='{rev}')
    assert output == _parent_rev()
    
    output = prompt(fs='{ at revision {rev}}')
    assert output == ' at revision %s' % _parent_rev()
    
    hg_commit()
    output = prompt(fs='{rev}')
    assert output == _parent_rev()


@with_setup(setup_sandbox, teardown_sandbox)
def test_merge_filter():
    hg_commit('one.txt')
    hg_commit('one.txt')
    rev_to_merge = _parent_rev()
    
    hg_update(0)
    hg_commit('two.txt')
    hg_merge(1)
    
    output = prompt(fs='{rev|merge}')
    assert output == rev_to_merge
    
    output = prompt(fs='{ merging with {rev|merge}}')
    assert output == ' merging with %s' % rev_to_merge