convert: warn on superfluous / in paths
shlex is really a bad parser for this line-based format ...
--- a/hgext/convert/filemap.py Sat Jul 24 22:15:22 2010 +0200
+++ b/hgext/convert/filemap.py Tue Jul 20 15:49:28 2010 +0200
@@ -33,10 +33,20 @@
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 += '!@#$%^&*()-=+[]{}|;:,./<>?'
--- a/tests/test-convert-filemap Sat Jul 24 22:15:22 2010 +0200
+++ b/tests/test-convert-filemap Tue Jul 20 15:49:28 2010 +0200
@@ -128,3 +128,14 @@
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
--- a/tests/test-convert-filemap.out Sat Jul 24 22:15:22 2010 +0200
+++ b/tests/test-convert-filemap.out Tue Jul 20 15:49:28 2010 +0200
@@ -157,3 +157,11 @@
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