예제 #1
0
 def _normalize(self, patterns, default, root, cwd, auditor):
     '''Convert 'kind:pat' from the patterns list to tuples with kind and
     normalized and rooted patterns and with listfiles expanded.'''
     kindpats = []
     for kind, pat in [_patsplit(p, default) for p in patterns]:
         if kind in ('glob', 'relpath'):
             pat = pathutil.canonpath(root, cwd, pat, auditor)
         elif kind in ('relglob', 'path'):
             pat = util.normpath(pat)
         elif kind in ('listfile', 'listfile0'):
             try:
                 files = util.readfile(pat)
                 if kind == 'listfile0':
                     files = files.split('\0')
                 else:
                     files = files.splitlines()
                 files = [f for f in files if f]
             except EnvironmentError:
                 raise util.Abort(_("unable to read file list (%s)") % pat)
             for k, p, source in self._normalize(files, default, root, cwd,
                                                 auditor):
                 kindpats.append((k, p, pat))
             continue
         elif kind == 'include':
             try:
                 includepats = readpatternfile(pat, self._warn)
                 for k, p, source in self._normalize(
                         includepats, default, root, cwd, auditor):
                     kindpats.append((k, p, source or pat))
             except util.Abort as inst:
                 raise util.Abort('%s: %s' % (pat, inst[0]))
             except IOError as inst:
                 if self._warn:
                     self._warn(
                         _("skipping unreadable pattern file "
                           "'%s': %s\n") % (pat, inst.strerror))
             continue
         # else: re or relre - which cannot be normalized
         kindpats.append((kind, pat, ''))
     return kindpats
예제 #2
0
def _normalize(names, default, root, cwd, auditor):
    pats = []
    for kind, name in [_patsplit(p, default) for p in names]:
        if kind in ('glob', 'relpath'):
            name = pathutil.canonpath(root, cwd, name, auditor)
        elif kind in ('relglob', 'path'):
            name = util.normpath(name)
        elif kind in ('listfile', 'listfile0'):
            try:
                files = util.readfile(name)
                if kind == 'listfile0':
                    files = files.split('\0')
                else:
                    files = files.splitlines()
                files = [f for f in files if f]
            except EnvironmentError:
                raise util.Abort(_("unable to read file list (%s)") % name)
            pats += _normalize(files, default, root, cwd, auditor)
            continue

        pats.append((kind, name))
    return pats
예제 #3
0
 def _normalize(self, patterns, default, root, cwd, auditor):
     '''Convert 'kind:pat' from the patterns list to tuples with kind and
     normalized and rooted patterns and with listfiles expanded.'''
     kindpats = []
     for kind, pat in [_patsplit(p, default) for p in patterns]:
         if kind in ('glob', 'relpath'):
             pat = pathutil.canonpath(root, cwd, pat, auditor)
         elif kind in ('relglob', 'path'):
             pat = util.normpath(pat)
         elif kind in ('listfile', 'listfile0'):
             try:
                 files = util.readfile(pat)
                 if kind == 'listfile0':
                     files = files.split('\0')
                 else:
                     files = files.splitlines()
                 files = [f for f in files if f]
             except EnvironmentError:
                 raise util.Abort(_("unable to read file list (%s)") % pat)
             for k, p, source in self._normalize(files, default, root, cwd,
                                                 auditor):
                 kindpats.append((k, p, pat))
             continue
         elif kind == 'include':
             try:
                 includepats = readpatternfile(pat, self._warn)
                 for k, p, source in self._normalize(includepats, default,
                                                     root, cwd, auditor):
                     kindpats.append((k, p, source or pat))
             except util.Abort as inst:
                 raise util.Abort('%s: %s' % (pat, inst[0]))
             except IOError as inst:
                 if self._warn:
                     self._warn(_("skipping unreadable pattern file "
                                  "'%s': %s\n") % (pat, inst.strerror))
             continue
         # else: re or relre - which cannot be normalized
         kindpats.append((kind, pat, ''))
     return kindpats
예제 #4
0
def _normalize(names, default, root, cwd, auditor):
    pats = []
    for kind, name in [_patsplit(p, default) for p in names]:
        if kind in ('glob', 'relpath'):
            name = pathutil.canonpath(root, cwd, name, auditor)
        elif kind in ('relglob', 'path'):
            name = util.normpath(name)
        elif kind in ('listfile', 'listfile0'):
            try:
                files = util.readfile(name)
                if kind == 'listfile0':
                    files = files.split('\0')
                else:
                    files = files.splitlines()
                files = [f for f in files if f]
            except EnvironmentError:
                raise util.Abort(_("unable to read file list (%s)") % name)
            pats += _normalize(files, default, root, cwd, auditor)
            continue

        pats.append((kind, name))
    return pats
예제 #5
0
def _expandsubinclude(kindpats, root):
    '''Returns the list of subinclude matchers and the kindpats without the
    subincludes in it.'''
    relmatchers = []
    other = []

    for kind, pat, source in kindpats:
        if kind == 'subinclude':
            sourceroot = pathutil.dirname(util.normpath(source))
            pat = util.pconvert(pat)
            path = pathutil.join(sourceroot, pat)

            newroot = pathutil.dirname(path)
            relmatcher = match(newroot, '', [], ['include:%s' % path])

            prefix = pathutil.canonpath(root, root, newroot)
            if prefix:
                prefix += '/'
            relmatchers.append((prefix, relmatcher))
        else:
            other.append((kind, pat, source))

    return relmatchers, other
예제 #6
0
def _expandsubinclude(kindpats, root):
    '''Returns the list of subinclude matchers and the kindpats without the
    subincludes in it.'''
    relmatchers = []
    other = []

    for kind, pat, source in kindpats:
        if kind == 'subinclude':
            sourceroot = pathutil.dirname(util.normpath(source))
            pat = util.pconvert(pat)
            path = pathutil.join(sourceroot, pat)

            newroot = pathutil.dirname(path)
            relmatcher = match(newroot, '', [], ['include:%s' % path])

            prefix = pathutil.canonpath(root, root, newroot)
            if prefix:
                prefix += '/'
            relmatchers.append((prefix, relmatcher))
        else:
            other.append((kind, pat, source))

    return relmatchers, other
예제 #7
0
def _normalize(patterns, default, root, cwd, auditor):
    '''Convert 'kind:pat' from the patterns list to tuples with kind and
    normalized and rooted patterns and with listfiles expanded.'''
    kindpats = []
    for kind, pat in [_patsplit(p, default) for p in patterns]:
        if kind in ('glob', 'relpath'):
            pat = pathutil.canonpath(root, cwd, pat, auditor)
        elif kind in ('relglob', 'path'):
            pat = util.normpath(pat)
        elif kind in ('listfile', 'listfile0'):
            try:
                files = util.readfile(pat)
                if kind == 'listfile0':
                    files = files.split('\0')
                else:
                    files = files.splitlines()
                files = [f for f in files if f]
            except EnvironmentError:
                raise util.Abort(_("unable to read file list (%s)") % pat)
            kindpats += _normalize(files, default, root, cwd, auditor)
            continue
        # else: re or relre - which cannot be normalized
        kindpats.append((kind, pat))
    return kindpats
예제 #8
0
def _normalize(patterns, default, root, cwd, auditor):
    '''Convert 'kind:pat' from the patterns list to tuples with kind and
    normalized and rooted patterns and with listfiles expanded.'''
    kindpats = []
    for kind, pat in [_patsplit(p, default) for p in patterns]:
        if kind in ('glob', 'relpath'):
            pat = pathutil.canonpath(root, cwd, pat, auditor)
        elif kind in ('relglob', 'path'):
            pat = util.normpath(pat)
        elif kind in ('listfile', 'listfile0'):
            try:
                files = util.readfile(pat)
                if kind == 'listfile0':
                    files = files.split('\0')
                else:
                    files = files.splitlines()
                files = [f for f in files if f]
            except EnvironmentError:
                raise util.Abort(_("unable to read file list (%s)") % pat)
            kindpats += _normalize(files, default, root, cwd, auditor)
            continue
        # else: re or relre - which cannot be normalized
        kindpats.append((kind, pat))
    return kindpats