Bug 780562 - Take locale chrome manifest flags into account when repacking l10n. r?gps draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 09 May 2017 14:23:55 +0900
changeset 575151 ed1183cc7f7c4bca170ed4faeb1216dc64e0bd98
parent 574519 b21b974d60d3075ae24f6fb1bae75d0f122f28fc
child 575152 5dcdd67b590573169ce329836437d77de6c8459a
push id57973
push userbmo:mh+mozilla@glandium.org
push dateWed, 10 May 2017 01:30:38 +0000
reviewersgps
bugs780562
milestone55.0a1
Bug 780562 - Take locale chrome manifest flags into account when repacking l10n. r?gps
python/mozbuild/mozpack/packager/l10n.py
--- a/python/mozbuild/mozpack/packager/l10n.py
+++ b/python/mozbuild/mozpack/packager/l10n.py
@@ -107,39 +107,49 @@ def _repack(app_finder, l10n_finder, cop
     l10n_locale = l10n.locales[0]
 
     # For each base directory, store what path a locale chrome package name
     # corresponds to.
     # e.g., for the following entry under app/chrome:
     #     locale foo en-US path/to/files
     # keep track that the locale path for foo in app is
     # app/chrome/path/to/files.
+    # As there may be multiple locale entries with the same base, but with
+    # different flags, that tracking takes the flags into account when there
+    # are some. Example:
+    #     locale foo en-US path/to/files/win os=Win
+    #     locale foo en-US path/to/files/mac os=Darwin
+    def key(entry):
+        if entry.flags:
+            return '%s %s' % (entry.name, entry.flags)
+        return entry.name
+
     l10n_paths = {}
     for e in l10n.entries:
         if isinstance(e, ManifestChrome):
             base = mozpath.basedir(e.path, app.bases)
             l10n_paths.setdefault(base, {})
-            l10n_paths[base][e.name] = e.path
+            l10n_paths[base][key(e)] = e.path
 
     # For chrome and non chrome files or directories, store what langpack path
     # corresponds to a package path.
     paths = {}
     for e in app.entries:
         if isinstance(e, ManifestEntryWithRelPath):
             base = mozpath.basedir(e.path, app.bases)
             if base not in l10n_paths:
                 errors.fatal("Locale doesn't contain %s/" % base)
                 # Allow errors to accumulate
                 continue
             if e.name not in l10n_paths[base]:
                 errors.fatal("Locale doesn't have a manifest entry for '%s'" %
                     e.name)
                 # Allow errors to accumulate
                 continue
-            paths[e.path] = l10n_paths[base][e.name]
+            paths[e.path] = l10n_paths[base][key(e)]
 
     for pattern in non_chrome:
         for base in app.bases:
             path = mozpath.join(base, pattern)
             left = set(p for p, f in app_finder.find(path))
             right = set(p for p, f in l10n_finder.find(path))
             for p in right:
                 paths[p] = p