Exemplo n.º 1
0
def cdm_mapfilechk(ui, repo, *args, **opts):
    '''check for a valid MAPFILE header block in active files

    Check that all link-editor mapfiles contain the standard mapfile
    header comment directing the reader to the document containing
    Solaris object versioning rules (README.mapfile).'''

    filelist = buildfilelist(wslist[repo], opts.get('parent'), args)
    exclude = not_check(repo, 'mapfilechk')
    ret = 0

    ui.write('Mapfile comment check:\n')

    for f, e in filelist:
        if e and e.is_removed():
            continue
        elif f.find('mapfile') == -1:
            continue
        elif (e or opts.get('honour_nots')) and exclude(f):
            ui.status('Skipping %s...\n' % f)
            continue

        fh = open(f, 'r')
        ret |= Mapfile.mapfilechk(fh, output=ui)
        fh.close()
    return ret
Exemplo n.º 2
0
def cdm_mapfilechk(ui, repo, *args, **opts):
    '''check for a valid mapfile header block in active files

    Check that all link-editor mapfiles contain the standard mapfile
    header comment directing the reader to the document containing
    Solaris object versioning rules (README.mapfile).

    Files can be excluded from this check using the mapfilechk.NOT
    file.  See NOT Files in the extension documentation ('hg help
    cdm').
    '''

    filelist = buildfilelist(wslist[repo], opts.get('parent'), args)
    exclude = not_check(repo, 'mapfilechk')
    ret = 0

    # We are interested in examining any file that has the following
    # in its final path segment:
    #    - Contains the word 'mapfile'
    #    - Begins with 'map.'
    #    - Ends with '.map'
    # We don't want to match unless these things occur in final path segment
    # because directory names with these strings don't indicate a mapfile.
    # We also ignore files with suffixes that tell us that the files
    # are not mapfiles.
    MapfileRE = re.compile(r'.*((mapfile[^/]*)|(/map\.+[^/]*)|(\.map))$',
        re.IGNORECASE)
    NotMapSuffixRE = re.compile(r'.*\.[ch]$', re.IGNORECASE)

    ui.write('Mapfile comment check:\n')

    for f, e in filelist:
        if e and e.is_removed():
            continue
        elif (not MapfileRE.match(f)) or NotMapSuffixRE.match(f):
            continue
        elif (e or opts.get('honour_nots')) and exclude(f):
            ui.status('Skipping %s...\n' % f)
            continue

        fh = open(f, 'r')
        ret |= Mapfile.mapfilechk(fh, output=ui)
        fh.close()
    return ret
Exemplo n.º 3
0
def mapfilechk(root, parent, flist, output):
    ret = 0

    # We are interested in examining any file that has the following
    # in its final path segment:
    #    - Contains the word 'mapfile'
    #    - Begins with 'map.'
    #    - Ends with '.map'
    # We don't want to match unless these things occur in final path segment
    # because directory names with these strings don't indicate a mapfile.
    # We also ignore files with suffixes that tell us that the files
    # are not mapfiles.
    MapfileRE = re.compile(r'.*((mapfile[^/]*)|(/map\.+[^/]*)|(\.map))$',
                           re.IGNORECASE)
    NotMapSuffixRE = re.compile(r'.*\.[ch]$', re.IGNORECASE)

    output.write("Mapfile comments:\n")

    for f in flist(
            lambda x: MapfileRE.match(x) and not NotMapSuffixRE.match(x)):
        with io.open(f, encoding='utf-8', errors='replace') as fh:
            ret |= Mapfile.mapfilechk(fh, output=output)
    return ret
Exemplo n.º 4
0
def mapfilechk(root, parent, flist, output):
    ret = 0

    # We are interested in examining any file that has the following
    # in its final path segment:
    #    - Contains the word 'mapfile'
    #    - Begins with 'map.'
    #    - Ends with '.map'
    # We don't want to match unless these things occur in final path segment
    # because directory names with these strings don't indicate a mapfile.
    # We also ignore files with suffixes that tell us that the files
    # are not mapfiles.
    MapfileRE = re.compile(r'.*((mapfile[^/]*)|(/map\.+[^/]*)|(\.map))$',
        re.IGNORECASE)
    NotMapSuffixRE = re.compile(r'.*\.[ch]$', re.IGNORECASE)

    output.write("Mapfile comments:\n")

    for f in flist(lambda x: MapfileRE.match(x) and not
                   NotMapSuffixRE.match(x)):
        fh = open(f, 'r')
        ret |= Mapfile.mapfilechk(fh, output=output)
        fh.close()
    return ret