Fix bug 1399166: Use X-channel repo as source (#714)

Update the script to create per-project en-US only repositories from
the cross-channel repository. It is already limited to localizable
files only, and it also includes files from the comm-* repositories.

We now also clean up target directory on a failed pull, so that it's
empty for a clone. We also prune all subdirectories in target
repository in case they get removed from source.
This commit is contained in:
Matjaž Horvat 2017-10-05 18:26:36 +02:00 коммит произвёл GitHub
Родитель f12ef80df4
Коммит 8a9b9fd465
1 изменённых файлов: 50 добавлений и 69 удалений

Просмотреть файл

@ -19,41 +19,32 @@ import shutil
import subprocess
TARGET_REPOS = {
'firefox': {
'folders': [
'browser', 'browser/branding/official',
'browser/extensions/onboarding',
'browser/extensions/pocket',
'browser/extensions/webcompat-reporter',
'devtools/client', 'devtools/shared', 'devtools/shim',
'dom', 'netwerk', 'security/manager',
'services/sync', 'toolkit', 'webapprt',
],
'source': 'mozilla',
},
'firefox-for-android': {
'folders': ['mobile', 'mobile/android', 'mobile/android/base'],
'source': 'mozilla',
},
'thunderbird': {
'folders': [
'chat', 'editor/ui', 'mail',
'other-licenses/branding/thunderbird'
],
'source': 'comm',
},
'lightning': {
'folders': ['calendar'],
'source': 'comm',
},
'seamonkey': {
'folders': ['suite'],
'source': 'comm',
},
'firefox': [
'browser',
'devtools',
'dom',
'netwerk',
'security',
'services',
'toolkit',
],
'firefox-for-android': [
'mobile',
],
'thunderbird': [
'chat',
'editor',
'mail',
'other-licenses',
],
'lightning': [
'calendar',
],
'seamonkey': [
'suite',
],
}
SOURCE_REPOS = set(v["source"] for v in TARGET_REPOS.values())
def write(text):
timestamp = datetime.datetime.now().strftime('[%Y-%m-%d %H:%M:%S] ')
@ -89,6 +80,10 @@ def pull(url, target):
write(text_type(error))
write('Clone instead.')
# Clean up target directory on a failed pull, so that it's empty for a clone
command = ["rm", "-rf", target]
code, output, error = execute(command)
code, output, error = execute(['hg', 'clone', url, target])
if code == 0:
write('Repository at ' + url + ' cloned.')
@ -117,45 +112,31 @@ abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
for channel in ['beta', 'central']:
for repo in SOURCE_REPOS:
ending = repo + '-' + channel
# Clone or update source repository
url = 'https://hg.mozilla.org/users/axel_mozilla.com/gecko-strings/'
target = 'source'
pull(url, target)
url_folder = ''
if channel == 'central':
if repo == 'mozilla':
url_folder = 'l10n/'
else:
url_folder = 'releases/'
for repo in TARGET_REPOS.keys():
ending = repo + '-central'
url = 'ssh://hg.mozilla.org/users/m_owca.info/' + ending
target = os.path.join('target', ending)
url = 'ssh://hg.mozilla.org/' + url_folder + ending
target = os.path.join('source', ending)
# Clone or update target repository
pull(url, target)
# Clone or update source repositories
pull(url, target)
# Prune all subdirectories in target repository in case they get removed from source
for subdir in os.listdir(target):
if not subdir.startswith('.'):
shutil.rmtree(os.path.join(target, subdir))
for repo in TARGET_REPOS.keys():
ending = repo + '-' + channel
url = 'ssh://hg.mozilla.org/users/m_owca.info/' + ending
target = os.path.join('target', ending)
# Copy folders from source to target
for folder in TARGET_REPOS[repo]:
origin = os.path.join('source', folder)
destination = os.path.join('target', ending, folder)
# Clone or update target repositories
pull(url, target)
if os.path.exists(origin):
shutil.copytree(origin, destination)
# Copy folders from source to target
folders = TARGET_REPOS[repo]['folders']
source = TARGET_REPOS[repo]['source'] + '-' + channel
for folder in folders:
origin = os.path.join('source', source, folder, 'locales/en-US')
destination = os.path.join('target', ending, folder)
if os.path.exists(destination):
shutil.rmtree(destination)
# Needed temporarily because devtools aren't moved in beta yet
if os.path.exists(origin):
shutil.copytree(origin, destination)
# Commit and push target repositories
push(target)
# Commit and push target repositories
push(target)