Show More
@@ -1,2 +1,3 b'' | |||||
1 | IPython debugger (IPdb) now supports the number of context lines for the |
|
1 | IPython debugger (IPdb) now supports the number of context lines for the | |
2 | ``where`` (and ``w``) commands. The `context` keyword is also available in various APIs. |
|
2 | ``where`` (and ``w``) commands. The `context` keyword is also available in various APIs. | |
|
3 | See PR #9097 |
@@ -1,80 +1,78 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | """Update the What's New doc (development version) |
|
2 | """Update the What's New doc (development version) | |
3 |
|
3 | |||
4 | This collects the snippets from whatsnew/pr/, moves their content into |
|
4 | This collects the snippets from whatsnew/pr/, moves their content into | |
5 | whatsnew/development.rst (chronologically ordered), and deletes the snippets. |
|
5 | whatsnew/development.rst (chronologically ordered), and deletes the snippets. | |
6 | """ |
|
6 | """ | |
7 |
|
7 | |||
8 | import io |
|
8 | import io | |
9 | import os |
|
9 | import os | |
10 | from glob import glob |
|
10 | from glob import glob | |
11 | from os.path import dirname, basename, abspath, join as pjoin |
|
11 | from os.path import dirname, basename, abspath, join as pjoin | |
12 | from subprocess import check_call, check_output |
|
12 | from subprocess import check_call, check_output | |
13 |
|
13 | |||
14 | repo_root = dirname(dirname(abspath(__file__))) |
|
14 | repo_root = dirname(dirname(abspath(__file__))) | |
15 | whatsnew_dir = pjoin(repo_root, 'docs', 'source', 'whatsnew') |
|
15 | whatsnew_dir = pjoin(repo_root, 'docs', 'source', 'whatsnew') | |
16 | pr_dir = pjoin(whatsnew_dir, 'pr') |
|
16 | pr_dir = pjoin(whatsnew_dir, 'pr') | |
17 | target = pjoin(whatsnew_dir, 'development.rst') |
|
17 | target = pjoin(whatsnew_dir, 'development.rst') | |
18 |
|
18 | |||
19 | FEATURE_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT." |
|
19 | FEATURE_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT." | |
20 | INCOMPAT_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. INCOMPAT INSERTION POINT." |
|
20 | INCOMPAT_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. INCOMPAT INSERTION POINT." | |
21 |
|
21 | |||
22 | # 1. Collect the whatsnew snippet files --------------------------------------- |
|
22 | # 1. Collect the whatsnew snippet files --------------------------------------- | |
23 |
|
23 | |||
24 | files = set() |
|
24 | files = set(glob(pjoin(pr_dir, '*.rst'))) | |
25 | for f in glob(pjoin(pr_dir, '*.rst')): |
|
|||
26 | files.add(f) |
|
|||
27 | # Ignore explanatory and example files |
|
25 | # Ignore explanatory and example files | |
28 |
files.difference_update({pjoin(pr_dir, f) for f in { |
|
26 | files.difference_update({pjoin(pr_dir, f) for f in { | |
29 | 'incompat-switching-to-perl.rst', |
|
27 | 'incompat-switching-to-perl.rst', | |
30 | 'antigravity-feature.rst'} |
|
28 | 'antigravity-feature.rst'} | |
31 | }) |
|
29 | }) | |
32 |
|
30 | |||
33 |
|
31 | |||
34 | def getmtime(f): |
|
32 | def getmtime(f): | |
35 | return check_output(['git', 'log', '-1', '--format="%ai"', '--', f]) |
|
33 | return check_output(['git', 'log', '-1', '--format="%ai"', '--', f]) | |
36 |
|
34 | |||
37 | files = sorted(files, key=getmtime) |
|
35 | files = sorted(files, key=getmtime) | |
38 |
|
36 | |||
39 | features, incompats = [], [] |
|
37 | features, incompats = [], [] | |
40 | for path in files: |
|
38 | for path in files: | |
41 | with io.open(path, encoding='utf-8') as f: |
|
39 | with io.open(path, encoding='utf-8') as f: | |
42 | try: |
|
40 | try: | |
43 | content = f.read().rstrip() |
|
41 | content = f.read().rstrip() | |
44 | except Exception as e: |
|
42 | except Exception as e: | |
45 | raise Exception('Error reading "{}"'.format(f)) |
|
43 | raise Exception('Error reading "{}"'.format(f)) from e | |
46 |
|
44 | |||
47 | if basename(path).startswith('incompat-'): |
|
45 | if basename(path).startswith('incompat-'): | |
48 | incompats.append(content) |
|
46 | incompats.append(content) | |
49 | else: |
|
47 | else: | |
50 | features.append(content) |
|
48 | features.append(content) | |
51 |
|
49 | |||
52 | # Put the insertion markers back on the end, so they're ready for next time. |
|
50 | # Put the insertion markers back on the end, so they're ready for next time. | |
53 | feature_block = '\n\n'.join(features + [FEATURE_MARK]) |
|
51 | feature_block = '\n\n'.join(features + [FEATURE_MARK]) | |
54 | incompat_block = '\n\n'.join(incompats + [INCOMPAT_MARK]) |
|
52 | incompat_block = '\n\n'.join(incompats + [INCOMPAT_MARK]) | |
55 |
|
53 | |||
56 | # 2. Update the target file --------------------------------------------------- |
|
54 | # 2. Update the target file --------------------------------------------------- | |
57 |
|
55 | |||
58 | with io.open(target, encoding='utf-8') as f: |
|
56 | with io.open(target, encoding='utf-8') as f: | |
59 | content = f.read() |
|
57 | content = f.read() | |
60 |
|
58 | |||
61 | assert content.count(FEATURE_MARK) == 1 |
|
59 | assert content.count(FEATURE_MARK) == 1 | |
62 | assert content.count(INCOMPAT_MARK) == 1 |
|
60 | assert content.count(INCOMPAT_MARK) == 1 | |
63 |
|
61 | |||
64 | content = content.replace(FEATURE_MARK, feature_block) |
|
62 | content = content.replace(FEATURE_MARK, feature_block) | |
65 | content = content.replace(INCOMPAT_MARK, incompat_block) |
|
63 | content = content.replace(INCOMPAT_MARK, incompat_block) | |
66 |
|
64 | |||
67 | # Clean trailing whitespace |
|
65 | # Clean trailing whitespace | |
68 | content = '\n'.join(l.rstrip() for l in content.splitlines()) |
|
66 | content = '\n'.join(l.rstrip() for l in content.splitlines()) | |
69 |
|
67 | |||
70 | with io.open(target, 'w', encoding='utf-8') as f: |
|
68 | with io.open(target, 'w', encoding='utf-8') as f: | |
71 | f.write(content) |
|
69 | f.write(content) | |
72 |
|
70 | |||
73 | # 3. Stage the changes in git ------------------------------------------------- |
|
71 | # 3. Stage the changes in git ------------------------------------------------- | |
74 |
|
72 | |||
75 | for file in files: |
|
73 | for file in files: | |
76 | check_call(['git', 'rm', file]) |
|
74 | check_call(['git', 'rm', file]) | |
77 |
|
75 | |||
78 | check_call(['git', 'add', target]) |
|
76 | check_call(['git', 'add', target]) | |
79 |
|
77 | |||
80 | print("Merged what's new changes. Check the diff and commit the change.") |
|
78 | 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