test channel name

[?]
Jun 3, 2025, 4:17 PM
SWDPAGF6BGUA2L6KFP6LAVCA3SX4QA5FOZRLLOAWLNZ6RNCIV4RQC

Dependencies

  • [2] SWWE2R6M display basic repo stuff
  • [3] KT5UYXGK fix selection after adding file, add changed file diffs
  • [4] W7IUT3ZV start recording impl
  • [5] YBJRDOTC make all repo actions async
  • [6] A5YBC77V record!
  • [7] VCNKFNUF app init test
  • [8] I56UGW7U make record test, fix log update
  • [9] KMB6FND3 test view update fn rather than direct fn calls
  • [10] YYKXNBFL test: add untracked file
  • [11] TSFQFCB2 test got repo change
  • [12] UF5NJKAS test load repo
  • [13] VOFP2YNQ prettify
  • [14] ONRCENKT rm unnecessary state from repo's internal state
  • [15] EC3TVL4X add untracked files
  • [16] ESMM3FEL test selection reindexing
  • [17] 4WO3ZJM2 show untracked files' contents

Change contents

  • edit in libflorescence/src/testing.rs at line 1
    [7.5]
    [7.6]
    use crate::prelude::pijul;
    use crate::repo;
  • edit in libflorescence/src/testing.rs at line 12
    [12.38]
    [7.177]
    use std::sync::Arc;
  • replacement in libflorescence/src/testing.rs at line 14
    [7.178][12.39:136]()
    /// Get the path to the repo
    pub fn repo_path(repo: &PijulRepo) -> PathBuf {
    let PijulRepo {
    [7.178]
    [12.136]
    /// Get the path to the test repo
    pub fn repo_path(repo: &TestRepo) -> PathBuf {
    let TestRepo {
  • replacement in libflorescence/src/testing.rs at line 27
    [12.310][7.178:327](),[7.178][7.178:327]()
    /// Setup a Pijul ID in a temp dir. Sets `PIJUL_CONFIG_DIR` env var, which is
    /// used by pijul when loading ID
    pub fn setup_pijul_id() -> PijulId {
    [12.310]
    [7.327]
    /// Setup a Pijul user ID in a temp dir. Sets `PIJUL_CONFIG_DIR` env var, which
    /// is used by pijul when loading ID
    pub fn setup_test_user_id() -> TestUserId {
  • replacement in libflorescence/src/testing.rs at line 57
    [7.1289][7.1289:1315]()
    PijulId { dir, skey }
    [7.1289]
    [7.1315]
    TestUserId { dir, skey }
  • replacement in libflorescence/src/testing.rs at line 61
    [7.1362][7.1362:1403](),[7.1403][12.311:346]()
    pub fn setup_pijul_repo() -> PijulRepo {
    setup_pijul_repo_in_subdir("")
    [7.1362]
    [12.346]
    pub fn setup_test_repo() -> TestRepo {
    setup_test_repo_in_subdir("")
  • replacement in libflorescence/src/testing.rs at line 66
    [12.415][12.415:491]()
    pub fn setup_pijul_repo_in_subdir<P: AsRef<Path>>(subdir: P) -> PijulRepo {
    [12.415]
    [12.491]
    pub fn setup_test_repo_in_subdir<P: AsRef<Path>>(subdir: P) -> TestRepo {
  • edit in libflorescence/src/testing.rs at line 68
    [12.529]
    [12.529]
    let repo_dir = rootdir.path().join(&subdir);
    let mut repo = empty_pijul_repo(repo_dir.clone());
  • replacement in libflorescence/src/testing.rs at line 71
    [12.530][12.530:629](),[12.629][7.1532:1856](),[7.1532][7.1532:1856]()
    let repo = Repository::init(Some(rootdir.path().join(&subdir)), None, None)
    .unwrap();
    let mut txn = repo.pristine.mut_txn_begin().unwrap();
    let channel_name = libpijul::DEFAULT_CHANNEL.to_string();
    libpijul::MutTxnT::open_or_create_channel(&mut txn, &channel_name).unwrap();
    libpijul::MutTxnT::set_current_channel(&mut txn, &channel_name).unwrap();
    libpijul::MutTxnT::commit(txn).unwrap();
    [12.530]
    [7.1856]
    // Select and record the default ".ignore" file
    let file_to_record = ".ignore";
    repo::add(&mut repo, file_to_record);
    let (internal, _state) = repo::load(repo_dir).unwrap();
    let skey = Arc::new(SKey::generate(None));
    repo::record(&internal, "Initialized".to_string(), skey);
  • replacement in libflorescence/src/testing.rs at line 79
    [7.1857][12.630:646]()
    PijulRepo {
    [7.1857]
    [12.646]
    TestRepo {
  • edit in libflorescence/src/testing.rs at line 87
    [12.822]
    [7.1879]
    }
    pub fn empty_pijul_repo(dir: PathBuf) -> pijul::Repository {
    let repo = Repository::init(Some(dir), None, None).unwrap();
    let mut txn = repo.pristine.mut_txn_begin().unwrap();
    let channel_name = libpijul::DEFAULT_CHANNEL.to_string();
    libpijul::MutTxnT::open_or_create_channel(&mut txn, &channel_name).unwrap();
    libpijul::MutTxnT::set_current_channel(&mut txn, &channel_name).unwrap();
    libpijul::MutTxnT::commit(txn).unwrap();
    repo
  • replacement in libflorescence/src/testing.rs at line 102
    [7.1925][7.1925:1946]()
    pub struct PijulId {
    [7.1925]
    [7.1946]
    pub struct TestUserId {
  • replacement in libflorescence/src/testing.rs at line 109
    [7.2044][7.2044:2067]()
    pub struct PijulRepo {
    [7.2044]
    [12.823]
    pub struct TestRepo {
  • replacement in libflorescence/src/repo.rs at line 276
    [2.663][12.1552:1622]()
    fn load(path: PathBuf) -> Result<(InternalState, State), LoadError> {
    [2.663]
    [12.1622]
    pub(crate) fn load(path: PathBuf) -> Result<(InternalState, State), LoadError> {
  • replacement in libflorescence/src/repo.rs at line 322
    [2.1299][6.803:870]()
    fn record(state: &InternalState, message: String, sk: Arc<SKey>) {
    [2.1299]
    [4.361]
    #[derive(Debug)]
    pub enum NewChannelError {
    AlreadyExists(String),
    }
    #[allow(dead_code)] // TODO rm once used
    fn new_channel(
    repo: &mut pijul::Repository,
    name: String,
    ) -> Result<(), NewChannelError> {
    use libpijul::{GraphTxnT, MutTxnTExt};
    // pijul's command `Channel::New`
    let mut txn = repo.pristine.mut_txn_begin().unwrap();
    if txn.load_channel(&name).unwrap().is_some() {
    return Err(NewChannelError::AlreadyExists(name));
    }
    let new = txn.open_or_create_channel(&name).unwrap();
    // Safeguard: apply the root patch if we're creating a new channel.
    let current = txn.current_channel().unwrap();
    let channel = txn.load_channel(current).unwrap().unwrap();
    let ch = channel.read();
    let h = if let Some(Ok((k, v))) =
    libpijul::pristine::changeid_log(&txn, &ch, 0u64.into())
    .unwrap()
    .next()
    {
    Some(txn.get_external(&v.a).unwrap().unwrap().into())
    } else {
    None
    };
    if let Some(h) = h {
    let mut new = new.write();
    txn.apply_change(&repo.changes, &mut new, &h).unwrap();
    }
    // txn.commit().unwrap();
    // Parts of pijul's command `Channel::Switch`
    txn.set_current_channel(&name).unwrap();
    txn.commit().unwrap();
    Ok(())
    }
    pub(crate) fn record(state: &InternalState, message: String, sk: Arc<SKey>) {
  • replacement in libflorescence/src/repo.rs at line 550
    [5.3438][5.3438:3498]()
    fn add(repo: &mut pijul::Repository, file_path_str: &str) {
    [5.3438]
    [3.635]
    pub fn add(repo: &mut pijul::Repository, file_path_str: &str) {
  • replacement in libflorescence/src/repo/test.rs at line 1
    [12.1959][12.1960:2056]()
    use crate::repo;
    use crate::testing::{repo_path, setup_pijul_repo, setup_pijul_repo_in_subdir};
    [12.1959]
    [12.2056]
    use crate::repo::{self, pijul};
    use crate::testing::{repo_path, setup_test_repo, setup_test_repo_in_subdir};
  • replacement in libflorescence/src/repo/test.rs at line 32
    [12.2798][12.2798:2853]()
    let repo = setup_pijul_repo_in_subdir(subdir);
    [12.2798]
    [12.2853]
    let repo = setup_test_repo_in_subdir(subdir);
  • replacement in libflorescence/src/repo/test.rs at line 46
    [13.558][12.3365:3400](),[12.3365][12.3365:3400]()
    let repo = setup_pijul_repo();
    [13.558]
    [12.3400]
    let repo = setup_test_repo();
  • replacement in libflorescence/src/repo/test.rs at line 66
    [12.3878][12.3878:3970]()
    assert_eq!(untracked_files.len(), 1);
    assert!(untracked_files.contains(".ignore"));
    [12.3878]
    [12.3970]
    assert!(untracked_files.is_empty());
  • replacement in libflorescence/src/repo/test.rs at line 68
    [12.4009][12.4009:4038]()
    assert!(log.is_empty());
    [12.4009]
    [12.4038]
    assert_eq!(log.len(), 2);
  • edit in libflorescence/src/repo/test.rs at line 70
    [12.4040]
    #[test]
    fn test_current_channel() {
    let repo = setup_test_repo();
    let repo_path = repo_path(&repo);
    let mut repo = pijul::Repository::find_root(Some(repo_path)).unwrap();
    assert_eq!(repo::current_channel(&repo), libpijul::DEFAULT_CHANNEL);
    let new_channel_name = "NEW CHANNEL!".to_string();
    repo::new_channel(&mut repo, new_channel_name.clone()).unwrap();
    assert_eq!(repo::current_channel(&repo), new_channel_name);
    }
  • replacement in inflorescence/src/test.rs at line 10
    [8.1520][12.4153:4222]()
    repo_path, setup_pijul_id, setup_pijul_repo, PijulId, PijulRepo,
    [8.1520]
    [8.1578]
    repo_path, setup_test_repo, setup_test_user_id, TestRepo, TestUserId,
  • replacement in inflorescence/src/test.rs at line 25
    [7.2682][7.2682:2749]()
    let _id = setup_pijul_id();
    let repo = setup_pijul_repo();
    [7.2682]
    [12.4223]
    let _id = setup_test_user_id();
    let repo = setup_test_repo();
  • replacement in inflorescence/src/test.rs at line 719
    [8.4785][8.4785:4851]()
    let id = setup_pijul_id();
    let repo = setup_pijul_repo();
    [8.4785]
    [12.4340]
    let id = setup_test_user_id();
    let repo = setup_test_repo();
  • edit in inflorescence/src/test.rs at line 740
    [8.5488][8.5488:5576](),[8.5576][9.1361:1698](),[9.1698][8.5710:6088](),[8.5710][8.5710:6088](),[8.6088][9.1699:1753](),[9.1753][8.6130:6235](),[8.6130][8.6130:6235](),[8.6235][9.1754:1779](),[9.1779][8.6256:6276](),[8.6256][8.6256:6276](),[8.6276][9.1780:1921](),[9.1921][8.6381:6713](),[8.6381][8.6381:6713](),[8.6713][9.1922:1991](),[9.1991][8.6754:6919](),[8.6754][8.6754:6919]()
    // Select and record the default ".ignore" file
    let file_to_record = ".ignore";
    update(
    &mut state,
    Msg::View(app::Msg::Cursor(cursor::Msg::Select(
    cursor::Select::UntrackedFile {
    ix: 0,
    path: file_to_record.to_string(),
    },
    ))),
    );
    // Selection triggers `LoadedSrcFile`
    let _msg = task::await_next_msg(&mut tasks).await;
    // Add it to tracked files
    let _task = update(&mut state, Msg::AddUntrackedFile);
    // Wait for it to be added
    let msg = task::await_next_msg(&mut tasks).await;
    assert_matches!(
    &msg,
    Msg::FromRepo(repo::MsgOut::AddedUntrackedFile { path }) if path == file_to_record
    );
    // Make the initial record to add project root: Start a record
    let _task = update(&mut state, Msg::StartRecord);
    assert!(state.record_msg.is_some());
    // Edit the record msg
    let record_msg = "Initialized";
    let _task = update(
    &mut state,
    Msg::View(app::Msg::EditRecordMsg(text_editor::Action::Edit(
    text_editor::Edit::Paste(Arc::new(record_msg.to_string())),
    ))),
    );
    assert!(state.record_msg.is_some());
    assert_matches!(
    state.record_msg.as_ref().unwrap(),
    app::RecordMsg::Typing(_)
    );
    if let app::RecordMsg::Typing(content) = state.record_msg.as_ref().unwrap()
    {
    assert_eq!(&content.text(), record_msg);
    }
    // Save the record
    let _task = update(&mut state, Msg::View(app::Msg::SaveRecord));
    let msg = task::await_next_msg(&mut tasks).await;
    assert_matches!(&msg, Msg::FromRepo(repo::MsgOut::Recorded(_)));
    let _task = update(&mut state, msg);
  • replacement in inflorescence/src/test.rs at line 745
    [10.2742][8.7129:7182](),[8.7129][8.7129:7182]()
    assert_eq!(log[0].file_paths, [file_to_record]);
    [10.2742]
    [8.7182]
    assert_eq!(log[0].file_paths, [".ignore"]);
  • replacement in inflorescence/src/test.rs at line 765
    [8.7604][8.7604:7650]()
    pub id: PijulId,
    pub repo: PijulRepo,
    [8.7573]
    [11.2214]
    pub id: TestUserId,
    pub repo: TestRepo,