convert: make filemap favor most specific filtering rule
A filemap like:
exclude "doc"
include "doc/foo.txt"
will now preserve doc/foo.txt and exclude everything else in doc/.
--- a/hgext/convert/filemap.py Tue Nov 17 13:24:58 2009 +0100
+++ b/hgext/convert/filemap.py Tue Nov 10 13:04:03 2009 +0100
@@ -10,11 +10,11 @@
from common import SKIPREV, converter_source
def rpairs(name):
- yield '.', name
e = len(name)
while e != -1:
yield name[:e], name[e+1:]
e = name.rfind('/', 0, e)
+ yield '.', name
class filemapper(object):
'''Map and filter filenames when importing.
@@ -82,7 +82,7 @@
exc = self.lookup(name, self.exclude)[0]
else:
exc = ''
- if not inc or exc:
+ if (not self.include and exc) or (len(inc) <= len(exc)):
return None
newpre, pre, suf = self.lookup(name, self.rename)
if newpre: