aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLehua Ding <lehua.ding@rivai.ai>2023-07-18 18:08:47 +0800
committerLehua Ding <lehua.ding@rivai.ai>2023-08-29 09:36:52 +0800
commitebffc840f50112196d0d55a384a2c29b08964319 (patch)
treec4c31177aded05bf43cdd83da583126e7b0e8350
parent88ae53a3852dac73fdecb9cfcee2c5100cee832f (diff)
downloadgcc-ebffc840f50112196d0d55a384a2c29b08964319.zip
gcc-ebffc840f50112196d0d55a384a2c29b08964319.tar.gz
gcc-ebffc840f50112196d0d55a384a2c29b08964319.tar.bz2
mklog: fix bugs of --append option
This little patch fix two bugs of mklog.py with --append option. The first bug is that the regexp used is not accurate enough to determine the top of diff area. The second bug is that if `---` is not a true start, it needs to be added back to the patch file. And with additional fix Python code format error, which Martin reported. contrib/ChangeLog: * mklog.py: Fix bugs.
-rwxr-xr-xcontrib/mklog.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/contrib/mklog.py b/contrib/mklog.py
index 26230b9..0abefcd 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -374,7 +374,8 @@ if __name__ == '__main__':
args.fill_up_bug_titles, args.pr_numbers)
if args.append:
if (not args.input):
- raise Exception("`-a or --append` option not support standard input")
+ raise Exception("`-a or --append` option not support standard "
+ "input")
lines = []
with open(args.input, 'r', newline='\n') as f:
# 1 -> not find the possible start of diff log
@@ -384,13 +385,14 @@ if __name__ == '__main__':
for line in f:
if maybe_diff_log == 1 and line == "---\n":
maybe_diff_log = 2
- elif maybe_diff_log == 2 and \
- re.match("\s[^\s]+\s+\|\s\d+\s[+\-]+\n", line):
+ elif (maybe_diff_log == 2 and
+ re.match(r"\s[^\s]+\s+\|\s+\d+\s[+\-]+\n", line)):
lines += [output, "---\n", line]
maybe_diff_log = 3
else:
# the possible start is not the true start.
if maybe_diff_log == 2:
+ lines.append("---\n")
maybe_diff_log = 1
lines.append(line)
with open(args.input, "w") as f: