##// END OF EJS Templates
run darker
dswij -
Show More
@@ -7,25 +7,24 b' whatsnew/development.rst (chronologically ordered), and deletes the snippets.'
7
7
8 import io
8 import io
9 import sys
9 import sys
10 from pathlib import Path
10 from pathlib import Path
11 from subprocess import check_call, check_output
11 from subprocess import check_call, check_output
12
12
13 repo_root = Path(__file__).resolve().parent.parent
13 repo_root = Path(__file__).resolve().parent.parent
14 whatsnew_dir = repo_root / 'docs' / 'source' / 'whatsnew'
14 whatsnew_dir = repo_root / "docs" / "source" / "whatsnew"
15 pr_dir = whatsnew_dir / 'pr'
15 pr_dir = whatsnew_dir / "pr"
16 target = whatsnew_dir / 'development.rst'
16 target = whatsnew_dir / "development.rst"
17
17
18 FEATURE_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT."
18 FEATURE_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT."
19 INCOMPAT_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. INCOMPAT INSERTION POINT."
19 INCOMPAT_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. INCOMPAT INSERTION POINT."
20
20
21 # 1. Collect the whatsnew snippet files ---------------------------------------
21 # 1. Collect the whatsnew snippet files ---------------------------------------
22
22
23 files = set(pr_dir.glob('*.rst'))
23 files = set(pr_dir.glob("*.rst"))
24 # Ignore explanatory and example files
24 # Ignore explanatory and example files
25 files.difference_update({pr_dir / f for f in {
25 files.difference_update(
26 'incompat-switching-to-perl.rst',
26 {pr_dir / f for f in {"incompat-switching-to-perl.rst", "antigravity-feature.rst"}}
27 'antigravity-feature.rst'}
27 )
28 })
29
28
30 if not files:
29 if not files:
31 print("No automatic update available for what's new")
30 print("No automatic update available for what's new")
@@ -33,30 +32,31 b' if not files:'
33
32
34
33
35 def getmtime(f):
34 def getmtime(f):
36 return check_output(['git', 'log', '-1', '--format="%ai"', '--', f])
35 return check_output(["git", "log", "-1", '--format="%ai"', "--", f])
36
37
37
38 files = sorted(files, key=getmtime)
38 files = sorted(files, key=getmtime)
39
39
40 features, incompats = [], []
40 features, incompats = [], []
41 for path in files:
41 for path in files:
42 with io.open(path, encoding='utf-8') as f:
42 with io.open(path, encoding="utf-8") as f:
43 try:
43 try:
44 content = f.read().rstrip()
44 content = f.read().rstrip()
45 except Exception as e:
45 except Exception as e:
46 raise Exception('Error reading "{}"'.format(f)) from e
46 raise Exception('Error reading "{}"'.format(f)) from e
47
47
48 if path.name.startswith('incompat-'):
48 if path.name.startswith("incompat-"):
49 incompats.append(content)
49 incompats.append(content)
50 else:
50 else:
51 features.append(content)
51 features.append(content)
52
52
53 # Put the insertion markers back on the end, so they're ready for next time.
53 # Put the insertion markers back on the end, so they're ready for next time.
54 feature_block = '\n\n'.join(features + [FEATURE_MARK])
54 feature_block = "\n\n".join(features + [FEATURE_MARK])
55 incompat_block = '\n\n'.join(incompats + [INCOMPAT_MARK])
55 incompat_block = "\n\n".join(incompats + [INCOMPAT_MARK])
56
56
57 # 2. Update the target file ---------------------------------------------------
57 # 2. Update the target file ---------------------------------------------------
58
58
59 with io.open(target, encoding='utf-8') as f:
59 with io.open(target, encoding="utf-8") as f:
60 content = f.read()
60 content = f.read()
61
61
62 assert content.count(FEATURE_MARK) == 1
62 assert content.count(FEATURE_MARK) == 1
@@ -66,16 +66,16 b' content = content.replace(FEATURE_MARK, feature_block)'
66 content = content.replace(INCOMPAT_MARK, incompat_block)
66 content = content.replace(INCOMPAT_MARK, incompat_block)
67
67
68 # Clean trailing whitespace
68 # Clean trailing whitespace
69 content = '\n'.join(l.rstrip() for l in content.splitlines())
69 content = "\n".join(l.rstrip() for l in content.splitlines())
70
70
71 with io.open(target, 'w', encoding='utf-8') as f:
71 with io.open(target, "w", encoding="utf-8") as f:
72 f.write(content)
72 f.write(content)
73
73
74 # 3. Stage the changes in git -------------------------------------------------
74 # 3. Stage the changes in git -------------------------------------------------
75
75
76 for file in files:
76 for file in files:
77 check_call(['git', 'rm', file])
77 check_call(["git", "rm", file])
78
78
79 check_call(['git', 'add', target])
79 check_call(["git", "add", target])
80
80
81 print("Merged what's new changes. Check the diff and commit the change.")
81 print("Merged what's new changes. Check the diff and commit the change.")
General Comments 0
You need to be logged in to leave comments. Login now