Pushing to, and pulling from the local repository

[?]
Nov 17, 2020, 11:36 AM
76PCXGML77EZWTRI5E6KHLVRAFTJ2AB5YRN5EKOYNAPKTWY2KCGAC

Dependencies

  • [2] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [3] IMCZFTIJ Update selection instructions to also mention pushing
  • [4] 5HF7C67M push/pull: fixed "changes" arguments

Change contents

  • edit in pijul/src/remote/mod.rs at line 18
    [2.52838]
    [2.52838]
    LocalChannel(String),
  • edit in pijul/src/remote/mod.rs at line 32
    [2.53031]
    [2.53031]
    self_path: Option<&Path>,
  • replacement in pijul/src/remote/mod.rs at line 38
    [2.53208][2.53208:53271]()
    unknown_remote(name, channel, no_cert_check).await
    [2.53208]
    [2.53271]
    unknown_remote(self_path, name, channel, no_cert_check).await
  • replacement in pijul/src/remote/mod.rs at line 40
    [2.53288][2.53288:53351]()
    unknown_remote(name, channel, no_cert_check).await
    [2.53288]
    [2.53351]
    unknown_remote(self_path, name, channel, no_cert_check).await
  • edit in pijul/src/remote/mod.rs at line 46
    [2.53399]
    [2.53399]
    self_path: Option<&Path>,
  • replacement in pijul/src/remote/mod.rs at line 53
    [2.53622][2.53622:53657]()
    Ok(RemoteRepo::Http(Http {
    [2.53622]
    [2.53657]
    return Ok(RemoteRepo::Http(Http {
  • replacement in pijul/src/remote/mod.rs at line 60
    [2.53907][2.53907:54008]()
    }))
    } else if name.starts_with("ssh://") {
    if let Some(ssh) = ssh_remote(name) {
    [2.53907]
    [2.54008]
    }));
    }
    if name.starts_with("ssh://") {
    return if let Some(ssh) = ssh_remote(name) {
  • edit in pijul/src/remote/mod.rs at line 71
    [2.54266]
    [2.54266]
    };
    }
    if let Ok(root) = std::fs::canonicalize(name) {
    if let Some(path) = self_path {
    let path = std::fs::canonicalize(path)?;
    if path == root {
    return Ok(RemoteRepo::LocalChannel(channel.to_string()));
    }
  • replacement in pijul/src/remote/mod.rs at line 80
    [2.54276][2.54276:54346]()
    } else {
    let mut dot_dir = Path::new(name).join(DOT_DIR);
    [2.54276]
    [2.54346]
    let mut dot_dir = root.join(DOT_DIR);
  • replacement in pijul/src/remote/mod.rs at line 88
    [2.54603][2.54603:54644]()
    Ok(RemoteRepo::Local(Local {
    [2.54603]
    [2.54644]
    return Ok(RemoteRepo::Local(Local {
  • replacement in pijul/src/remote/mod.rs at line 94
    [2.54838][2.54838:55165]()
    }))
    } else if let Some(ssh) = ssh_remote(name) {
    debug!("unknown_remote, ssh = {:?}", ssh);
    Ok(RemoteRepo::Ssh(ssh.connect(name, channel).await?))
    } else {
    Err((Error::RemoteNotFound {
    remote: name.to_string(),
    })
    .into())
    [2.54838]
    [2.55165]
    }));
  • edit in pijul/src/remote/mod.rs at line 97
    [2.55181]
    [2.55181]
    if let Some(ssh) = ssh_remote(name) {
    debug!("unknown_remote, ssh = {:?}", ssh);
    Ok(RemoteRepo::Ssh(ssh.connect(name, channel).await?))
    } else {
    Err((Error::RemoteNotFound {
    remote: name.to_string(),
    })
    .into())
    }
  • replacement in pijul/src/remote/mod.rs at line 109
    [2.55202][2.55202:55231]()
    fn name(&self) -> &str {
    [2.55202]
    [2.55231]
    fn name(&self) -> Option<&str> {
  • replacement in pijul/src/remote/mod.rs at line 111
    [2.55253][2.55253:55421]()
    RemoteRepo::Ssh(ref s) => s.name.as_str(),
    RemoteRepo::Local(ref l) => l.name.as_str(),
    RemoteRepo::Http(ref h) => h.name.as_str(),
    [2.55253]
    [2.55421]
    RemoteRepo::Ssh(ref s) => Some(s.name.as_str()),
    RemoteRepo::Local(ref l) => Some(l.name.as_str()),
    RemoteRepo::Http(ref h) => Some(h.name.as_str()),
    RemoteRepo::LocalChannel(_) => None,
  • edit in pijul/src/remote/mod.rs at line 143
    [2.56425]
    [2.56425]
    RemoteRepo::LocalChannel(_) => None,
  • replacement in pijul/src/remote/mod.rs at line 156
    [2.56691][2.56691:56739]()
    pub async fn update_changelist<T: MutTxnT>(
    [2.56691]
    [2.56739]
    pub async fn update_changelist<T: MutTxnT + TxnTExt>(
  • replacement in pijul/src/remote/mod.rs at line 160
    [2.56804][2.56804:56851]()
    ) -> Result<RemoteRef<T>, anyhow::Error> {
    [2.56804]
    [2.56851]
    ) -> Result<Option<RemoteRef<T>>, anyhow::Error> {
  • replacement in pijul/src/remote/mod.rs at line 162
    [2.56888][2.56888:56920]()
    let name = self.name();
    [2.56888]
    [2.56920]
    let name = if let Some(name) = self.name() {
    name
    } else {
    return Ok(None);
    };
  • replacement in pijul/src/remote/mod.rs at line 181
    [2.57497][2.57497:57516]()
    Ok(remote)
    [2.57497]
    [2.57516]
    Ok(Some(remote))
  • replacement in pijul/src/remote/mod.rs at line 184
    [2.57523][2.57523:57570]()
    async fn dichotomy_changelist<T: MutTxnT>(
    [2.57523]
    [2.57570]
    async fn dichotomy_changelist<T: MutTxnT + TxnTExt>(
  • replacement in pijul/src/remote/mod.rs at line 196
    [2.57913][2.57913:57976]()
    if let Some((_, s)) = self.get_state(Some(b)).await? {
    [2.57913]
    [2.57976]
    if let Some((_, s)) = self.get_state(txn, Some(b)).await? {
  • replacement in pijul/src/remote/mod.rs at line 208
    [2.58438][2.58438:58503]()
    let remote_state = self.get_state(Some(mid)).await?;
    [2.58438]
    [2.58503]
    let remote_state = self.get_state(txn, Some(mid)).await?;
  • replacement in pijul/src/remote/mod.rs at line 229
    [2.59045][2.59045:59069]()
    async fn get_state(
    [2.59045]
    [2.59069]
    async fn get_state<T: libpijul::TxnTExt>(
  • edit in pijul/src/remote/mod.rs at line 231
    [2.59088]
    [2.59088]
    txn: &T,
  • edit in pijul/src/remote/mod.rs at line 268
    [2.60604]
    [2.60604]
    RemoteRepo::LocalChannel(ref channel) => {
    if let Some(channel) = txn.load_channel(&channel) {
    Ok(local::get_state(txn, &channel, mid))
    } else {
    Ok(None)
    }
    }
  • edit in pijul/src/remote/mod.rs at line 341
    [2.63484]
    [2.63484]
    RemoteRepo::LocalChannel(_) => unreachable!(),
  • edit in pijul/src/remote/mod.rs at line 383
    [2.65082]
    [2.65082]
    RemoteRepo::LocalChannel(_) => Ok(()),
  • replacement in pijul/src/remote/mod.rs at line 388
    [2.65147][2.65147:65180]()
    pub async fn upload_changes(
    [2.65147]
    [2.65180]
    pub async fn upload_changes<T: MutTxnTExt, W: libpijul::working_copy::WorkingCopy>(
  • edit in pijul/src/remote/mod.rs at line 390
    [2.65199]
    [2.65199]
    repo: &mut W,
    txn: &mut T,
  • edit in pijul/src/remote/mod.rs at line 422
    [2.66522]
    [2.66522]
    RemoteRepo::LocalChannel(ref channel) => {
    let mut channel = txn.open_or_create_channel(channel)?;
    let store = libpijul::changestore::filesystem::FileSystem::from_changes(local);
    local::upload_changes(&store, repo, txn, &mut channel, changes)
    }
  • edit in pijul/src/remote/mod.rs at line 464
    [2.68044]
    [2.68044]
    RemoteRepo::LocalChannel(_) => {}
  • replacement in pijul/src/remote/mod.rs at line 616
    [2.73321][2.73321:73353]()
    let name = self.name();
    [2.73321]
    [2.73353]
    let name = self.name().unwrap();
  • replacement in pijul/src/remote/mod.rs at line 755
    [2.78229][2.78229:78300]()
    let remote_changes = self.update_changelist(txn, path).await?;
    [2.78229]
    [2.78300]
    let remote_changes = self
    .update_changelist(txn, path)
    .await?
    .expect("Remote is not self");
  • edit in pijul/src/remote/local.rs at line 11
    [2.80101]
    [2.80101]
    }
    pub fn get_state<T: TxnTExt>(
    txn: &T,
    channel: &libpijul::pristine::ChannelRef<T>,
    mid: Option<u64>,
    ) -> Option<(u64, Merkle)> {
    if let Some(mid) = mid {
    txn.get_changes(&channel, mid).map(|(_, m)| (mid, m))
    } else {
    txn.reverse_log(&channel.borrow(), None)
    .next()
    .map(|(n, (_, m))| (n, m))
    }
  • replacement in pijul/src/remote/local.rs at line 31
    [2.80327][2.80327:80598]()
    if let Some(mid) = mid {
    Ok(txn.get_changes(&channel, mid).map(|(_, m)| (mid, m)))
    } else {
    Ok(txn
    .reverse_log(&channel.borrow(), None)
    .next()
    .map(|(n, (_, m))| (n, m)))
    }
    [2.80327]
    [2.80598]
    Ok(get_state(&txn, &channel, mid))
  • edit in pijul/src/remote/local.rs at line 85
    [2.82503][2.82503:82557]()
    let mut ws = libpijul::ApplyWorkspace::new();
  • replacement in pijul/src/remote/local.rs at line 90
    [2.82894][2.82894:82954]()
    std::fs::hard_link(&local, &self.changes_dir)?;
    [2.82894]
    [2.82954]
    if std::fs::hard_link(&local, &self.changes_dir).is_err() {
    std::fs::copy(&local, &self.changes_dir)?;
    }
  • edit in pijul/src/remote/local.rs at line 96
    [2.83149][2.83149:83218]()
    txn.apply_change_ws(&store, &mut channel, *c, &mut ws)?;
  • replacement in pijul/src/remote/local.rs at line 98
    [2.83322][2.83322:83408]()
    txn.output_repository_no_pending(&mut repo, &store, &mut channel, "", true)?;
    [2.83322]
    [2.83408]
    upload_changes(&store, &mut repo, &mut txn, &mut channel, changes)?;
  • replacement in pijul/src/remote/local.rs at line 110
    [2.83755][2.83755:83809]()
    std::fs::hard_link(&self.changes_dir, path)?;
    [2.83755]
    [2.83809]
    if std::fs::hard_link(&self.changes_dir, path).is_err() {
    std::fs::copy(&self.changes_dir, path)?;
    }
  • edit in pijul/src/remote/local.rs at line 119
    [2.83970]
    pub fn upload_changes<
    T: MutTxnTExt,
    C: libpijul::changestore::ChangeStore,
    W: libpijul::working_copy::WorkingCopy,
    >(
    store: &C,
    repo: &mut W,
    txn: &mut T,
    channel: &mut libpijul::pristine::ChannelRef<T>,
    changes: &[Hash],
    ) -> Result<(), anyhow::Error> {
    let mut ws = libpijul::ApplyWorkspace::new();
    for c in changes {
    txn.apply_change_ws(store, channel, *c, &mut ws)?;
    }
    txn.output_repository_no_pending(repo, store, channel, "", true)?;
    Ok(())
    }
  • replacement in pijul/src/commands/pushpull.rs at line 102
    [2.114511][2.114511:114570]()
    let repo = Repository::find_root(self.repo_path)?;
    [2.114511]
    [2.114570]
    let mut repo = Repository::find_root(self.repo_path)?;
  • replacement in pijul/src/commands/pushpull.rs at line 127
    [2.115467][2.115467:115537]()
    .remote(&remote_name, remote_channel, self.no_cert_check)
    [2.115467]
    [2.115537]
    .remote(
    Some(&repo.path),
    &remote_name,
    remote_channel,
    self.no_cert_check,
    )
  • replacement in pijul/src/commands/pushpull.rs at line 155
    [2.116338][2.116338:116665]()
    if txn.remote_has_state(&remote_changes, m) {
    break;
    }
    let h_int = txn.get_internal(h).unwrap();
    if !txn.remote_has_change(&remote_changes, h) {
    if let Some(ref p) = path {
    if txn.get_touched_files(*p, Some(h_int)).is_some() {
    [2.116338]
    [2.116665]
    if let Some(ref remote_changes) = remote_changes {
    if txn.remote_has_state(remote_changes, m) {
    break;
    }
    let h_int = txn.get_internal(h).unwrap();
    if !txn.remote_has_change(&remote_changes, h) {
    if let Some(ref p) = path {
    if txn.get_touched_files(*p, Some(h_int)).is_some() {
    to_upload.push(h)
    }
    } else {
  • replacement in pijul/src/commands/pushpull.rs at line 168
    [2.116729][2.116729:116792]()
    } else {
    to_upload.push(h)
    [2.116729]
    [2.116792]
    }
    } else if let crate::remote::RemoteRepo::LocalChannel(ref remote_channel) = remote {
    if let Some(channel) = txn.load_channel(remote_channel) {
    let channel = channel.borrow();
    let h_int = txn.get_internal(h).unwrap();
    if txn.get_changeset(&channel.changes, h_int, None).is_none() {
    if let Some(ref p) = path {
    if txn.get_touched_files(*p, Some(h_int)).is_some() {
    to_upload.push(h)
    }
    } else {
    to_upload.push(h)
    }
    }
  • replacement in pijul/src/commands/pushpull.rs at line 226
    [2.117334][2.117334:117414]()
    .upload_changes(repo.changes_dir.clone(), push_channel, &to_upload)
    [2.117334]
    [2.117414]
    .upload_changes(
    &mut repo.working_copy,
    &mut txn,
    repo.changes_dir.clone(),
    push_channel,
    &to_upload,
    )
  • replacement in pijul/src/commands/pushpull.rs at line 261
    [2.118313][2.118313:118381]()
    .remote(&remote_name, from_channel, self.no_cert_check)
    [2.118313]
    [2.118381]
    .remote(
    Some(&repo.path),
    &remote_name,
    from_channel,
    self.no_cert_check,
    )
  • replacement in pijul/src/commands/pushpull.rs at line 271
    [2.118489][2.118489:118578]()
    let paths = if let Some(p) = self.path {
    vec![p.to_string()]
    [2.118489]
    [2.118578]
    let mut paths = if let Some(p) = self.path {
    vec![p]
  • replacement in pijul/src/commands/pushpull.rs at line 279
    [2.118806][2.118806:119084]()
    for (_, (h, m)) in txn.iter_remote(&remote_changes.borrow().remote, 0) {
    if txn.channel_has_state(&channel, m) {
    break;
    } else if txn.get_revchanges(&channel, h).is_none() {
    to_download.push(h)
    [2.118806]
    [2.119084]
    if let Some(ref remote_changes) = remote_changes {
    for (_, (h, m)) in txn.iter_remote(&remote_changes.borrow().remote, 0) {
    if txn.channel_has_state(&channel, m) {
    break;
    } else if txn.get_revchanges(&channel, h).is_none() {
    to_download.push(h)
    }
    }
    } else if let crate::remote::RemoteRepo::LocalChannel(ref remote_channel) = remote {
    let path = if let Some(path) = paths.pop() {
    let (p, ambiguous) = txn.follow_oldest_path(&repo.changes, &channel, &path)?;
    if ambiguous {
    return Err((crate::Error::AmbiguousPath { path: path.clone() }).into());
    }
    Some(p)
    } else {
    None
    };
    if let Some(remote_channel) = txn.load_channel(remote_channel) {
    let remote_channel = remote_channel.borrow();
    for (_, (h, m)) in txn.reverse_log(&remote_channel, None) {
    if txn.channel_has_state(&channel, m) {
    break;
    }
    let h_int = txn.get_internal(h).unwrap();
    if txn
    .get_changeset(&channel.borrow().changes, h_int, None)
    .is_none()
    {
    if let Some(ref p) = path {
    if txn.get_touched_files(*p, Some(h_int)).is_some() {
    to_download.push(h)
    }
    } else {
    to_download.push(h)
    }
    }
    }
  • replacement in pijul/src/commands/clone.rs at line 31
    [2.183896][2.183896:183995]()
    crate::remote::unknown_remote(&self.remote, &self.channel, self.no_cert_check).await?;
    [2.183896]
    [2.183995]
    crate::remote::unknown_remote(None, &self.remote, &self.channel, self.no_cert_check)
    .await?;
  • replacement in pijul/src/commands/archive.rs at line 27
    [2.191803][2.191803:191861]()
    pub async fn run(self) -> Result<(), anyhow::Error> {
    [2.191803]
    [2.191861]
    pub async fn run(mut self) -> Result<(), anyhow::Error> {
  • edit in pijul/src/commands/archive.rs at line 41
    [2.192281]
    [2.192281]
    None,
  • replacement in pijul/src/commands/archive.rs at line 51
    [2.192546][2.192546:192710]()
    let mut p = std::path::Path::new(&self.name).to_path_buf();
    if !self.name.ends_with(".tar.gz") {
    p.set_extension("tar.gz");
    [2.192546]
    [2.192710]
    if let crate::remote::RemoteRepo::LocalChannel(_) = remote {
    if let Some(ref mut path) = self.repo_path {
    path.clear();
    path.push(rem);
    }
    } else {
    let mut p = std::path::Path::new(&self.name).to_path_buf();
    if !self.name.ends_with(".tar.gz") {
    p.set_extension("tar.gz");
    }
    let mut f = std::fs::File::create(&p)?;
    remote
    .archive(self.prefix, state.map(|x| (x, &extra[..])), &mut f)
    .await?;
    return Ok(());
  • replacement in pijul/src/commands/archive.rs at line 67
    [2.192724][2.192724:192979]()
    let mut f = std::fs::File::create(&p)?;
    remote
    .archive(self.prefix, state.map(|x| (x, &extra[..])), &mut f)
    .await?;
    } else if let Ok(repo) = Repository::find_root(self.repo_path.clone()) {
    [2.192724]
    [2.192979]
    }
    if let Ok(repo) = Repository::find_root(self.repo_path.clone()) {