tests/test_branch.py @ 5faf9b0ae984

bookmarks: check if bookmark is actually current

Mercurial doesn't remove the bookmarks.current file when updating away
from a bookmark, and repo._bookmarkcurrent() doesn't check whether the
bookmark read from bookmarks.current is actually current.

This patch prevents hg-prompt from reporting a current bookmark when the
bookmark in bookmarks.current isn't actually the working directory's
first parent. This matches the behavior of the `hg bookmarks` command.
author Kevin Bullock <kbullock@umn.edu>
date Tue, 05 Jul 2011 14:19:52 -0500
parents 724156256017
children (none)
'''Test output of {branch}.'''

from nose import *
from util import *


@with_setup(setup_sandbox, teardown_sandbox)
def test_default_branch():
    output = prompt(fs='{branch}')
    assert output == 'default'
    
    output = prompt(fs='{on {branch}}')
    assert output == 'on default'


@with_setup(setup_sandbox, teardown_sandbox)
def test_non_default_branch():
    hg_branch('test')
    
    output = prompt(fs='{branch}')
    assert output == 'test'
    
    output = prompt(fs='{on the {branch} branch}')
    assert output == 'on the test branch'


@with_setup(setup_sandbox, teardown_sandbox)
def test_quiet_filter():
    output = prompt(fs='{branch|quiet}')
    assert output == ''
    
    output = prompt(fs='{on {branch|quiet}}')
    assert output == ''
    
    hg_branch('test')
    
    output = prompt(fs='{branch|quiet}')
    assert output == 'test'
    
    output = prompt(fs='{on the {branch|quiet} branch}')
    assert output == 'on the test branch'