On Sun, Jan 17, 2021 at 01:16:59PM -0000, futat...@apache.org wrote:
> Author: futatuki
> Date: Sun Jan 17 13:16:59 2021
> New Revision: 1885600
> 
> URL: http://svn.apache.org/viewvc?rev=1885600&view=rev
> Log:
> Follow up to r1884427, r1885557: mailer.py: Fix mixture of bytes/str.

This change seems to have changed the output of mailer.py. The new
output looks better (no leading slash on paths), but the test suite
fails because it still expects the old output.

The differences detected by the mailer.py test suite are:

--- mailer-t1.output    Mon Dec 14 17:15:21 2020
+++ mailer-t1.current   Fri Jan 22 12:45:38 2021
@@ -283,33 +283,33 @@
 
 Added:
    dir2/file7
-      - copied unchanged from r2, /file1
+      - copied unchanged from r2, file1
    dir3/   (props changed)
-      - copied from r2, /dir1/
+      - copied from r2, dir1/
 Replaced:
    dir3/file3
-      - copied unchanged from r1, /dir1/file3
+      - copied unchanged from r1, dir1/file3
    dir3/file4
-      - copied unchanged from r1, /dir1/file4
+      - copied unchanged from r1, dir1/file4
 
-Copied: dir2/file7 (from r2, /file1)
+Copied: dir2/file7 (from r2, file1)
 ==============================================================================
 --- /dev/null  00:00:00 1970   (empty, because file is newly added)
-+++ dir2/file7 Sun Sep  9 07:20:00 2001        (r3, copy of r2, /file1)
++++ dir2/file7 Sun Sep  9 07:20:00 2001        (r3, copy of r2, file1)
 @@ -0,0 +1 @@
 +file1
 
-Copied: dir3/file3 (from r1, /dir1/file3)
+Copied: dir3/file3 (from r1, dir1/file3)
 ==============================================================================
 --- /dev/null  00:00:00 1970   (empty, because file is newly added)
-+++ dir3/file3 Sun Sep  9 07:20:00 2001        (r3, copy of r1, /dir1/file3)
++++ dir3/file3 Sun Sep  9 07:20:00 2001        (r3, copy of r1, dir1/file3)
 @@ -0,0 +1 @@
 +file3
 
-Copied: dir3/file4 (from r1, /dir1/file4)
+Copied: dir3/file4 (from r1, dir1/file4)
 ==============================================================================
 --- /dev/null  00:00:00 1970   (empty, because file is newly added)
-+++ dir3/file4 Sun Sep  9 07:20:00 2001        (r3, copy of r1, /dir1/file4)
++++ dir3/file4 Sun Sep  9 07:20:00 2001        (r3, copy of r1, dir1/file4)
 @@ -0,0 +1 @@
 +file4
 Group: All
@@ -324,11 +324,11 @@
 
 Added:
    dir3/file8
-      - copied, changed from r2, /file1
+      - copied, changed from r2, file1
 
-Copied and modified: dir3/file8 (from r2, /file1)
+Copied and modified: dir3/file8 (from r2, file1)
 ==============================================================================
---- /file1     Sun Sep  9 04:33:20 2001        (r2, copy source)
+--- file1      Sun Sep  9 04:33:20 2001        (r2, copy source)
 +++ dir3/file8 Sun Sep  9 10:06:40 2001        (r4)
 @@ -1 +1,2 @@
  file1
@@ -639,26 +639,26 @@
 
 Added:
    dir6/
-      - copied from r6, /dir3/
+      - copied from r6, dir3/
    dir6/dir5/
-      - copied from r7, /dir3/dir5/
+      - copied from r7, dir3/dir5/
 Replaced:
    dir6/file3
-      - copied unchanged from r7, /dir3/file3
+      - copied unchanged from r7, dir3/file3
 Modified:
    dir6/file4
 
-Copied: dir6/file3 (from r7, /dir3/file3)
+Copied: dir6/file3 (from r7, dir3/file3)
 ==============================================================================
 --- /dev/null  00:00:00 1970   (empty, because file is newly added)
-+++ dir6/file3 Sun Sep  9 21:13:20 2001        (r8, copy of r7, /dir3/file3)
++++ dir6/file3 Sun Sep  9 21:13:20 2001        (r8, copy of r7, dir3/file3)
 @@ -0,0 +1,2 @@
 +file3
 +change C5
 
 Modified: dir6/file4
 ==============================================================================
---- /dir3/file4        Sun Sep  9 15:40:00 2001        (r6)
+--- dir3/file4 Sun Sep  9 15:40:00 2001        (r6)
 +++ dir6/file4 Sun Sep  9 21:13:20 2001        (r8)
 @@ -1 +1,2 @@
  file4

> * tools/hook-scripts/mailer/mailer.py
>   (): Rename imported function urllib.parse.quote from urlib_parse_quote to
>    _url_quote.
>   (remove_leading_slashes): Treat path as a bytes, if it is not None.
>   (Commit.__init__): Fix the case that SVN_PROP_REVISION_LOG property is NULL.
>   (DiffURLSelections._get_url): Use renamed urllib.parse.quote function and
>    'if' expression for readability.
>   (generate_content): Set data.log as s str.
>   (TextCommitRenderer.render): Treat data.log as a str.
> 
> Modified:
>     subversion/trunk/tools/hook-scripts/mailer/mailer.py
> 
> Modified: subversion/trunk/tools/hook-scripts/mailer/mailer.py
> URL: 
> http://svn.apache.org/viewvc/subversion/trunk/tools/hook-scripts/mailer/mailer.py?rev=1885600&r1=1885599&r2=1885600&view=diff
> ==============================================================================
> --- subversion/trunk/tools/hook-scripts/mailer/mailer.py (original)
> +++ subversion/trunk/tools/hook-scripts/mailer/mailer.py Sun Jan 17 13:16:59 
> 2021
> @@ -47,7 +47,7 @@
>  import os
>  import sys
>  import configparser
> -from urllib.parse import quote as urllib_parse_quote
> +from urllib.parse import quote as _url_quote
>  import time
>  import subprocess
>  from io import BytesIO
> @@ -120,7 +120,7 @@ def main(pool, cmd, config_fname, repos_
>  
>  
>  def remove_leading_slashes(path):
> -  while path and path[0] == '/':
> +  while path and path[0:1] == b'/':
>      path = path[1:]
>    return path
>  
> @@ -431,8 +431,8 @@ class Commit(Messenger):
>  
>      self.changelist = sorted(editor.get_changes().items())
>  
> -    log = repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG) or ''
> -    log = log.decode('utf-8')
> +    log = (repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG)
> +           or b'').decode('utf-8')
>  
>      # collect the set of groups and the unique sets of params for the options
>      self.groups = { }
> @@ -708,9 +708,9 @@ class DiffURLSelections:
>      # parameters for the configuration module, otherwise we may get
>      # KeyError exceptions.
>      params = self.params.copy()
> -    params['path'] = change.path and urllib_parse_quote(change.path) or None
> -    params['base_path'] = change.base_path and 
> urllib_parse_quote(change.base_path) \
> -                          or None
> +    params['path'] = _url_quote(change.path) if change.path else None
> +    params['base_path'] = (_url_quote(change.base_path)  
> +                           if change.base_path else None)
>      params['rev'] = repos_rev
>      params['base_rev'] = change.base_rev
>  
> @@ -764,7 +764,8 @@ def generate_content(renderer, cfg, repo
>      author=repos.author,
>      date=date,
>      rev=repos.rev,
> -    log=repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG) or '',
> +    log=(repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG)
> +         or b'').decode('utf-8'),
>      commit_url=commit_url,
>      added_data=generate_list('A', changelist, paths, True),
>      replaced_data=generate_list('R', changelist, paths, True),
> @@ -1110,7 +1111,7 @@ class TextCommitRenderer:
>      else:
>        w('\n')
>  
> -    w('Log:\n%s\n\n' % data.log.strip().decode('utf-8'))
> +    w('Log:\n%s\n\n' % data.log.strip())
>  
>      # print summary sections
>      self._render_list('Added', data.added_data)
> 
> 
> 

Reply via email to