msubprojects: wrap-file should be re-extracted with --reset

When using --reset we should guarantee that next reconfigure will pick
the latest code. For wrap-file we have no way to know if the revision
changed, so we have to delete the source tree and extract again.

It is unlikely that user has local changes in non-git subprojects, and
--reset is known to be dangerous.
pull/8597/head
Xavier Claessens 4 years ago committed by Jussi Pakkanen
parent 23c706add1
commit 1ad469342b
  1. 3
      docs/markdown/Subprojects.md
  2. 8
      docs/markdown/snippets/subprojects_update.md
  3. 44
      mesonbuild/msubprojects.py

@ -310,7 +310,8 @@ To pull latest version of all your subprojects at once, just run the command:
- If the wrap file comes from wrapdb, the latest version of the wrap file will - If the wrap file comes from wrapdb, the latest version of the wrap file will
be pulled and used next time meson reconfigure the project. This can be be pulled and used next time meson reconfigure the project. This can be
triggered using `meson --reconfigure`. Previous source tree is not deleted, to triggered using `meson --reconfigure`. Previous source tree is not deleted, to
prevent from any loss of local changes. prevent from any loss of local changes. *Since 0.58.0* If `--reset` is
specified, the source tree is deleted and new source is extracted.
- If subproject is currently in detached mode, a checkout of the revision from - If subproject is currently in detached mode, a checkout of the revision from
wrap file is performed. *Since 0.56.0* a rebase is also performed in case the wrap file is performed. *Since 0.56.0* a rebase is also performed in case the
revision already existed locally but was outdated. If `--reset` is specified, revision already existed locally but was outdated. If `--reset` is specified,

@ -0,0 +1,8 @@
## `meson subprojects update --reset` now re-extract tarballs
When using `--reset` option, the source tree of `[wrap-file]` subprojects is now
deleted and re-extracted from cached tarballs, or re-downloaded. This is because
Meson has no way to know if the source tree or the wrap file has been modified,
and `--reset` should guarantee that latest code is being used on next reconfigure.
Use `--reset` with caution if you do local changes on non-git subprojects.

@ -9,40 +9,44 @@ from .wrap import wraptool
ALL_TYPES_STRING = ', '.join(ALL_TYPES) ALL_TYPES_STRING = ', '.join(ALL_TYPES)
def update_wrapdb_file(wrap, repo_dir, options): def update_wrapdb_file(wrap):
patch_url = wrap.get('patch_url') patch_url = wrap.get('patch_url')
branch, revision = wraptool.parse_patch_url(patch_url) branch, revision = wraptool.parse_patch_url(patch_url)
new_branch, new_revision = wraptool.get_latest_version(wrap.name) new_branch, new_revision = wraptool.get_latest_version(wrap.name)
if new_branch == branch and new_revision == revision: if new_branch != branch or new_revision != revision:
mlog.log(' -> Up to date.') wraptool.update_wrap_file(wrap.filename, wrap.name, new_branch, new_revision)
return True mlog.log(' -> New wrap file downloaded.')
wraptool.update_wrap_file(wrap.filename, wrap.name, new_branch, new_revision)
msg = [' -> New wrap file downloaded.']
# Meson reconfigure won't use the new wrap file as long as the source
# directory exists. We don't delete it ourself to avoid data loss in case
# user has changes in their copy.
if os.path.isdir(repo_dir):
msg += ['To use it, delete', mlog.bold(repo_dir), 'and run', mlog.bold('meson --reconfigure')]
mlog.log(*msg)
return True
def update_file(r, wrap, repo_dir, options): def update_file(r, wrap, repo_dir, options):
patch_url = wrap.values.get('patch_url', '') patch_url = wrap.values.get('patch_url', '')
if patch_url.startswith(API_ROOT): if patch_url.startswith(API_ROOT):
return update_wrapdb_file(wrap, repo_dir, options) update_wrapdb_file(wrap)
elif not os.path.isdir(repo_dir): if not os.path.isdir(repo_dir):
# The subproject is not needed, or it is a tarball extracted in # The subproject is not needed, or it is a tarball extracted in
# 'libfoo-1.0' directory and the version has been bumped and the new # 'libfoo-1.0' directory and the version has been bumped and the new
# directory is 'libfoo-2.0'. In that case forcing a meson # directory is 'libfoo-2.0'. In that case forcing a meson
# reconfigure will download and use the new tarball. # reconfigure will download and use the new tarball.
mlog.log(' -> Subproject has not been checked out. Run', mlog.bold('meson --reconfigure'), 'to fetch it if needed.') mlog.log(' -> Not used.')
return True
elif options.reset:
# Delete existing directory and redownload. It is possible that nothing
# changed but we have no way to know. Hopefully tarballs are still
# cached.
windows_proof_rmtree(repo_dir)
try:
r.resolve(wrap.name, 'meson')
mlog.log(' -> New version extracted')
return True
except WrapException as e:
mlog.log(' ->', mlog.red(str(e)))
return False
else: else:
# The subproject has not changed, or the new source and/or patch # The subproject has not changed, or the new source and/or patch
# tarballs should be extracted in the same directory than previous # tarballs should be extracted in the same directory than previous
# version. # version.
mlog.log(' -> Subproject has not changed, or the new source/patch needs to be extracted on the same location.\n' + mlog.log(' -> Subproject has not changed, or the new source/patch needs to be extracted on the same location.')
' In that case, delete', mlog.bold(repo_dir), 'and run', mlog.bold('meson --reconfigure')) mlog.log(' Pass --reset option to delete directory and redownload.')
return True return False
def git_output(cmd, workingdir): def git_output(cmd, workingdir):
return quiet_git(cmd, workingdir, check=True)[1] return quiet_git(cmd, workingdir, check=True)[1]
@ -260,6 +264,8 @@ def update(r, wrap, repo_dir, options):
return update_hg(r, wrap, repo_dir, options) return update_hg(r, wrap, repo_dir, options)
elif wrap.type == 'svn': elif wrap.type == 'svn':
return update_svn(r, wrap, repo_dir, options) return update_svn(r, wrap, repo_dir, options)
elif wrap.type is None:
mlog.log(' -> Cannot update subproject with no wrap file')
else: else:
mlog.log(' -> Cannot update', wrap.type, 'subproject') mlog.log(' -> Cannot update', wrap.type, 'subproject')
return True return True

Loading…
Cancel
Save