view tests/test-ui-config @ 5378:8a2915f57dfc

convert: add a mode where mercurial_sink skips empty revisions. The getchanges function of some converter_source classes can return some false positives. I.e. they sometimes claim that a file "foo" was changed in some revision, even though its contents are still the same. convert_svn is particularly bad, but I think this can also happen with convert_cvs and, at least in theory, with mercurial_source. For regular conversions this is not really a problem - as long as getfile returns the right contents, we'll get a converted revision with the right contents. But when we use --filemap, this could lead to superfluous revisions being converted. Instead of fixing every converter_source, I decided to change mercurial_sink to work around this problem. When --filemap is used, we're interested only in revisions that touch some specific files. If a revision doesn't change any of these files, then we're not interested in it (at least for revisions with a single parent; merges are special). For mercurial_sink, we abuse this property and rollback a commit if the manifest text hasn't changed. This avoids duplicating the logic from localrepo.filecommit to detect unchanged files.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Thu, 04 Oct 2007 23:21:37 -0300
parents 18a9fbb5cd78
children
line wrap: on
line source

#!/usr/bin/env python

import ConfigParser
from mercurial import ui, util, dispatch

testui = ui.ui()
parsed = dispatch._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 '!')