-
Notifications
You must be signed in to change notification settings - Fork 0
/
importpypychanges.py
73 lines (61 loc) · 1.88 KB
/
importpypychanges.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
import sys
import shutil
import subprocess
FILELIST = [
("astconsts.py", "../astcompiler/consts.py"),
"error.py",
("parsefuture.py", "future.py"),
"pygram.py",
"pytokenize.py",
"pytoken.py",
"automata.py",
"gendfa.py",
"dfa_generated.py",
"pylexer.py",
"metaparser.py",
"parser.py",
"pyparse.py",
"pytokenizer.py",
"data/Grammar2.7",
]
TESTLIST = [
"test_automata.py",
"test_future.py",
"test_gendfa.py",
"test_metaparser.py",
"test_pytokenizer.py",
"test_parser.py",
"test_pyparse.py",
]
TARGET = os.path.join(os.path.dirname(__file__), "src", "syntaxerrors")
TARGETTEST = os.path.join(os.path.dirname(__file__), "tests")
def main():
pypydir = sys.argv[1]
assert os.path.isdir(pypydir)
# check that no local changes
subprocess.check_output("git diff --exit-code", shell=True)
subprocess.check_output("git checkout pypy-import", shell=True)
addfiles = ["PYPYREV"]
for t in FILELIST:
if isinstance(t, tuple):
target, source = t
else:
target = source = t
source = os.path.join(pypydir, "pypy", "interpreter", "pyparser", source)
target = os.path.join(TARGET, target)
shutil.copy(source, target)
addfiles.append(target)
for filename in TESTLIST:
source = os.path.join(pypydir, "pypy", "interpreter", "pyparser", "test", filename)
target = os.path.join(TARGETTEST, filename)
shutil.copy(source, target)
addfiles.append(target)
rev = subprocess.check_output("hg id -i", shell=True, cwd=pypydir)
print rev
with open("PYPYREV", "w") as f:
f.write(rev)
subprocess.check_output("git add " + " ".join(addfiles), shell=True)
subprocess.check_output('git commit -m "updated PyPy files to %s"' % rev.strip(), shell=True)
if __name__ == '__main__':
main()