From fcbe936b1dbc0d6fa490cc4bb4ac32bf9aadab10 Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 3 May 2024 17:58:04 -0400 Subject: [PATCH] Fixed a bug in update-state - need to switch to the fixture dir first --- src/mepo/command/update-state.py | 17 ++++++++++++++--- src/mepo/component.py | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mepo/command/update-state.py b/src/mepo/command/update-state.py index 55ea6682..95fa9268 100644 --- a/src/mepo/command/update-state.py +++ b/src/mepo/command/update-state.py @@ -1,17 +1,28 @@ +import os + from ..state import MepoState from ..component import MepoComponent def run(args): + '''Permanently convert mepo1 state to mepo2 state''' allcomps_old = MepoState.read_state() MepoState.mepo1_patch_undo() # Convert component to dict and then package it as component again. That is # needed to avoid pickle trying to use the path to the old modules allcomps = [] for comp in allcomps_old: + # print(comp) tmp_dict = comp.to_registry_format() - name = list(tmp_dict)[0] - comp = tmp_dict[name] - allcomps.append(MepoComponent().to_component(name, comp, None)) + tmp_name = list(tmp_dict)[0] + tmp_details = tmp_dict[tmp_name] + # This needs to be run from the fixture directory so that + # MepoComponent::__set_original_version + # picks the right repo for setting version + cwd = os.getcwd() + os.chdir(MepoState.get_root_dir()) + comp_new = MepoComponent().to_component(tmp_name, tmp_details, None) + os.chdir(cwd) + allcomps.append(comp_new) # Write new state MepoState.write_state(allcomps) print('\nConverted mepo1 state to mepo2\n') diff --git a/src/mepo/component.py b/src/mepo/component.py index bbaf0108..62ed844f 100644 --- a/src/mepo/component.py +++ b/src/mepo/component.py @@ -117,9 +117,9 @@ def __validate_component(self, comp_name, comp_details): def to_component(self, comp_name, comp_details, comp_style): self.name = comp_name self.fixture = comp_details.get('fixture', False) + # local/remote - start if self.fixture: self.__validate_fixture(comp_details) - self.local = '.' repo_url = get_current_remote_url() p = urlparse(repo_url) @@ -159,6 +159,7 @@ def to_component(self, comp_name, comp_details, comp_style): #print(f'final self.local: {self.local}') self.remote = comp_details['remote'] + # local/remote - end self.sparse = comp_details.get('sparse', None) # sparse is optional self.develop = comp_details.get('develop', None) # develop is optional self.recurse_submodules = comp_details.get('recurse_submodules', None) # recurse_submodules is optional