mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
convert: warn on superfluous / in paths
shlex is really a bad parser for this line-based format ...
This commit is contained in:
parent
a1c3bcbbfe
commit
ef1e88d17c
@ -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 += '!@#$%^&*()-=+[]{}|;:,./<>?'
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user