Reland "Drop py2 support in gerrit and git related files"

This is a reland of commit b5c7f4b46c

Original change's description:
> Drop py2 support in gerrit and git related files
>
> python3 is the only supported version of python in depot_tools.
>
> Bug: 1475402
> Change-Id: Ie4ee18d297081b3aa0206b8d7ce6461819bff0ca
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809560
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> Commit-Queue: Gavin Mak <gavinmak@google.com>

Bug: 1475402
Change-Id: I194180494071777b7b9dd91a5c8edabbbf5484c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4811218
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
This commit is contained in:
Gavin Mak
2023-08-28 17:01:52 +00:00
committed by LUCI CQ
parent b8164180d2
commit cc97655889
32 changed files with 67 additions and 264 deletions

View File

@@ -20,10 +20,6 @@ import gclient_utils
DEFAULT_BRANCH = 'main'
if sys.version_info.major == 3:
# pylint: disable=redefined-builtin
basestring = (str,)
def git_hash_data(data, typ='blob'):
"""Calculate the git-style SHA1 for some data.
@@ -333,7 +329,7 @@ class GitRepo(object):
for fname, file_data in commit_data.items():
# If it isn't a string, it's one of the special keys.
if not isinstance(fname, basestring):
if not isinstance(fname, str):
continue
deleted = False
@@ -496,8 +492,6 @@ class GitRepoSchemaTestBase(unittest.TestCase):
@classmethod
def getRepoContent(cls, commit):
commit = 'COMMIT_%s' % commit
if sys.version_info.major == 2:
commit = commit.encode('utf-8')
return getattr(cls, commit, None)
@classmethod