From 24a3726a17182047bee4f41b0c2d222ab23779cc Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 18 Sep 2020 08:05:31 -0600 Subject: [PATCH] improve sorting, checkout externals with each comp --- manic/sourcetree.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/manic/sourcetree.py b/manic/sourcetree.py index 65d6e2f11..d22de7768 100644 --- a/manic/sourcetree.py +++ b/manic/sourcetree.py @@ -336,8 +336,9 @@ def checkout(self, verbosity, load_all, load_comp=None): tmp_comps = [load_comp] else: tmp_comps = self._required_compnames - - load_comps = self.order_comps_by_local_path(tmp_comps) + # 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 for comp in load_comps: if verbosity < VERBOSITY_VERBOSE: @@ -347,23 +348,6 @@ def checkout(self, verbosity, load_all, load_comp=None): # output a newline printlog(EMPTY_STR) self._all_components[comp].checkout(verbosity, load_all) - printlog('') - - # now give each external an opportunitity to checkout it's externals. - for comp in load_comps: + # now give each external an opportunitity to checkout it's externals. self._all_components[comp].checkout_externals(verbosity, load_all) - - def order_comps_by_local_path(self, comps_in): - """ - put the comps into an order so that comp local_paths - that are nested are checked out in correct order - """ - comps_out = [] - local_paths = [] - for comp in comps_in: - local_paths.append(self._all_components[comp].get_local_path()) - for path in sorted(local_paths, key=len): - for comp in comps_in: - if self._all_components[comp].get_local_path() == path: - comps_out.append(comp) - return comps_out + printlog('')