tests/test-check-code-hg.py
author Christian Ebert <blacktrash@gmx.net>
Wed, 01 Dec 2010 10:51:49 +0100
branchstable
changeset 13069 6aff4f144ad3
parent 11771 b0e3d3973440
permissions -rw-r--r--
keyword: copy: when copied source is a symlink, follow it 1) hg cp symlink copy -> copy is a symlink. 2) cp symlink copy; hg cp -A symlink copy -> copy is a regular file. In the second case we have to follow the symlink to its target to find out whether we have to unexpand keywords in the copy. Add test covering the case where the copied link's target is ignored by keyword but has content which would match the regex for expanded keywords to check whether we indeed leave the destination alone.

# Pass all working directory files through check-code.py

import sys, os, imp
rootdir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
if not os.path.isdir(os.path.join(rootdir, '.hg')):
    sys.stderr.write('skipped: cannot check code on non-repository sources\n')
    sys.exit(80)

checkpath = os.path.join(rootdir, 'contrib/check-code.py')
checkcode = imp.load_source('checkcode', checkpath)

from mercurial import hg, ui
u = ui.ui()
repo = hg.repository(u, rootdir)
checked = 0
wctx = repo[None]
for f in wctx:
    # ignore removed and unknown files
    if f not in wctx:
        continue
    checked += 1
    checkcode.checkfile(os.path.join(rootdir, f))
if not checked:
    sys.stderr.write('no file checked!\n')