Skip to content

Commit

Permalink
Fixed a bug in update-state - need to switch to the fixture dir first
Browse files Browse the repository at this point in the history
  • Loading branch information
pchakraborty committed May 3, 2024
1 parent c8582c5 commit fcbe936
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/mepo/command/update-state.py
Original file line number Diff line number Diff line change
@@ -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')
3 changes: 2 additions & 1 deletion src/mepo/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fcbe936

Please sign in to comment.