Login
repoOrCheckout.s2 at [962200c936]
Login

File bindings/s2/require.d/fsl/db/repoOrCheckout.s2 artifact e684a8619f part of check-in 962200c936


/**
   require.s2 module which returns either the repo db (specified by
   the -R|--repo-db=DBFILE script flags) or (if that fails) the repo
   db associated with the current checkout. Throws if it can neither
   open a checkout nor figure out the db from the CLI args.
*/
return requireS2(['fsl/context'], proc(F){
  affirm F.db;
  const x = F.hasDb('repo') ||| F.hasDb('checkout');
  x && return x;
  catch return requireS2(['fsl/db/repo']).0; // fails if no -R|--repo-db=DBFILE flag specified
  requireS2(['fsl/db/checkout']) /* opens the checkout */;
  affirm F.hasDb('checkout');
  return F.db;
});