assume environment always accepts strings

Different Python & OS versions have different environ behavior wrt
accepted types & encoding.  Since we're migrating to be Python 3 only,
lets change our code to assume strings always work as that's what the
newer Python 3 does.  This will fail under Python 2 for some env vars,
mostly on Windows, but the effort of maintaining shim layers that can
handle these edge cases isn't worth it when we're dropping that code.

We leave the logic in the `repo` launcher for now as it is simple, and
we want it to be able to switch versions a bit longer than the rest of
the tree.

Here's the support table:
          |    *NIX      |         Windows           |
 Python 2 | ASCII string | str or bytes, not unicode |
 Python 3 | str or bytes | str only                  |

Windows uses strings natively in its environment all the time.  But it
doesn't allow unicode strings under Python 2, so we have to encode.

Python 2 on *NIX is funky in that it always lowers to ASCII, so we had
to manually encode to avoid errors regardless of unicode or str.

Python 3 on Windows & *NIX will accept strings.  *NIX will also accept
bytes but Windows will not.

Bug: https://crbug.com/gerrit/12145
Change-Id: I3cf8f95a06902754ea1f08ad4b28503f7063531b
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/248972
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
3 files changed
tree: ae5ef606503262f21ac53e336196bfb9975c98e2
  1. .github/
  2. docs/
  3. hooks/
  4. subcmds/
  5. tests/
  6. .flake8
  7. .gitattributes
  8. .gitignore
  9. .mailmap
  10. .project
  11. .pydevproject
  12. color.py
  13. command.py
  14. editor.py
  15. error.py
  16. event_log.py
  17. git_command.py
  18. git_config.py
  19. git_refs.py
  20. git_ssh
  21. gitc_utils.py
  22. LICENSE
  23. main.py
  24. MANIFEST.in
  25. manifest_xml.py
  26. pager.py
  27. platform_utils.py
  28. platform_utils_win32.py
  29. progress.py
  30. project.py
  31. pyversion.py
  32. README.md
  33. repo
  34. repo_trace.py
  35. run_tests
  36. setup.py
  37. SUBMITTING_PATCHES.md
  38. tox.ini
  39. wrapper.py
README.md

repo

Repo is a tool built on top of Git. Repo helps manage many Git repositories, does the uploads to revision control systems, and automates parts of the development workflow. Repo is not meant to replace Git, only to make it easier to work with Git. The repo command is an executable Python script that you can put anywhere in your path.

Install

Many distros include repo, so you might be able to install from there.

# Debian/Ubuntu.
$ sudo apt-get install repo

# Gentoo.
$ sudo emerge dev-vcs/repo

You can install it manually as well as it's a single script.

$ mkdir -p ~/.bin
$ PATH="${HOME}/.bin:${PATH}"
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
$ chmod a+rx ~/.bin/repo