Skip to content

Commit 6bf747a

Browse files
authored
Merge pull request #512 from theotherjimmy/update-recursive
Add -l/--latest-deps option to update
2 parents 5cbf7ea + 7646f3c commit 6bf747a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mbed/mbed.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,12 +1943,13 @@ def publish(all_refs=None, msg=None, top=True):
19431943
dict(name=['-I', '--ignore'], action='store_true', help='Ignore errors related to unpublished libraries, unpublished or uncommitted changes, and attempt to update from associated remote repository URLs.'),
19441944
dict(name='--depth', nargs='?', help='Number of revisions to fetch from the remote repository. Default: all revisions.'),
19451945
dict(name='--protocol', nargs='?', help='Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.'),
1946+
dict(name=['-l', '--latest-deps'], action='store_true', help='Update all dependencies to the latest revision of their current branch. WARNING: Ignores lib files'),
19461947
help='Update to branch, tag, revision or latest',
19471948
description=(
19481949
"Updates the current program or library and its dependencies to specified\nbranch, tag or revision.\n"
19491950
"Alternatively fetches from associated remote repository URL and updates to the\n"
19501951
"latest revision in the current branch."))
1951-
def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=False, top=True, depth=None, protocol=None):
1952+
def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=False, top=True, depth=None, protocol=None, latest_deps=False):
19521953
if top and clean:
19531954
sync()
19541955

@@ -1964,6 +1965,11 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
19641965
"This %s is in detached HEAD state, and you won't be able to receive updates from the remote repository until you either checkout a branch or create a new one.\n"
19651966
"You can checkout a branch using \"%s checkout <branch_name>\" command before running \"mbed update\"." % (cwd_type, repo.scm.name), 1)
19661967

1968+
if repo.isdetached() and latest_deps:
1969+
warning(
1970+
"The repo %s is in detached HEAD state, and you won't be able to receive updates from the remote repository until you either checkout a branch or create a new one.\n"
1971+
"You can checkout a branch using \"%s checkout <branch_name>\" command before running \"mbed update\"." % (repo.name, repo.scm.name))
1972+
19671973
if repo.is_local and not repo.rev:
19681974
action("Skipping unpublished empty %s \"%s\"" % (
19691975
cwd_type if top else cwd_dest,
@@ -2037,7 +2043,7 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
20372043
repo.ignore(relpath(repo.path, lib.path))
20382044
else:
20392045
with cd(lib.path):
2040-
update(lib.rev, clean=clean, clean_files=clean_files, clean_deps=clean_deps, ignore=ignore, top=False)
2046+
update(None if latest_deps else lib.rev, clean=clean, clean_files=clean_files, clean_deps=clean_deps, ignore=ignore, top=False, latest_deps=latest_deps)
20412047

20422048
if top:
20432049
program = Program(repo.path)

0 commit comments

Comments
 (0)