4871: Unable to rbt post when using subversion after renaming a file

pfee

What version are you running?

OpenSUSE Tumbleweed (w/updates as of 15 May 2020)
SVN 1.13.0
Python 3.8.2
RBTools 1.0.2

What steps will reproduce the problem?

  1. Make changes in an SVN sandbox, including renaming a file with "svn mv".
  2. Post the changes for review using "rbt post -d --svn-show-copies-as-adds=n"
  3. Posting fails due to python exception

What is the expected output? What do you see instead?

Expect "Review request #xyz posted."

Instead see Python exception and stacktrace:

<initial output snipped ...>

Running: svn --non-interactive diff --diff-cmd=diff --notice-ancestry -r BASE --no-diff-deleted
Traceback (most recent call last):
File "/usr/bin/rbt", line 11, in <module>
load_entry_point('RBTools==1.0.2', 'console_scripts', 'rbt')()
File "/usr/lib/python3.8/site-packages/rbtools/commands/main.py", line 120, in main
command.run_from_argv([RB_MAIN, command_name] + args)
File "/usr/lib/python3.8/site-packages/rbtools/commands/init.py", line 725, in run_from_argv
exit_code = self.main(*args) or 0
File "/usr/lib/python3.8/site-packages/rbtools/commands/post.py", line 802, in main
diff_info = self.tool.diff(
File "/usr/lib/python3.8/site-packages/rbtools/clients/svn.py", line 517, in diff
diff = self._handle_empty_files(diff, diff_cmd,
File "/usr/lib/python3.8/site-packages/rbtools/clients/svn.py", line 789, in _handle_empty_files
result.append(b'--- %s\t%s\n' % (filename.encode(_fs_encoding),
AttributeError: 'bytes' object has no attribute 'encode'

What operating system are you using?

Linux, openSUSE Tumbleweed. Distro packaged versions of RBTools, python3 and subversion.

Please provide any additional information below.

Debugged this using python debugger: python3 -m pdb /usr/bin/rbt post -d --svn-show-copies-as-adds=n

(Pdb) b /usr/lib/python3.8/site-packages/rbtools/clients/svn.py:789

Relevant code:
788 result.append(b'%s\n' % self.INDEX_SEP)
789 result.append(b'--- %s\t%s\n' % (filename.encode(_fs_encoding),
790 base.encode('utf-8')))
791 result.append(b'+++ %s\t%s\n' % (filename.encode(_fs_encoding),
792 tip.encode('utf-8')))

The "filename" variable is of type "bytes", rather than "str", hence doesn't have a .encode() method.

Removing this .encode() call allowed the "rbt post" to work as expected. The contents of filename comes from the "diff_content", so I suspect it will always by of type "bytes", though I haven't tested the fix below extensively.

PATCH

$ diff -u /usr/lib/python3.8/site-packages/rbtools/clients/svn.py.orig /usr/lib/python3.8/site-packages/rbtools/clients/svn.py
--- /usr/lib/python3.8/site-packages/rbtools/clients/svn.py.orig 2020-05-15 16:10:03.876230238 +0100
+++ /usr/lib/python3.8/site-packages/rbtools/clients/svn.py 2020-05-15 16:12:36.331769935 +0100
@@ -786,9 +786,9 @@
tip = revisions['tip']

             result.append(b'%s\n' % self.INDEX_SEP)
  • result.append(b'--- %s\t%s\n' % (filename.encode(_fs_encoding),
  • result.append(b'--- %s\t%s\n' % (filename,
    base.encode('utf-8')))
  • result.append(b'+++ %s\t%s\n' % (filename.encode(_fs_encoding),
  • result.append(b'+++ %s\t%s\n' % (filename,
    tip.encode('utf-8')))
             # Skip the next line (the index separator) since we've already
    
pfee
#1 pfee

Markdown has adjust some of the above text, hopefully the content and patch are still readable. Shame splat has no button to disable markdown like ReviewBoard has.