Bug 1628506 - Port bug 1622972: Switch mach configure to Python 3. rs=bustage-fix
authorRob Lemley <rob@thunderbird.net>
Wed, 08 Apr 2020 18:29:48 -0400
changeset 38752 9fc6b7e2078d8ff3978dccf065ea34828b2bb840
parent 38751 ab3ec689c2afddce46d9bf042be7aa257ccd9b4e
child 38753 d1d0c7e3dc9da581b3b157681573a728da8e698f
push id401
push userclokep@gmail.com
push dateMon, 01 Jun 2020 20:41:59 +0000
reviewersbustage-fix
bugs1628506, 1622972
Bug 1628506 - Port bug 1622972: Switch mach configure to Python 3. rs=bustage-fix Replace the use of system_encoding with six.ensure_text.
build/moz.configure/gecko_source.configure
--- a/build/moz.configure/gecko_source.configure
+++ b/build/moz.configure/gecko_source.configure
@@ -39,86 +39,86 @@ def read_sourcestamp(repository):
 
     line2read = {'COMM': 1,
                  'GECKO': 2}[repository]
 
     @depends(comm_paths)
     @imports(_from='os.path', _import='exists')
     @imports(_from='os.path', _import='join')
     @imports(_from='__builtin__', _import='open')
-    @imports(_from='mozbuild.util', _import='system_encoding')
+    @imports(_from='six', _import='ensure_text')
     def get_sourcestamp(paths):
         sourcestamp_file = join(paths.moztopsrcdir, 'sourcestamp.txt')
         if exists(sourcestamp_file):
             try:
                 lines = open(sourcestamp_file).readlines()
             except:
                 pass
 
             if len(lines) != 3:
                 log.warn('sourcestamp.txt is corrupt!')
                 return
 
             if lines and lines[line2read].startswith('http'):
-                repo_line = lines[line2read].decode(system_encoding)
+                repo_line = ensure_text(lines[line2read])
                 repo_url = repo_line.split('/rev/')
                 return namespace(repo_url=repo_url[0], repo_rev=repo_url[1])
 
     return get_sourcestamp
 
 
 @template
 def read_gecko_rev_yml():
     def get_value(x):
         return x.split()[1]
 
     @depends(comm_paths)
     @imports(_from='os.path', _import='exists')
     @imports(_from='os.path', _import='join')
     @imports(_from='__builtin__', _import='open')
-    @imports(_from='mozbuild.util', _import='system_encoding')
+    @imports(_from='six', _import='ensure_text')
     def wrapped(paths):
         log.info("Determining GECKO source information from .gecko_rev.yml")
         rev_file = join(paths.commtopsrcdir, '.gecko_rev.yml')
         if not exists(rev_file): return
 
         repo = rev = ref = None
 
         for line in open(rev_file).readlines():
             if line.startswith('GECKO_HEAD_REPOSITORY:'):
-                repo = get_value(line).decode(system_encoding)
+                repo = ensure_text(get_value(line))
             elif line.startswith('GECKO_HEAD_REV:'):
-                rev = get_value(line).decode(system_encoding)
+                rev = ensure_text(get_value(line))
             elif line.startswith('GECKO_HEAD_REF:'):
-                ref = get_value(line).decode(system_encoding)
+                ref = ensure_text(get_value(line))
             else:
                 pass
 
         return namespace(repo=repo, rev=rev, ref=ref)
 
     return wrapped
 
 
 @depends(application)
 @imports(_from='os', _import="environ")
-@imports(_from='mozbuild.util', _import='system_encoding')
+@imports(_from='six', _import='ensure_text')
 def comm_repo_from_environ(app):
     """
     Read the Thunderbird source repository information from the environment.
 
     Taskcluster builds set MOZ_SOURCE_REPO and MOZ_SOURCE_CHANGESET pointing
     to the comm-* repository.
     """
     log.info("Determining COMM source information from environment...")
     comm_repo = environ.get('MOZ_SOURCE_REPO', None)
     comm_rev = environ.get('MOZ_SOURCE_CHANGESET', None)
 
     if all([comm_repo, comm_rev]):
-        comm_repo = comm_repo.decode(system_encoding)
-        comm_rev = comm_rev.decode(system_encoding)
+        comm_repo = ensure_text(comm_repo)
+        comm_rev = ensure_text(comm_rev)
 
         log.info("{}/rev/{}".format(comm_repo, comm_rev))
         return namespace(comm_repo=comm_repo, comm_rev=comm_rev)
 
 
 # Read sourcestamp.txt and return the Thunderbird source URL (with changeset).
 # Silent fail if the file cannot be read.
 comm_sourcestamp = read_sourcestamp('COMM')
@@ -188,27 +188,27 @@ def comm_source_repo(from_environ, from_
 
     log.info('COMM_SOURCE_REPOSITORY: {}'.format(rv.comm_repo))
     log.info('COMM_SOURCE_CHANGESET: {}'.format(rv.comm_rev))
     return rv
 
 
 @depends(application)
 @imports(_from='os', _import="environ")
-@imports(_from='mozbuild.util', _import='system_encoding')
+@imports(_from='six', _import='ensure_text')
 def gecko_repo_from_environ(app):
     """
     Same as above, but this time checking for the mozilla- repository.
     """
     log.info("Determining GECKO source information from environment...")
     gecko_repo = environ.get('GECKO_HEAD_REPOSITORY', None)
     gecko_rev = environ.get('GECKO_HEAD_REV', None)
     if all([gecko_repo, gecko_rev]):
-        gecko_repo = gecko_repo.decode(system_encoding)
-        gecko_rev = gecko_rev.decode(system_encoding)
+        gecko_repo = ensure_text(gecko_repo)
+        gecko_rev = ensure_text(gecko_rev)
 
         log.info("{}/rev/{}".format(gecko_repo, gecko_rev))
         return namespace(gecko_repo=gecko_repo, gecko_rev=gecko_rev)
 
 
 # Read sourcestamp.txt, this time returning the mozilla- data
 gecko_sourcestamp = read_sourcestamp('GECKO')
 # Look in comm/.gecko_rev.yml fpr repository information