tests/test-check-code-hg.py
changeset 15557 7bb5ed61b74c
parent 15556 e5804c0f6576
child 15558 c6b600d2348c
equal deleted inserted replaced
15556:e5804c0f6576 15557:7bb5ed61b74c
     1 # Pass all working directory files through check-code.py
       
     2 
       
     3 import sys, os, imp
       
     4 rootdir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
       
     5 if not os.path.isdir(os.path.join(rootdir, '.hg')):
       
     6     sys.stderr.write('skipped: cannot check code on non-repository sources\n')
       
     7     sys.exit(80)
       
     8 
       
     9 checkpath = os.path.join(rootdir, 'contrib/check-code.py')
       
    10 checkcode = imp.load_source('checkcode', checkpath)
       
    11 
       
    12 from mercurial import hg, ui
       
    13 u = ui.ui()
       
    14 repo = hg.repository(u, rootdir)
       
    15 checked = 0
       
    16 wctx = repo[None]
       
    17 for f in wctx:
       
    18     # ignore removed and unknown files
       
    19     if f not in wctx:
       
    20         continue
       
    21     checked += 1
       
    22     checkcode.checkfile(os.path.join(rootdir, f))
       
    23 if not checked:
       
    24     sys.stderr.write('no file checked!\n')