pijul_org / pijul

Some refactorings around patch selection in record

By FlorentBecker on March 1, 2018
This patch is not signed.
AcT8V9UhpjPjHeYnSgij1aSzratXpJsZ4imsa38ir8rEAQigooujVQ5t2RTbBbvDtmFSn4tLnYxetqktEqZrcV4C
This patch is in the following branches:
latest
master
testing
In file pijul/src/commands


































fn interactive_decision<T: rand::Rng>(repository: &MutTxn<T>,
                                      change: &Record<ChangeContext<Hash>>,
                                      current_file: &mut Option<Rc<PathBuf>>,
                                      n_changes: usize,
                                      i: usize,
                                      direction: ChangesDirection,
                                      terminal: &mut Option<Box<StdoutTerminal>>,
                                      getch: &getch::Getch)
                                      -> Result<(char, Option<char>), Error> {
    print_change(terminal, repository, current_file, &change)?;
    print!("Shall I {} this change? ({}/{}) [ynkad] ", direction.verb(), i+1, n_changes);
                'A' => {
                    Ok(('Y', Some('Y')))
                }
                'D' => {
                    Ok(('N', Some('N')))
                }
        let (e,f) = match decision {
                    interactive_decision(repository, &changes[i], &mut current_file,
                                         changes.len(), i, direction, &mut terminal, &getch)?
fn select_changes(opts: &BasicOptions, add_new_files: bool, branch_name: &str,
                  yes_to_all: bool, prefix: Option<HashSet<PathBuf>>) ->
    Result<(Vec<Record<Vec<Key<Option<Hash>>>>>, Vec<InodeUpdate>)>
{
    if add_new_files { add_untracked_files(&mut txn, &opts.repo_root)? };
    let (changes, syncs) = changes_from_prefixes(
        &opts.repo_root,
        &mut txn,
        &branch_name,
        prefix.as_ref()
    )?;
    let changes:Vec<_> = changes.into_iter().map(|x| txn.globalize_record(x)).collect();
        let c = ask_changes(&txn, &changes, ChangesDirection::Record)?;
        let selected = changes.into_iter()