Mercurial > hg
annotate tests/test-check-code-hg.py @ 15164:7bddec632821
patchbomb: make it easy for the user to decline sending an intro message.
- prompt(): respect interactive mode; clarify logic a bit
- rename introneeded() to introwanted() and give it only one caller
- add 'numbered' arg to makepatch() so it does not need to call
introwanted()
- factor makeintro() out of getpatchmsgs(), so it's easier to skip the
intro message based on the user's behaviour
Unexpected but perfectly reasonable side effect: in non-interactive
mode, we don't show unanswerable "Cc" or "From" prompts anymore, so
remove those from the test expectations.
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Tue, 27 Sep 2011 22:38:47 -0400 |
parents | b0e3d3973440 |
children |
rev | line source |
---|---|
11762
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 # Pass all working directory files through check-code.py |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
2 |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
3 import sys, os, imp |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
4 rootdir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
5 if not os.path.isdir(os.path.join(rootdir, '.hg')): |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
6 sys.stderr.write('skipped: cannot check code on non-repository sources\n') |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
7 sys.exit(80) |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
8 |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
9 checkpath = os.path.join(rootdir, 'contrib/check-code.py') |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
10 checkcode = imp.load_source('checkcode', checkpath) |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
11 |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
12 from mercurial import hg, ui |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
13 u = ui.ui() |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 repo = hg.repository(u, rootdir) |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
15 checked = 0 |
11771
b0e3d3973440
tests: only run check-code on tracked files
Matt Mackall <mpm@selenic.com>
parents:
11762
diff
changeset
|
16 wctx = repo[None] |
b0e3d3973440
tests: only run check-code on tracked files
Matt Mackall <mpm@selenic.com>
parents:
11762
diff
changeset
|
17 for f in wctx: |
b0e3d3973440
tests: only run check-code on tracked files
Matt Mackall <mpm@selenic.com>
parents:
11762
diff
changeset
|
18 # ignore removed and unknown files |
b0e3d3973440
tests: only run check-code on tracked files
Matt Mackall <mpm@selenic.com>
parents:
11762
diff
changeset
|
19 if f not in wctx: |
b0e3d3973440
tests: only run check-code on tracked files
Matt Mackall <mpm@selenic.com>
parents:
11762
diff
changeset
|
20 continue |
11762
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
21 checked += 1 |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
22 checkcode.checkfile(os.path.join(rootdir, f)) |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
23 if not checked: |
8b03c988efb3
tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
24 sys.stderr.write('no file checked!\n') |