<commit_before>let sprintf = Printf.sprintf

let name = "uniboom"
let () = Util.supplyFileInUnisonDirFn (fun s -> sprintf "./.%s/%s" name s)

let debug s = Trace.debug "uniboom" (fun () -> Util.format "%s" s)

let archive_fn n = Util.fileInUnisonDir (sprintf ".#%s" n) 
let tmp_fn n = Util.fileInUnisonDir (sprintf ".#%s-tmp" n) 

let go l c_fn a_fn = 
  let o_fn = archive_fn c_fn in 
  let cp fn1 fn2 = Misc.write fn2 (Misc.read fn1) in 
  let eq fn1 fn2 = Misc.read fn1 = Misc.read fn2 in 
  let get c a = ignore (Sys.command (sprintf "boomerang -c %s -o %s %s" c a l)) in 
  let put a o c = ignore (Sys.command (sprintf "boomerang -a %s -c %s -o %s %s" a o c l)) in 
  let crt a c = ignore (Sys.command (sprintf "boomerang -a %s -o %s %s" a c l)) in 
  match Sys.file_exists o_fn, Sys.file_exists c_fn, Sys.file_exists a_fn with 
    | _,false,false -> 
        (* if neither c nor a exists, clear o and return *)
        Misc.remove_file_or_dir o_fn;
        None

    | _,true,false -> 
        (* if c exists but a does not, set a to GET c *)
        cp c_fn o_fn;
        get c_fn a_fn;
        None
          
    | true,false,true ->
        (* if c does not exist but a and o do, set c to PUT a o *)        
        put a_fn o_fn c_fn;
        cp c_fn o_fn;
        None
          
    | false,false,true ->
        (* if c and o do not exist but a does, set c to CRT a *)        
        crt a_fn c_fn;
        cp c_fn o_fn;
        None          

    | false,true,true -> 
        (* if c and a exist but o does not and a <> GET c then conflict *)
        let t_fn = tmp_fn a_fn in 
        get c_fn t_fn;
        if eq a_fn t_fn then
          (cp c_fn o_fn; 
           None)
        else 
          Some (c_fn, a_fn)
    | true,true,true -> 
        (* otherwise, c, a, and o exist:
           - if c=o, set c to PUT a o
           - else if a=GET o set a to GET c
           - otherwise conflict *)
        if eq c_fn o_fn then
          (put a_fn o_fn c_fn;
           cp c_fn o_fn;
           None)
        else 
          (let t_fn = tmp_fn a_fn in 
             get o_fn t_fn;             
            if eq a_fn t_fn then 
              (get c_fn a_fn;
               cp c_fn o_fn;                
               None)
            else 
              Some (c_fn,a_fn))
            
let usage = sprintf "%s [options]" name

let l_pref = Prefs.createStringList "lens" "lens" "lens"
let c_pref = Prefs.createStringList "concrete" "concrete" "abstract"
let a_pref = Prefs.createStringList "abstract" "abstract" "abstract"

let () = 
  Prefs.profileName := Some "uniboom";
  Prefs.parseCmdLine usage;
  Prefs.loadTheFile ()

let ll = Prefs.read l_pref  
let cl = Prefs.read c_pref  
let al = Prefs.read a_pref  
let ll_len = Safelist.length ll 
let cl_len = Safelist.length cl 
let al_len = Safelist.length al <commit_msg>Small fix: changed name of pref file to "default". <commit_after>let sprintf = Printf.sprintf

let name = "uniboom"
let () = Util.supplyFileInUnisonDirFn (fun s -> sprintf "./.%s/%s" name s)

let debug s = Trace.debug "uniboom" (fun () -> Util.format "%s" s)

let archive_fn n = Util.fileInUnisonDir (sprintf ".#%s" n) 
let tmp_fn n = Util.fileInUnisonDir (sprintf ".#%s-tmp" n) 

let go l c_fn a_fn = 
  let o_fn = archive_fn c_fn in 
  let cp fn1 fn2 = Misc.write fn2 (Misc.read fn1) in 
  let eq fn1 fn2 = Misc.read fn1 = Misc.read fn2 in 
  let get c a = ignore (Sys.command (sprintf "boomerang -c %s -o %s %s" c a l)) in 
  let put a o c = ignore (Sys.command (sprintf "boomerang -a %s -c %s -o %s %s" a o c l)) in 
  let crt a c = ignore (Sys.command (sprintf "boomerang -a %s -o %s %s" a c l)) in 
  match Sys.file_exists o_fn, Sys.file_exists c_fn, Sys.file_exists a_fn with 
    | _,false,false -> 
        (* if neither c nor a exists, clear o and return *)
        Misc.remove_file_or_dir o_fn;
        None

    | _,true,false -> 
        (* if c exists but a does not, set a to GET c *)
        cp c_fn o_fn;
        get c_fn a_fn;
        None
          
    | true,false,true ->
        (* if c does not exist but a and o do, set c to PUT a o *)        
        put a_fn o_fn c_fn;
        cp c_fn o_fn;
        None
          
    | false,false,true ->
        (* if c and o do not exist but a does, set c to CRT a *)        
        crt a_fn c_fn;
        cp c_fn o_fn;
        None          

    | false,true,true -> 
        (* if c and a exist but o does not and a <> GET c then conflict *)
        let t_fn = tmp_fn a_fn in 
        get c_fn t_fn;
        if eq a_fn t_fn then
          (cp c_fn o_fn; 
           None)
        else 
          Some (c_fn, a_fn)
    | true,true,true -> 
        (* otherwise, c, a, and o exist:
           - if c=o, set c to PUT a o
           - else if a=GET o set a to GET c
           - otherwise conflict *)
        if eq c_fn o_fn then
          (put a_fn o_fn c_fn;
           cp c_fn o_fn;
           None)
        else 
          (let t_fn = tmp_fn a_fn in 
             get o_fn t_fn;             
            if eq a_fn t_fn then 
              (get c_fn a_fn;
               cp c_fn o_fn;                
               None)
            else 
              Some (c_fn,a_fn))
            
let usage = sprintf "%s [options]" name

let l_pref = Prefs.createStringList "lens" "lens" "lens"
let c_pref = Prefs.createStringList "concrete" "concrete" "abstract"
let a_pref = Prefs.createStringList "abstract" "abstract" "abstract"

let () = 
  Prefs.profileName := Some "default";
  Prefs.parseCmdLine usage;
  Prefs.loadTheFile ()

let ll = Prefs.read l_pref  
let cl = Prefs.read c_pref  
let al = Prefs.read a_pref  
let ll_len = Safelist.length ll 
let cl_len = Safelist.length cl 
let al_len = Safelist.length al 
{'fraction_non_alphanumeric': 0.09548793284365163, 'fraction_numerical': 0.0027981811822315496, 'mean_word_length': 1.7376735280038296, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6579206', 'n_tokens_mistral': 2117, 'n_tokens_neox': 2045, 'n_words': 739}