convert: warn on superfluous / in paths

shlex is really a bad parser for this line-based format ...
This commit is contained in:
Mads Kiilerich 2010-07-20 15:49:28 +02:00
parent a1c3bcbbfe
commit ef1e88d17c
3 changed files with 29 additions and 0 deletions

View File

@ -33,10 +33,20 @@ class filemapper(object):
def parse(self, path):
errs = 0
def check(name, mapping, listname):
if not name:
self.ui.warn(_('%s:%d: path to %s is missing\n') %
(lex.infile, lex.lineno, listname))
return 1
if name in mapping:
self.ui.warn(_('%s:%d: %r already in %s list\n') %
(lex.infile, lex.lineno, name, listname))
return 1
if (name.startswith('/') or
name.endswith('/') or
'//' in name):
self.ui.warn(_('%s:%d: superfluous / in %s %r\n') %
(lex.infile, lex.lineno, listname, name))
return 1
return 0
lex = shlex.shlex(open(path), path, True)
lex.wordchars += '!@#$%^&*()-=+[]{}|;:,./<>?'

View File

@ -128,3 +128,14 @@ echo 'copied:'
hg --cwd source cat copied
echo 'copied2:'
hg --cwd renames.repo cat copied2
echo % filemap errors
cat > errors.fmap <<EOF
include dir/ # beware that comments changes error line numbers!
exclude /dir
rename dir//dir /dir//dir/ "out of sync"
include
EOF
hg -q convert --filemap errors.fmap source errors.repo
true # happy ending

View File

@ -157,3 +157,11 @@ copied:
foo
copied2:
foo
% filemap errors
errors.fmap:1: superfluous / in exclude 'dir/'
errors.fmap:3: superfluous / in include '/dir'
errors.fmap:3: superfluous / in rename '/dir'
errors.fmap:3: superfluous / in exclude 'dir//dir'
errors.fmap:4: unknown directive 'out of sync'
errors.fmap:5: path to exclude is missing
abort: errors in filemap