Clone of official tools

Committer:
theotherjimmy
Date:
Tue Sep 25 13:43:09 2018 -0500
Revision:
43:2a7da56ebd24
Release 5.10.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
theotherjimmy 43:2a7da56ebd24 1 """
theotherjimmy 43:2a7da56ebd24 2 mbed SDK
theotherjimmy 43:2a7da56ebd24 3 Copyright (c) 2011-2013 ARM Limited
theotherjimmy 43:2a7da56ebd24 4
theotherjimmy 43:2a7da56ebd24 5 Licensed under the Apache License, Version 2.0 (the "License");
theotherjimmy 43:2a7da56ebd24 6 you may not use this file except in compliance with the License.
theotherjimmy 43:2a7da56ebd24 7 You may obtain a copy of the License at
theotherjimmy 43:2a7da56ebd24 8
theotherjimmy 43:2a7da56ebd24 9 http://www.apache.org/licenses/LICENSE-2.0
theotherjimmy 43:2a7da56ebd24 10
theotherjimmy 43:2a7da56ebd24 11 Unless required by applicable law or agreed to in writing, software
theotherjimmy 43:2a7da56ebd24 12 distributed under the License is distributed on an "AS IS" BASIS,
theotherjimmy 43:2a7da56ebd24 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
theotherjimmy 43:2a7da56ebd24 14 See the License for the specific language governing permissions and
theotherjimmy 43:2a7da56ebd24 15 limitations under the License.
theotherjimmy 43:2a7da56ebd24 16
theotherjimmy 43:2a7da56ebd24 17
theotherjimmy 43:2a7da56ebd24 18 One repository to update them all
theotherjimmy 43:2a7da56ebd24 19 On mbed.org the mbed SDK is split up in multiple repositories, this script takes
theotherjimmy 43:2a7da56ebd24 20 care of updating them all.
theotherjimmy 43:2a7da56ebd24 21 """
theotherjimmy 43:2a7da56ebd24 22 import sys
theotherjimmy 43:2a7da56ebd24 23 from copy import copy
theotherjimmy 43:2a7da56ebd24 24 from os import walk, remove, makedirs, getcwd, rmdir, listdir
theotherjimmy 43:2a7da56ebd24 25 from os.path import join, abspath, dirname, relpath, exists, isfile, normpath, isdir
theotherjimmy 43:2a7da56ebd24 26 from shutil import copyfile
theotherjimmy 43:2a7da56ebd24 27 from optparse import OptionParser
theotherjimmy 43:2a7da56ebd24 28 import re
theotherjimmy 43:2a7da56ebd24 29 import string
theotherjimmy 43:2a7da56ebd24 30
theotherjimmy 43:2a7da56ebd24 31 ROOT = abspath(join(dirname(__file__), ".."))
theotherjimmy 43:2a7da56ebd24 32 sys.path.insert(0, ROOT)
theotherjimmy 43:2a7da56ebd24 33
theotherjimmy 43:2a7da56ebd24 34 from tools.settings import MBED_ORG_PATH, MBED_ORG_USER, BUILD_DIR
theotherjimmy 43:2a7da56ebd24 35 from tools.paths import *
theotherjimmy 43:2a7da56ebd24 36 from tools.utils import run_cmd
theotherjimmy 43:2a7da56ebd24 37
theotherjimmy 43:2a7da56ebd24 38 MBED_URL = "mbed.org"
theotherjimmy 43:2a7da56ebd24 39 MBED_USER = "mbed_official"
theotherjimmy 43:2a7da56ebd24 40
theotherjimmy 43:2a7da56ebd24 41 changed = []
theotherjimmy 43:2a7da56ebd24 42 push_remote = True
theotherjimmy 43:2a7da56ebd24 43 quiet = False
theotherjimmy 43:2a7da56ebd24 44 commit_msg = ''
theotherjimmy 43:2a7da56ebd24 45
theotherjimmy 43:2a7da56ebd24 46 # Code that does have a mirror in the mbed SDK
theotherjimmy 43:2a7da56ebd24 47 # Tuple data: (repo_name, list_of_code_dirs, [team])
theotherjimmy 43:2a7da56ebd24 48 # team is optional - if not specified, the code is published under mbed_official
theotherjimmy 43:2a7da56ebd24 49 OFFICIAL_CODE = {"mbed-dev" : ["cmsis", "drivers", "hal", "platform", "targets", "mbed.h"]}
theotherjimmy 43:2a7da56ebd24 50
theotherjimmy 43:2a7da56ebd24 51
theotherjimmy 43:2a7da56ebd24 52 # A list of regular expressions that will be checked against each directory
theotherjimmy 43:2a7da56ebd24 53 # name and skipped if they match.
theotherjimmy 43:2a7da56ebd24 54 IGNORE_DIRS = (
theotherjimmy 43:2a7da56ebd24 55 )
theotherjimmy 43:2a7da56ebd24 56
theotherjimmy 43:2a7da56ebd24 57 IGNORE_FILES = (
theotherjimmy 43:2a7da56ebd24 58 'COPYING',
theotherjimmy 43:2a7da56ebd24 59 '\.md',
theotherjimmy 43:2a7da56ebd24 60 "\.lib",
theotherjimmy 43:2a7da56ebd24 61 "\.bld"
theotherjimmy 43:2a7da56ebd24 62 )
theotherjimmy 43:2a7da56ebd24 63
theotherjimmy 43:2a7da56ebd24 64 def ignore_path(name, reg_exps):
theotherjimmy 43:2a7da56ebd24 65 for r in reg_exps:
theotherjimmy 43:2a7da56ebd24 66 if re.search(r, name):
theotherjimmy 43:2a7da56ebd24 67 return True
theotherjimmy 43:2a7da56ebd24 68 return False
theotherjimmy 43:2a7da56ebd24 69
theotherjimmy 43:2a7da56ebd24 70 class MbedRepository:
theotherjimmy 43:2a7da56ebd24 71 @staticmethod
theotherjimmy 43:2a7da56ebd24 72 def run_and_print(command, cwd):
theotherjimmy 43:2a7da56ebd24 73 stdout, _, _ = run_cmd(command, work_dir=cwd, redirect=True)
theotherjimmy 43:2a7da56ebd24 74 print(stdout)
theotherjimmy 43:2a7da56ebd24 75
theotherjimmy 43:2a7da56ebd24 76 def __init__(self, name):
theotherjimmy 43:2a7da56ebd24 77 self.name = name
theotherjimmy 43:2a7da56ebd24 78 self.path = join(MBED_ORG_PATH, name)
theotherjimmy 43:2a7da56ebd24 79 self.url = "http://" + MBED_URL + "/users/" + MBED_ORG_USER + "/code/%s/"
theotherjimmy 43:2a7da56ebd24 80
theotherjimmy 43:2a7da56ebd24 81 if not exists(self.path):
theotherjimmy 43:2a7da56ebd24 82 # Checkout code
theotherjimmy 43:2a7da56ebd24 83 if not exists(MBED_ORG_PATH):
theotherjimmy 43:2a7da56ebd24 84 makedirs(MBED_ORG_PATH)
theotherjimmy 43:2a7da56ebd24 85
theotherjimmy 43:2a7da56ebd24 86 self.run_and_print(['hg', 'clone', self.url % name], cwd=MBED_ORG_PATH)
theotherjimmy 43:2a7da56ebd24 87
theotherjimmy 43:2a7da56ebd24 88 else:
theotherjimmy 43:2a7da56ebd24 89 # Update
theotherjimmy 43:2a7da56ebd24 90 self.run_and_print(['hg', 'pull'], cwd=self.path)
theotherjimmy 43:2a7da56ebd24 91 self.run_and_print(['hg', 'update'], cwd=self.path)
theotherjimmy 43:2a7da56ebd24 92
theotherjimmy 43:2a7da56ebd24 93 def publish(self):
theotherjimmy 43:2a7da56ebd24 94 # The maintainer has to evaluate the changes first and explicitly accept them
theotherjimmy 43:2a7da56ebd24 95 self.run_and_print(['hg', 'addremove'], cwd=self.path)
theotherjimmy 43:2a7da56ebd24 96 stdout, _, _ = run_cmd(['hg', 'status'], work_dir=self.path)
theotherjimmy 43:2a7da56ebd24 97 if stdout == '':
theotherjimmy 43:2a7da56ebd24 98 print "No changes"
theotherjimmy 43:2a7da56ebd24 99 return False
theotherjimmy 43:2a7da56ebd24 100 print stdout
theotherjimmy 43:2a7da56ebd24 101 if quiet:
theotherjimmy 43:2a7da56ebd24 102 commit = 'Y'
theotherjimmy 43:2a7da56ebd24 103 else:
theotherjimmy 43:2a7da56ebd24 104 commit = raw_input(push_remote and "Do you want to commit and push? Y/N: " or "Do you want to commit? Y/N: ")
theotherjimmy 43:2a7da56ebd24 105 if commit == 'Y':
theotherjimmy 43:2a7da56ebd24 106 args = ['hg', 'commit', '-u', MBED_ORG_USER]
theotherjimmy 43:2a7da56ebd24 107
theotherjimmy 43:2a7da56ebd24 108
theotherjimmy 43:2a7da56ebd24 109 # NOTE commit_msg should always come from the relevant mbed 2 release text
theotherjimmy 43:2a7da56ebd24 110 if commit_msg:
theotherjimmy 43:2a7da56ebd24 111 args = args + ['-m', commit_msg]
theotherjimmy 43:2a7da56ebd24 112 self.run_and_print(args, cwd=self.path)
theotherjimmy 43:2a7da56ebd24 113 if push_remote:
theotherjimmy 43:2a7da56ebd24 114 self.run_and_print(['hg', 'push'], cwd=self.path)
theotherjimmy 43:2a7da56ebd24 115 return True
theotherjimmy 43:2a7da56ebd24 116
theotherjimmy 43:2a7da56ebd24 117 # Check if a file is a text file or a binary file
theotherjimmy 43:2a7da56ebd24 118 # Taken from http://code.activestate.com/recipes/173220/
theotherjimmy 43:2a7da56ebd24 119 text_characters = "".join(map(chr, range(32, 127)) + list("\n\r\t\b"))
theotherjimmy 43:2a7da56ebd24 120 _null_trans = string.maketrans("", "")
theotherjimmy 43:2a7da56ebd24 121 def is_text_file(filename):
theotherjimmy 43:2a7da56ebd24 122 block_size = 1024
theotherjimmy 43:2a7da56ebd24 123 def istext(s):
theotherjimmy 43:2a7da56ebd24 124 if "\0" in s:
theotherjimmy 43:2a7da56ebd24 125 return 0
theotherjimmy 43:2a7da56ebd24 126
theotherjimmy 43:2a7da56ebd24 127 if not s: # Empty files are considered text
theotherjimmy 43:2a7da56ebd24 128 return 1
theotherjimmy 43:2a7da56ebd24 129
theotherjimmy 43:2a7da56ebd24 130 # Get the non-text characters (maps a character to itself then
theotherjimmy 43:2a7da56ebd24 131 # use the 'remove' option to get rid of the text characters.)
theotherjimmy 43:2a7da56ebd24 132 t = s.translate(_null_trans, text_characters)
theotherjimmy 43:2a7da56ebd24 133
theotherjimmy 43:2a7da56ebd24 134 # If more than 30% non-text characters, then
theotherjimmy 43:2a7da56ebd24 135 # this is considered a binary file
theotherjimmy 43:2a7da56ebd24 136 if float(len(t))/len(s) > 0.30:
theotherjimmy 43:2a7da56ebd24 137 return 0
theotherjimmy 43:2a7da56ebd24 138 return 1
theotherjimmy 43:2a7da56ebd24 139 with open(filename) as f:
theotherjimmy 43:2a7da56ebd24 140 res = istext(f.read(block_size))
theotherjimmy 43:2a7da56ebd24 141 return res
theotherjimmy 43:2a7da56ebd24 142
theotherjimmy 43:2a7da56ebd24 143 # Return the line ending type for the given file ('cr' or 'crlf')
theotherjimmy 43:2a7da56ebd24 144 def get_line_endings(f):
theotherjimmy 43:2a7da56ebd24 145 examine_size = 1024
theotherjimmy 43:2a7da56ebd24 146 try:
theotherjimmy 43:2a7da56ebd24 147 tf = open(f, "rb")
theotherjimmy 43:2a7da56ebd24 148 lines, ncrlf = tf.readlines(examine_size), 0
theotherjimmy 43:2a7da56ebd24 149 tf.close()
theotherjimmy 43:2a7da56ebd24 150 for l in lines:
theotherjimmy 43:2a7da56ebd24 151 if l.endswith("\r\n"):
theotherjimmy 43:2a7da56ebd24 152 ncrlf = ncrlf + 1
theotherjimmy 43:2a7da56ebd24 153 return 'crlf' if ncrlf > len(lines) >> 1 else 'cr'
theotherjimmy 43:2a7da56ebd24 154 except:
theotherjimmy 43:2a7da56ebd24 155 return 'cr'
theotherjimmy 43:2a7da56ebd24 156
theotherjimmy 43:2a7da56ebd24 157 # Copy file to destination, but preserve destination line endings if possible
theotherjimmy 43:2a7da56ebd24 158 # This prevents very annoying issues with huge diffs that appear because of
theotherjimmy 43:2a7da56ebd24 159 # differences in line endings
theotherjimmy 43:2a7da56ebd24 160 def copy_with_line_endings(sdk_file, repo_file):
theotherjimmy 43:2a7da56ebd24 161 if not isfile(repo_file):
theotherjimmy 43:2a7da56ebd24 162 copyfile(sdk_file, repo_file)
theotherjimmy 43:2a7da56ebd24 163 return
theotherjimmy 43:2a7da56ebd24 164 is_text = is_text_file(repo_file)
theotherjimmy 43:2a7da56ebd24 165 if is_text:
theotherjimmy 43:2a7da56ebd24 166 sdk_le = get_line_endings(sdk_file)
theotherjimmy 43:2a7da56ebd24 167 repo_le = get_line_endings(repo_file)
theotherjimmy 43:2a7da56ebd24 168 if not is_text or sdk_le == repo_le:
theotherjimmy 43:2a7da56ebd24 169 copyfile(sdk_file, repo_file)
theotherjimmy 43:2a7da56ebd24 170 else:
theotherjimmy 43:2a7da56ebd24 171 print "Converting line endings in '%s' to '%s'" % (abspath(repo_file), repo_le)
theotherjimmy 43:2a7da56ebd24 172 f = open(sdk_file, "rb")
theotherjimmy 43:2a7da56ebd24 173 data = f.read()
theotherjimmy 43:2a7da56ebd24 174 f.close()
theotherjimmy 43:2a7da56ebd24 175 f = open(repo_file, "wb")
theotherjimmy 43:2a7da56ebd24 176 data = data.replace("\r\n", "\n") if repo_le == 'cr' else data.replace('\n','\r\n')
theotherjimmy 43:2a7da56ebd24 177 f.write(data)
theotherjimmy 43:2a7da56ebd24 178 f.close()
theotherjimmy 43:2a7da56ebd24 179
theotherjimmy 43:2a7da56ebd24 180 def visit_files(path, visit):
theotherjimmy 43:2a7da56ebd24 181 for root, dirs, files in walk(path):
theotherjimmy 43:2a7da56ebd24 182 # Ignore hidden directories
theotherjimmy 43:2a7da56ebd24 183 for d in copy(dirs):
theotherjimmy 43:2a7da56ebd24 184 full = join(root, d)
theotherjimmy 43:2a7da56ebd24 185 if d.startswith('.'):
theotherjimmy 43:2a7da56ebd24 186 dirs.remove(d)
theotherjimmy 43:2a7da56ebd24 187 if ignore_path(full, IGNORE_DIRS):
theotherjimmy 43:2a7da56ebd24 188 print "Skipping '%s'" % full
theotherjimmy 43:2a7da56ebd24 189 dirs.remove(d)
theotherjimmy 43:2a7da56ebd24 190
theotherjimmy 43:2a7da56ebd24 191 for file in files:
theotherjimmy 43:2a7da56ebd24 192 if ignore_path(file, IGNORE_FILES):
theotherjimmy 43:2a7da56ebd24 193 continue
theotherjimmy 43:2a7da56ebd24 194
theotherjimmy 43:2a7da56ebd24 195 visit(join(root, file))
theotherjimmy 43:2a7da56ebd24 196
theotherjimmy 43:2a7da56ebd24 197 def visit_dirs(path, visit):
theotherjimmy 43:2a7da56ebd24 198
theotherjimmy 43:2a7da56ebd24 199 for root, dirs, files in walk(path, topdown=False):
theotherjimmy 43:2a7da56ebd24 200 for d in dirs:
theotherjimmy 43:2a7da56ebd24 201 full = join(root, d)
theotherjimmy 43:2a7da56ebd24 202
theotherjimmy 43:2a7da56ebd24 203 # We don't want to remove the .hg directory
theotherjimmy 43:2a7da56ebd24 204 if not '.hg' in full:
theotherjimmy 43:2a7da56ebd24 205 visit(full)
theotherjimmy 43:2a7da56ebd24 206
theotherjimmy 43:2a7da56ebd24 207
theotherjimmy 43:2a7da56ebd24 208 def update_repo(repo_name, sdk_paths, lib=False):
theotherjimmy 43:2a7da56ebd24 209 repo = MbedRepository(repo_name)
theotherjimmy 43:2a7da56ebd24 210
theotherjimmy 43:2a7da56ebd24 211 # copy files from mbed SDK to mbed_official repository
theotherjimmy 43:2a7da56ebd24 212 def visit_mbed_sdk(sdk_file):
theotherjimmy 43:2a7da56ebd24 213
theotherjimmy 43:2a7da56ebd24 214 # Source files structure is different for the compiled binary lib
theotherjimmy 43:2a7da56ebd24 215 # compared to the mbed-dev sources
theotherjimmy 43:2a7da56ebd24 216 if lib:
theotherjimmy 43:2a7da56ebd24 217 repo_file = join(repo.path, relpath(sdk_file, sdk_path))
theotherjimmy 43:2a7da56ebd24 218 else:
theotherjimmy 43:2a7da56ebd24 219 repo_file = join(repo.path, sdk_file)
theotherjimmy 43:2a7da56ebd24 220 repo_dir = dirname(repo_file)
theotherjimmy 43:2a7da56ebd24 221 if not exists(repo_dir):
theotherjimmy 43:2a7da56ebd24 222 print("CREATING: %s" % repo_dir)
theotherjimmy 43:2a7da56ebd24 223 makedirs(repo_dir)
theotherjimmy 43:2a7da56ebd24 224
theotherjimmy 43:2a7da56ebd24 225 copy_with_line_endings(sdk_file, repo_file)
theotherjimmy 43:2a7da56ebd24 226
theotherjimmy 43:2a7da56ebd24 227 # Go through each path specified in the mbed structure
theotherjimmy 43:2a7da56ebd24 228 for sdk_path in sdk_paths:
theotherjimmy 43:2a7da56ebd24 229
theotherjimmy 43:2a7da56ebd24 230 if isfile(sdk_path):
theotherjimmy 43:2a7da56ebd24 231 # Single file so just copy directly across
theotherjimmy 43:2a7da56ebd24 232 visit_mbed_sdk(sdk_path)
theotherjimmy 43:2a7da56ebd24 233 else:
theotherjimmy 43:2a7da56ebd24 234 visit_files(sdk_path, visit_mbed_sdk)
theotherjimmy 43:2a7da56ebd24 235
theotherjimmy 43:2a7da56ebd24 236 def sdk_remove(repo_path):
theotherjimmy 43:2a7da56ebd24 237
theotherjimmy 43:2a7da56ebd24 238 print("REMOVING: %s" % repo_path)
theotherjimmy 43:2a7da56ebd24 239
theotherjimmy 43:2a7da56ebd24 240 # Check if this is an empty directory or a file before determining how to
theotherjimmy 43:2a7da56ebd24 241 # delete it. As this function should only be called with a directory list
theotherjimmy 43:2a7da56ebd24 242 # after being called with a file list, the directory should automatically
theotherjimmy 43:2a7da56ebd24 243 # be either valid or empty .
theotherjimmy 43:2a7da56ebd24 244 if isfile(repo_path):
theotherjimmy 43:2a7da56ebd24 245 remove(repo_path)
theotherjimmy 43:2a7da56ebd24 246 elif isdir(repo_path) and not listdir(repo_path):
theotherjimmy 43:2a7da56ebd24 247 rmdir(repo_path)
theotherjimmy 43:2a7da56ebd24 248 else:
theotherjimmy 43:2a7da56ebd24 249 print("ERROR: %s is not empty, please remove manually." % repo_path)
theotherjimmy 43:2a7da56ebd24 250 print listdir(repo_path)
theotherjimmy 43:2a7da56ebd24 251 exit(1)
theotherjimmy 43:2a7da56ebd24 252
theotherjimmy 43:2a7da56ebd24 253 # remove repository files that do not exist in the mbed SDK
theotherjimmy 43:2a7da56ebd24 254 def visit_lib_repo(repo_path):
theotherjimmy 43:2a7da56ebd24 255 for sdk_path in sdk_paths:
theotherjimmy 43:2a7da56ebd24 256 sdk_file = join(sdk_path, relpath(repo_path, repo.path))
theotherjimmy 43:2a7da56ebd24 257 if not exists(sdk_file):
theotherjimmy 43:2a7da56ebd24 258 sdk_remove(repo_path)
theotherjimmy 43:2a7da56ebd24 259
theotherjimmy 43:2a7da56ebd24 260 # remove repository files that do not exist in the mbed SDK source
theotherjimmy 43:2a7da56ebd24 261 def visit_repo(repo_path):
theotherjimmy 43:2a7da56ebd24 262
theotherjimmy 43:2a7da56ebd24 263 # work out equivalent sdk path from repo file
theotherjimmy 43:2a7da56ebd24 264 sdk_path = join(getcwd(), relpath(repo_path, repo.path))
theotherjimmy 43:2a7da56ebd24 265
theotherjimmy 43:2a7da56ebd24 266 if not exists(sdk_path):
theotherjimmy 43:2a7da56ebd24 267 sdk_remove(repo_path)
theotherjimmy 43:2a7da56ebd24 268
theotherjimmy 43:2a7da56ebd24 269 # Go through each path specified in the mbed structure
theotherjimmy 43:2a7da56ebd24 270 # Check if there are any files in any of those paths that are no longer part of the SDK
theotherjimmy 43:2a7da56ebd24 271
theotherjimmy 43:2a7da56ebd24 272 if lib:
theotherjimmy 43:2a7da56ebd24 273 visit_files(repo.path, visit_lib_repo)
theotherjimmy 43:2a7da56ebd24 274 # Now do the same for directories that may need to be removed. This needs to be done
theotherjimmy 43:2a7da56ebd24 275 # bottom up to ensure any lower nested directories can be deleted first
theotherjimmy 43:2a7da56ebd24 276 visit_dirs(repo.path, visit_lib_repo)
theotherjimmy 43:2a7da56ebd24 277
theotherjimmy 43:2a7da56ebd24 278 else:
theotherjimmy 43:2a7da56ebd24 279 visit_files(repo.path, visit_repo)
theotherjimmy 43:2a7da56ebd24 280
theotherjimmy 43:2a7da56ebd24 281 # Now do the same for directories that may need to be removed. This needs to be done
theotherjimmy 43:2a7da56ebd24 282 # bottom up to ensure any lower nested directories can be deleted first
theotherjimmy 43:2a7da56ebd24 283 visit_dirs(repo.path, visit_repo)
theotherjimmy 43:2a7da56ebd24 284
theotherjimmy 43:2a7da56ebd24 285 if repo.publish():
theotherjimmy 43:2a7da56ebd24 286 changed.append(repo_name)
theotherjimmy 43:2a7da56ebd24 287
theotherjimmy 43:2a7da56ebd24 288
theotherjimmy 43:2a7da56ebd24 289 def update_code(repositories):
theotherjimmy 43:2a7da56ebd24 290 for repo_name in repositories.keys():
theotherjimmy 43:2a7da56ebd24 291 sdk_dirs = repositories[repo_name]
theotherjimmy 43:2a7da56ebd24 292 print '\n=== Updating "%s" ===' % repo_name
theotherjimmy 43:2a7da56ebd24 293 update_repo(repo_name, sdk_dirs)
theotherjimmy 43:2a7da56ebd24 294
theotherjimmy 43:2a7da56ebd24 295
theotherjimmy 43:2a7da56ebd24 296 def update_mbed():
theotherjimmy 43:2a7da56ebd24 297 update_repo("mbed", [join(BUILD_DIR, "mbed")], lib=True)
theotherjimmy 43:2a7da56ebd24 298
theotherjimmy 43:2a7da56ebd24 299 def do_sync(options):
theotherjimmy 43:2a7da56ebd24 300 global push_remote, quiet, commit_msg, changed
theotherjimmy 43:2a7da56ebd24 301
theotherjimmy 43:2a7da56ebd24 302 push_remote = not options.nopush
theotherjimmy 43:2a7da56ebd24 303 quiet = options.quiet
theotherjimmy 43:2a7da56ebd24 304 commit_msg = options.msg
theotherjimmy 43:2a7da56ebd24 305 changed = []
theotherjimmy 43:2a7da56ebd24 306
theotherjimmy 43:2a7da56ebd24 307 if options.code:
theotherjimmy 43:2a7da56ebd24 308 update_code(OFFICIAL_CODE)
theotherjimmy 43:2a7da56ebd24 309
theotherjimmy 43:2a7da56ebd24 310 if options.mbed:
theotherjimmy 43:2a7da56ebd24 311 update_mbed()
theotherjimmy 43:2a7da56ebd24 312
theotherjimmy 43:2a7da56ebd24 313 if changed:
theotherjimmy 43:2a7da56ebd24 314 print "Repositories with changes:", changed
theotherjimmy 43:2a7da56ebd24 315
theotherjimmy 43:2a7da56ebd24 316 return changed
theotherjimmy 43:2a7da56ebd24 317
theotherjimmy 43:2a7da56ebd24 318 if __name__ == '__main__':
theotherjimmy 43:2a7da56ebd24 319 parser = OptionParser()
theotherjimmy 43:2a7da56ebd24 320
theotherjimmy 43:2a7da56ebd24 321 parser.add_option("-c", "--code",
theotherjimmy 43:2a7da56ebd24 322 action="store_true", default=False,
theotherjimmy 43:2a7da56ebd24 323 help="Update the mbed_official code")
theotherjimmy 43:2a7da56ebd24 324
theotherjimmy 43:2a7da56ebd24 325 parser.add_option("-m", "--mbed",
theotherjimmy 43:2a7da56ebd24 326 action="store_true", default=False,
theotherjimmy 43:2a7da56ebd24 327 help="Release a build of the mbed library")
theotherjimmy 43:2a7da56ebd24 328
theotherjimmy 43:2a7da56ebd24 329 parser.add_option("-n", "--nopush",
theotherjimmy 43:2a7da56ebd24 330 action="store_true", default=False,
theotherjimmy 43:2a7da56ebd24 331 help="Commit the changes locally only, don't push them")
theotherjimmy 43:2a7da56ebd24 332
theotherjimmy 43:2a7da56ebd24 333 parser.add_option("", "--commit_message",
theotherjimmy 43:2a7da56ebd24 334 action="store", type="string", default='', dest='msg',
theotherjimmy 43:2a7da56ebd24 335 help="Commit message to use for all the commits")
theotherjimmy 43:2a7da56ebd24 336
theotherjimmy 43:2a7da56ebd24 337 parser.add_option("-q", "--quiet",
theotherjimmy 43:2a7da56ebd24 338 action="store_true", default=False,
theotherjimmy 43:2a7da56ebd24 339 help="Don't ask for confirmation before commiting or pushing")
theotherjimmy 43:2a7da56ebd24 340
theotherjimmy 43:2a7da56ebd24 341 (options, args) = parser.parse_args()
theotherjimmy 43:2a7da56ebd24 342
theotherjimmy 43:2a7da56ebd24 343 do_sync(options)
theotherjimmy 43:2a7da56ebd24 344