diff --git a/kas/config.py b/kas/config.py index b3eb311..ede8544 100644 --- a/kas/config.py +++ b/kas/config.py @@ -58,7 +58,11 @@ class Config: 'belong to the same repository or all ' 'must be outside of versioning control') - self.handler = IncludeHandler(self.filenames, self.top_repo_path) + update = ctx.args.update if hasattr(ctx.args, 'update') else False + + self.handler = IncludeHandler(self.filenames, + self.top_repo_path, + not update) self.repo_dict = self._get_repo_dict() def get_build_system(self): diff --git a/kas/includehandler.py b/kas/includehandler.py index 0a85fb4..c42b227 100644 --- a/kas/includehandler.py +++ b/kas/includehandler.py @@ -26,6 +26,7 @@ """ import os +from pathlib import Path from collections import OrderedDict from collections.abc import Mapping import functools @@ -121,12 +122,26 @@ class IncludeHandler: relative to the repository root path. The includes are read and merged from the deepest level upwards. + + In case ignore_lock is false, kas checks if a file .lock. + exists next to the first entry in top_files. This file is then appended + to the list of top_files. """ - def __init__(self, top_files, top_repo_path): + def __init__(self, top_files, top_repo_path, use_lock=True): self.top_files = top_files self.top_repo_path = top_repo_path + if use_lock: + lockfile = self.get_lockfile() + if Path(lockfile).exists(): + logging.debug('includehandler: append lockfile %s', lockfile) + self.top_files.append(lockfile) + + def get_lockfile(self): + file = Path(self.top_files[0]) + return file.parent / (file.stem + '.lock' + file.suffix) + def get_config(self, repos=None): """ Parameters: