Skip to content

Commit a3fcfd0

Browse files
committed
Update the tools in mbed 2.0/Classic programs during mbed update (#331)
1 parent 57ad6a0 commit a3fcfd0

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

mbed/mbed.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def discard():
409409
popen([hg_cmd, 'update', '-C'] + (['-v'] if very_verbose else ([] if verbose else ['-q'])))
410410

411411
def checkout(rev, clean=False, clean_files=False):
412-
info("Checkout \"%s\" in %s to %s" % (rev, os.path.basename(os.getcwd()), rev))
412+
info("Checkout \"%s\" in %s" % (rev if rev else "latest", os.path.basename(os.getcwd())))
413413
if clean_files:
414414
files = pquery([hg_cmd, 'status', '--no-status', '-ui']).splitlines()
415415
for f in files:
@@ -598,7 +598,7 @@ def merge(dest):
598598
def checkout(rev, clean=False):
599599
if not rev:
600600
return
601-
info("Checkout \"%s\" in %s to %s" % (rev, os.path.basename(os.getcwd()), rev))
601+
info("Checkout \"%s\" in %s" % (rev, os.path.basename(os.getcwd())))
602602
popen([git_cmd, 'checkout', rev] + (['-f'] if clean else []) + ([] if very_verbose else ['-q']))
603603
if Git.isdetached(): # try to find associated refs to avoid detached state
604604
refs = Git.getrefs(rev)
@@ -1286,6 +1286,22 @@ def add_tools(self, path):
12861286
rmtree_readonly(tools_dir)
12871287
error("An error occurred while cloning the mbed SDK tools from \"%s\"" % mbed_sdk_tools_url)
12881288

1289+
def update_tools(self, path):
1290+
if not os.path.exists(path):
1291+
os.mkdir(path)
1292+
with cd(path):
1293+
tools_dir = 'tools'
1294+
if not os.path.exists(tools_dir):
1295+
return self.add_tools(path)
1296+
else:
1297+
with cd(tools_dir):
1298+
try:
1299+
action("Updating the mbed 2.0 SDK tools...")
1300+
repo = Repo.fromrepo()
1301+
repo.update()
1302+
except Exception:
1303+
error("An error occurred while update the mbed SDK tools from \"%s\"" % mbed_sdk_tools_url)
1304+
12891305
def get_tools(self):
12901306
mbed_tools_path = self.get_tools_dir()
12911307
if not mbed_tools_path:
@@ -1707,8 +1723,10 @@ def deploy(ignore=False, depth=None, protocol=None, top=True):
17071723
repo.ignore(relpath(repo.path, lib.path))
17081724

17091725
if top:
1710-
Program(repo.path).post_action()
1711-
1726+
program = Program(repo.path)
1727+
program.post_action()
1728+
if program.is_classic:
1729+
program.update_tools('.temp')
17121730

17131731
# Publish command
17141732
@subcommand('publish',
@@ -1869,6 +1887,8 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
18691887
program = Program(repo.path)
18701888
program.set_root()
18711889
program.post_action()
1890+
if program.is_classic:
1891+
program.update_tools('.temp')
18721892

18731893

18741894
# Synch command

0 commit comments

Comments
 (0)