view tests/test-ui-config @ 5149:ad6b97132b81

merge: fix a copy detection bug (issue672) When merging rev1 and rev2, we want to search for copies that happened in rev1 but not in rev2 and vice-versa. We were starting the search at rev1/rev2 and then going back, stopping as soon as we reached the revno of the ancestor, but that can miss some cases (see the new test-issue672). Now we calculate the revisions that are ancestors of rev1 or rev2 (but not both) and make sure the search doesn't stop too early. Simplified test provided by mpm, based on a test case provided by Edward Lee.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sun, 12 Aug 2007 12:15:10 -0300
parents 9881abfc0e44
children 18a9fbb5cd78
line wrap: on
line source

#!/usr/bin/env python

import ConfigParser
from mercurial import ui, util, cmdutil

testui = ui.ui()
parsed = cmdutil.parseconfig([
    'values.string=string value',
    'values.bool1=true',
    'values.bool2=false',
    'lists.list1=foo',
    'lists.list2=foo bar baz',
    'lists.list3=alice, bob',
    'lists.list4=foo bar baz alice, bob',
    'interpolation.value1=hallo',
    'interpolation.value2=%(value1)s world',
    'interpolation.value3=%(novalue)s',
    'interpolation.value4=%(bad)1',
    'interpolation.value5=%bad2',
])
testui.updateopts(config=parsed)

print repr(testui.configitems('values'))
print repr(testui.configitems('lists'))
try:
    print repr(testui.configitems('interpolation'))
except util.Abort, inst:
    print inst
print "---"
print repr(testui.config('values', 'string'))
print repr(testui.config('values', 'bool1'))
print repr(testui.config('values', 'bool2'))
print repr(testui.config('values', 'unknown'))
print "---"
try:
    print repr(testui.configbool('values', 'string'))
except util.Abort, inst:
    print inst
print repr(testui.configbool('values', 'bool1'))
print repr(testui.configbool('values', 'bool2'))
print repr(testui.configbool('values', 'bool2', True))
print repr(testui.configbool('values', 'unknown'))
print repr(testui.configbool('values', 'unknown', True))
print "---"
print repr(testui.configlist('lists', 'list1'))
print repr(testui.configlist('lists', 'list2'))
print repr(testui.configlist('lists', 'list3'))
print repr(testui.configlist('lists', 'list4'))
print repr(testui.configlist('lists', 'list4', ['foo']))
print repr(testui.configlist('lists', 'unknown'))
print repr(testui.configlist('lists', 'unknown', ''))
print repr(testui.configlist('lists', 'unknown', 'foo'))
print repr(testui.configlist('lists', 'unknown', ['foo']))
print repr(testui.configlist('lists', 'unknown', 'foo bar'))
print repr(testui.configlist('lists', 'unknown', 'foo, bar'))
print repr(testui.configlist('lists', 'unknown', ['foo bar']))
print repr(testui.configlist('lists', 'unknown', ['foo', 'bar']))
print "---"
print repr(testui.config('interpolation', 'value1'))
print repr(testui.config('interpolation', 'value2'))
try:
    print repr(testui.config('interpolation', 'value3'))
except util.Abort, inst:
    print inst
try:
    print repr(testui.config('interpolation', 'value4'))
except util.Abort, inst:
    print inst
try:
    print repr(testui.config('interpolation', 'value5'))
except util.Abort, inst:
    print inst
print "---"

cp = util.configparser()
cp.add_section('foo')
cp.set('foo', 'bar', 'baz')
try:
    # should fail - keys are case-sensitive
    cp.get('foo', 'Bar')
except ConfigParser.NoOptionError, inst:
    print inst

def function():
    pass

cp.add_section('hook')
# values that aren't strings should work
cp.set('hook', 'commit', function)
f = cp.get('hook', 'commit')
print "f %s= function" % (f == function and '=' or '!')