@@ -0,0 +1,2891 @@
+#!/usr/bin/env python%0A%22%22%22This script creates or updates en-US repository from Mozilla source%0A   code to use for Mozilla product localization.%22%22%22%0A%0Aimport os%0Aimport shutil%0Aimport subprocess%0A%0A%0ACONFIG = %7B%0A    'sources': %5B'comm-aurora', 'mozilla-aurora'%5D,%0A    'target': 'mozilla-aurora',%0A    'folders': %5B%0A        'browser', 'browser/branding/official', 'dom', 'netwerk',%0A        'security/manager', 'services/sync', 'toolkit', 'webapprt',%0A        'mobile', 'mobile/android', 'mobile/android/base',%0A        'chat', 'editor/ui', 'mail', 'other-licenses/branding/thunderbird',%0A        'calendar',%0A        'suite',%0A    %5D,%0A%7D%0A%0A%0Adef execute(command, cwd=None):%0A%0A    try:%0A        st = subprocess.PIPE%0A        proc = subprocess.Popen(%0A            args=command, stdout=st, stderr=st, stdin=st, cwd=cwd)%0A%0A        (output, error) = proc.communicate()%0A        code = proc.returncode%0A        return code, output, error%0A%0A    except OSError as error:%0A        return -1, '', error%0A%0A%0Adef pull(url, target):%0A%0A    # Undo local changes%0A    execute(%5B'hg', 'revert', '--all', '--no-backup'%5D, target)%0A%0A    code, output, error = execute(%5B'hg', 'pull', '-u'%5D, target)%0A    if code == 0:%0A        print('Repository at ' + url + ' updated.')%0A%0A    else:%0A        print(unicode(error))%0A        print('Clone instead.')%0A%0A        code, output, error = execute(%5B'hg', 'clone', url, target%5D)%0A        if code == 0:%0A            print('Repository at ' + url + ' cloned.')%0A        else:%0A            print(unicode(error))%0A%0A%0Adef push(path):%0A%0A    # Add%0A    execute(%5B'hg', 'add'%5D, path)%0A%0A    # Commit%0A    code, output, error = execute(%5B'hg', 'commit', '-m', 'Update'%5D, path)%0A    if code != 0 and len(error):%0A        print(unicode(error))%0A%0A    # Push%0A    code, output, error = execute(%5B'hg', 'push'%5D, path)%0A    if code == 0:%0A        print('Repository at ' + path + ' pushed.')%0A    elif len(error):%0A        print(unicode(error))%0A%0A%0A# Change working directory to where script is located%0Aabspath = os.path.abspath(__file__)%0Adname = os.path.dirname(abspath)%0Aos.chdir(dname)%0A%0A%0A# Clone or update source repositories%0Afor repo in CONFIG%5B'sources'%5D:%0A    base = 'ssh://hg.mozilla.org/releases/'%0A    url = os.path.join(base, repo)%0A    target = os.path.join('source', repo)%0A    pull(url, target)%0A%0A# Clone or update target repository%0Arepo = CONFIG%5B'target'%5D%0Abase = 'ssh://hg.mozilla.org/users/m_owca.info/'%0Aurl = os.path.join(base, repo)%0Atarget = os.path.join('target', repo)%0Apull(url, target)%0A%0A# Copy folders from source to target%0Afor folder in CONFIG%5B'folders'%5D:%0A    for source in CONFIG%5B'sources'%5D:%0A        origin = os.path.join('source', source, folder, 'locales/en-US')%0A        destination = os.path.join('target', repo, folder)%0A%0A        if os.path.exists(origin):%0A            if os.path.exists(destination):%0A                shutil.rmtree(destination)%0A%0A            shutil.copytree(origin, destination)%0A%0A# Commit and push target repository%0Apush(target)%0A

Add script to create en-US repo from Mozilla code