import logging,os,shutil,zipfile
from localstack.utils.files import new_tmp_dir,rm_rf
from localstack.utils.strings import short_uid
from localstack_ext.bootstrap.pods.utils.common import PodsConfigContext
LOG=logging.getLogger(__name__)
def merge_from_version_archive(versions_archive,config_context):
	C=config_context;B=versions_archive;D=new_tmp_dir();G=short_uid();A=PodsConfigContext(pods_root_dir=D,pod_name=G)
	with zipfile.ZipFile(B)as H:H.extractall(A.get_pod_root_dir())
	I=A.get_versions_path();J=C.get_versions_path();K=A.get_obj_store_path();L=C.get_obj_store_path();M=(J,I),(L,K)
	for (N,E) in M:
		for F in os.listdir(E):O=os.path.join(E,F);P=os.path.join(N,F);shutil.copy(O,P)
	rm_rf(D);rm_rf(B)