diff mbox series

mklog: fix bugs of --append option

Message ID 20230719082126.265155-1-lehua.ding@rivai.ai
State New
Headers show
Series mklog: fix bugs of --append option | expand

Commit Message

Lehua Ding July 19, 2023, 8:21 a.m. UTC
Hi,

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.

contrib/ChangeLog:

	* mklog.py: Fix regexp and add missed `---`

---
 contrib/mklog.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Lehua Ding July 26, 2023, 6:30 a.m. UTC | #1
Hi,

Gentle Ping.

I sent a V2 patch as below for an additional fix Python code format error,
which Martin reported, thanks.

Best,
Lehua

contrib/ChangeLog:

	* mklog.py: Fix bugs.
---
 contrib/mklog.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/contrib/mklog.py b/contrib/mklog.py
index 26230b9b4f2..0abefcd9374 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:
Lehua Ding Aug. 16, 2023, 5:10 a.m. UTC | #2
Hi Jeff,


Can you take a look at this little patch?
It's a bugfix patch that only affects the --apend
option that I added earlier, not anyone else.
And please let me know if there is a more
suitable reviewer as well. Thank you so much.


Best,
Lehua





------------------ Original ------------------
From:                                                                                                                        "Lehua Ding"                                                                                    <lehua.ding@rivai.ai&gt;;
Date:&nbsp;Wed, Jul 26, 2023 02:30 PM
To:&nbsp;"gcc-patches"<gcc-patches@gcc.gnu.org&gt;;
Cc:&nbsp;"juzhe.zhong"<juzhe.zhong@rivai.ai&gt;;"jeffreyalaw"<jeffreyalaw@gmail.com&gt;;"mjambor"<mjambor@suse.cz&gt;;
Subject:&nbsp;Re: [PATCH] mklog: fix bugs of --append option



Hi,

Gentle Ping.

I sent a V2 patch as below for an additional fix Python code format error,
which Martin reported, thanks.

Best,
Lehua

contrib/ChangeLog:

 * mklog.py: Fix bugs.
---
contrib/mklog.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/contrib/mklog.py b/contrib/mklog.py
index 26230b9b4f2..0abefcd9374 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):
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise Exception("`-a or --append` option not support standard input")
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise Exception("`-a or --append` option not support standard "
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "input")
 lines = []
 with open(args.input, 'r', newline='\n') as f:
 # 1 -&gt; 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
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elif maybe_diff_log == 2 and \
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; re.match("\s[^\s]+\s+\|\s\d+\s[+\-]+\n", line):
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elif (maybe_diff_log == 2 and
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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:
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lines.append("---\n")
 maybe_diff_log = 1
 lines.append(line)
 with open(args.input, "w") as f:
Lehua Ding Aug. 22, 2023, 3:09 a.m. UTC | #3
Gentle ping this little fix patch.
Can anyone help review this patch?
Thanks in advance.

Best,
Lehua

On 2023/7/26 14:30, Lehua Ding wrote:
> Hi,
> 
> Gentle Ping.
> 
> I sent a V2 patch as below for an additional fix Python code format error,
> which Martin reported, thanks.
> 
> Best,
> Lehua
> 
> contrib/ChangeLog:
> 
> 	* mklog.py: Fix bugs.
> ---
>   contrib/mklog.py | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/contrib/mklog.py b/contrib/mklog.py
> index 26230b9b4f2..0abefcd9374 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:
Jeff Law Aug. 28, 2023, 11:38 p.m. UTC | #4
On 7/19/23 02:21, Lehua Ding wrote:
> Hi,
> 
> 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.
> 
> contrib/ChangeLog:
> 
> 	* mklog.py: Fix regexp and add missed `---`
OK.  Sorry for the delay.
jeff
Lehua Ding Aug. 29, 2023, 1:43 a.m. UTC | #5
Committed the V2 patch, which additional fix some code format warning, 
thanks Jeff.

On 2023/8/29 7:38, Jeff Law wrote:
> 
> 
> On 7/19/23 02:21, Lehua Ding wrote:
>> Hi,
>>
>> 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.
>>
>> contrib/ChangeLog:
>>
>>     * mklog.py: Fix regexp and add missed `---`
> OK.  Sorry for the delay.
> jeff
>
diff mbox series

Patch

diff --git a/contrib/mklog.py b/contrib/mklog.py
index 26230b9b4f2..bd81c5ba92c 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -385,12 +385,13 @@  if __name__ == '__main__':
                     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):
+                         re.match("\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: