From 00ad0440b19acfc61c713e97da33c7821b4cd2b3 Mon Sep 17 00:00:00 2001 From: John Alex Date: Fri, 6 Jan 2023 21:14:06 +0000 Subject: [PATCH] =?UTF-8?q?Further=20tiny=20refactorings=20and=20docs=20of?= =?UTF-8?q?=20checkout=20API=20(no-op).=20=20=20=20Remove=20unused=20load?= =?UTF-8?q?=5Fall=20param=20in=20=5FExternal.checkout().=20=20=20=20Rename?= =?UTF-8?q?=20=5FExternal.checkout=5Fexternals()=20to=20checkout=5Fsubexte?= =?UTF-8?q?rnals(),=20to=20remove=20the=20ambiguity=20about=20whether=20th?= =?UTF-8?q?e=20main=20external=20pointed=20to=20by=20the=20=5FExternal=20i?= =?UTF-8?q?s=20itelf=20checked=20out=20(it=20is=20not)=20=20=20=20Clarify?= =?UTF-8?q?=20load=5Fall=20documentation=20-=20it=E2=80=99s=20always=20rec?= =?UTF-8?q?ursive,=20but=20applies=20different=20criteria=20at=20each=20le?= =?UTF-8?q?vel.=20=20=20=20Rename=20variables=20in=20checkout.py=20(e.g.?= =?UTF-8?q?=20ext=5Fdescription)=20=20to=20match=20the=20equivalent=20code?= =?UTF-8?q?=20in=20sourcetree.py.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manic/checkout.py | 10 +++++----- manic/sourcetree.py | 35 ++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/manic/checkout.py b/manic/checkout.py index ee39f9e35..dff11b661 100755 --- a/manic/checkout.py +++ b/manic/checkout.py @@ -396,17 +396,17 @@ def main(args): load_all = True root_dir = os.path.abspath(os.getcwd()) - external_data = read_externals_description_file(root_dir, args.externals) - external = create_externals_description( - external_data, components=args.components, exclude=args.exclude) + model_data = read_externals_description_file(root_dir, args.externals) + ext_description = create_externals_description( + model_data, components=args.components, exclude=args.exclude) for comp in args.components: - if comp not in external.keys(): + if comp not in ext_description.keys(): fatal_error( "No component {} found in {}".format( comp, args.externals)) - source_tree = SourceTree(root_dir, external, svn_ignore_ancestry=args.svn_ignore_ancestry) + source_tree = SourceTree(root_dir, ext_description, svn_ignore_ancestry=args.svn_ignore_ancestry) if args.components: components_str = 'specified components' else: diff --git a/manic/sourcetree.py b/manic/sourcetree.py index 1e66623a2..3ab9d014c 100644 --- a/manic/sourcetree.py +++ b/manic/sourcetree.py @@ -117,10 +117,10 @@ def status(self, force=False): elif self._local_path == LOCAL_PATH_INDICATOR: # LOCAL_PATH_INDICATOR, '.' paths, are standalone # component directories that are not managed by - # checkout_externals. + # checkout_subexternals. self._stat.source_type = ExternalStatus.STANDALONE else: - # managed by checkout_externals + # managed by checkout_subexternals self._stat.source_type = ExternalStatus.MANAGED subcomponent_stats = {} @@ -169,13 +169,13 @@ def status(self, force=False): return all_stats - def checkout(self, verbosity, load_all): + def checkout(self, verbosity): """ If the repo destination directory exists, ensure it is correct (from correct URL, correct branch or tag), and possibly update the external. If the repo destination directory does not exist, checkout the correct branch or tag. - load_all is currently ignored. See checkout_externals() to check out sub-externals. + Does not check out sub-externals, see checkout_subexternals(). """ # Make sure we are in correct location if not os.path.exists(self._repo_dir_path): @@ -213,10 +213,10 @@ def checkout(self, verbosity, load_all): self._repo.checkout(self._base_dir_path, self._repo_dir_name, checkout_verbosity, self.clone_recursive()) - def checkout_externals(self, verbosity, load_all): - """Checkout the sub-externals for this component, if any. + def checkout_subexternals(self, verbosity, load_all): + """Recursively checkout the sub-externals for this component, if any. - if load_all is True, also recurse into sub-sub-externals and so on. + See load_all documentation in SourceTree.checkout(). """ if self.load_externals(): if self._externals_sourcetree: @@ -353,13 +353,11 @@ def _find_installed_optional_components(self): def checkout(self, verbosity, load_all, load_comp=None): """ - Checkout or update indicated components into the the configured - subdirs. + Checkout or update indicated components into the configured subdirs. - If load_all is True, recursively checkout all externals. - If load_all is False, load_comp is an optional set of components to load. - If load_all is False and load_comp is None, only checkout the required external (plus any optionals that are already checked out) - For all 3 cases, sub-externals are also recursively checked out. + If load_all is True, checkout all externals (required + optional), recursively. + If load_all is False and load_comp is set, checkout load_comp (and any required subexternals, plus any optional subexternals that are already checked out, recursively) + If load_all is False and load_comp is None, checkout all required externals, plus any optionals that are already checked out, recursively. """ if load_all: tmp_comps = self._all_components.keys() @@ -380,7 +378,8 @@ def checkout(self, verbosity, load_all, load_comp=None): # Sort by path so that if paths are nested the # parent repo is checked out first. load_comps = sorted(tmp_comps, key=lambda comp: self._all_components[comp].get_local_path()) - # checkout the primary externals + + # checkout. for comp in load_comps: if verbosity < VERBOSITY_VERBOSE: printlog('{0}, '.format(comp), end='') @@ -388,7 +387,9 @@ def checkout(self, verbosity, load_all, load_comp=None): # verbose output handled by the _External object, just # output a newline printlog(EMPTY_STR) - self._all_components[comp].checkout(verbosity, load_all) - # now give each external an opportunitity to checkout it's externals. - self._all_components[comp].checkout_externals(verbosity, load_all) + # Does not recurse. + self._all_components[comp].checkout(verbosity) + # Recursively check out subexternals, if any. + self._all_components[comp].checkout_subexternals(verbosity, + load_all) printlog('')