This is an archive of the discontinued LLVM Phabricator instance.

llvm-git: More tweaks.
ClosedPublic

Authored by jyknight on Nov 21 2018, 12:02 PM.

Details

Reviewers
zturner
Summary

On python3, use bytes for reading and applying the patch file, rather
than str. This fixes encoding issues when applying patches with
python3.X (reported by zturner).

Also, simplify the "svn update" call, by using svn's "--parents" flag,
instead of manually computing and supplying the list of parent
directories.

Event Timeline

jyknight created this revision.Nov 21 2018, 12:02 PM
zturner added inline comments.Nov 21 2018, 12:08 PM
llvm/utils/git-svn/git-llvm
120–121

Don't we still need this line? When I wrote this patch, it was because after experimenting I found that subprocess.Popen would with universal_newlines=False unless stdin was a bytes.

132–134

Don't we need these lines too? Like before, I found that if universal_newlines=False on Python 3, then stdout and stderr would both be a bytes object, and subsequent lines of code where we do something like stdout.strip('\r\n') would fail because it would be trying to mix bytes and str.

BTW, I've tested this on Linux in both python2 and python3, but not on windows.

llvm/utils/git-svn/git-llvm
120–121

Yes, that's correct. "universal_newlines" in python3 really means "text". If it's enabled, the input/output are str, otherwise they're bytes. And for binary data, we _want_ (and now provide) bytes input, so this line is unneeded and undesirable. (in python3.7, they in fact fixed the confusing name, and added a "text" keyword arg as an alias of the "universal_newlines" one.).

132–134

We don't need them -- the purpose of this change is exactly to allow the use of bytes objects for binary I/O. Note the diff below to use rstrip(b'\r\n') instead of rstrip('\r\n') when !text.

zturner accepted this revision.Nov 21 2018, 12:52 PM
zturner added inline comments.
llvm/utils/git-svn/git-llvm
327–328

Should we retain the comment here about why we're passing text=False?

This revision is now accepted and ready to land.Nov 21 2018, 12:52 PM
jyknight closed this revision.Dec 3 2018, 2:38 PM

Forgot to close with the commit, r347766.