Printing patches to the terminal


#1

I just pushed a new experimental patch to print patches to the terminal.

This is better than the current Nest, as it knows line numbers.
For this reason, it is very likely to be refactored soon into a more general solution.

Along with tags, I believe this was the main missing feature for a serious use of Pijul.


#2

That sounds awesome - thank you so much, that has been high on my wishlist :slight_smile: I’ll check it out.


#3

It looks like there is an issue with the thrussh versions.


#4

I thought I had been careful with this :frowning:

What I did was, I noticed that the Nest was requiring exclusive access to repositories even when reading, even though only commits should require it, and with future versions of Sanakirja this might not even be always necessary.

Since the Nest runs on a relatively small machine, this was causing scaling issues, so I changed it, but noticed in the process that users of Thrussh could sometimes want to share SSH sessions between threads.

This forced me to replace a number of Rc with Arc, and I incremented the version number of Thrussh to 0.16 because Pijul had to be changed.

So, what is the problem exactly?


#5

There are several issues.

Cloning pijul from upstream, I did the following:

error[E0599]: no function or associated item named `new_nolock` found for type `sanakirja::Env` in the current scope
   --> /home/lethom/Repos/ppijul/libpijul/src/backend/mod.rs:199:30
    |
199 |         Ok(Repository { env: sanakirja::Env::new_nolock(path, size)? })
    |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no method named `close` found for type `sanakirja::Env` in the current scope
   --> /home/lethom/Repos/ppijul/libpijul/src/backend/mod.rs:204:18
    |
204 |         self.env.close()
    |                  ^^^^^

error: aborting due to 2 previous errors

error: Could not compile `libpijul`.
warning: build failed, waiting for other jobs to finish...
error: build failed

I thought it might be related to an outdated Cargo.lock, so:

λ cargo update                                                                                                                                                                                                                   master pijul
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating atty v0.2.2 -> v0.2.3
    Updating either v1.1.0 -> v1.2.0
    Updating hyper v0.11.2 -> v0.11.4
    Updating lazy_static v0.2.8 -> v0.2.9
    Updating num_cpus v1.6.2 -> v1.7.0
      Adding relay v0.1.0
    Updating sanakirja v0.8.13 -> v0.8.14
      Adding thrussh v0.16.0
    Updating thrussh-keys v0.7.0 -> v0.7.1
λ cargo build --release                                                                                                                                                                                                          master pijul
   Compiling libpijul v0.8.1 (file:///home/lethom/Repos/ppijul/libpijul)
   Compiling pijul v0.8.0 (file:///home/lethom/Repos/ppijul/pijul)
warning: unused import: `std::str`
 --> src/commands/changes.rs:9:5
  |
9 | use std::str;
  |     ^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

error[E0308]: mismatched types
   --> src/commands/remote.rs:215:75
    |
215 |         match thrussh_keys::check_known_hosts_path(&self.host, self.port, server_public_key, &path) {
    |                                                                           ^^^^^^^^^^^^^^^^^ expected enum `thrussh::key::PublicKey`, found a different enum `thrussh::key::PublicKey`
    |
    = note: expected type `&thrussh::key::PublicKey` (enum `thrussh::key::PublicKey`)
               found type `&thrussh::key::PublicKey` (enum `thrussh::key::PublicKey`)
note: Perhaps two different versions of crate `thrussh` are being used?
   --> src/commands/remote.rs:215:75
    |
215 |         match thrussh_keys::check_known_hosts_path(&self.host, self.port, server_public_key, &path) {
    |                                                                           ^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> src/commands/remote.rs:228:58
    |
228 |                                                          server_public_key,
    |                                                          ^^^^^^^^^^^^^^^^^ expected enum `thrussh::key::PublicKey`, found a different enum `thrussh::key::PublicKey`
    |
    = note: expected type `&thrussh::key::PublicKey` (enum `thrussh::key::PublicKey`)
               found type `&thrussh::key::PublicKey` (enum `thrussh::key::PublicKey`)
note: Perhaps two different versions of crate `thrussh` are being used?
   --> src/commands/remote.rs:228:58
    |
228 |                                                          server_public_key,
    |                                                          ^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> src/commands/remote.rs:749:33
    |
749 |                                 config.clone(),
    |                                 ^^^^^^^^^^^^^^ expected struct `std::rc::Rc`, found struct `std::sync::Arc`
    |
    = note: expected type `std::rc::Rc<thrussh::client::Config>`
               found type `std::sync::Arc<thrussh::client::Config>`

error[E0308]: mismatched types
   --> src/commands/remote.rs:788:23
    |
788 |         Ok(key) => Ok(key),
    |                       ^^^ expected enum `thrussh::key::Algorithm`, found a different enum `thrussh::key::Algorithm`
    |
    = note: expected type `thrussh::key::Algorithm` (enum `thrussh::key::Algorithm`)
               found type `thrussh::key::Algorithm` (enum `thrussh::key::Algorithm`)
note: Perhaps two different versions of crate `thrussh` are being used?
   --> src/commands/remote.rs:788:23
    |
788 |         Ok(key) => Ok(key),
    |                       ^^^

error[E0308]: match arms have incompatible types
   --> src/commands/remote.rs:794:31
    |
794 |                       return Ok(thrussh_keys::load_secret_key(
    |  _______________________________^
795 | |                         path_sec.to_str().unwrap(),
796 | |                         Some(password.as_bytes()),
797 | |                         path_pub.as_ref().map(|x| x.as_path())
798 | |                     )?)
    | |______________________^ expected enum `thrussh::key::Algorithm`, found a different enum `thrussh::key::Algorithm`
    |
    = note: expected type `thrussh::key::Algorithm` (enum `thrussh::key::Algorithm`)
               found type `thrussh::key::Algorithm` (enum `thrussh::key::Algorithm`)
note: match arm with an incompatible type
   --> src/commands/remote.rs:794:31
    |
794 |                       return Ok(thrussh_keys::load_secret_key(
    |  _______________________________^
795 | |                         path_sec.to_str().unwrap(),
796 | |                         Some(password.as_bytes()),
797 | |                         path_pub.as_ref().map(|x| x.as_path())
798 | |                     )?)
    | |______________________^
note: Perhaps two different versions of crate `thrussh` are being used?
   --> src/commands/remote.rs:794:31
    |
794 |                       return Ok(thrussh_keys::load_secret_key(
    |  _______________________________^
795 | |                         path_sec.to_str().unwrap(),
796 | |                         Some(password.as_bytes()),
797 | |                         path_pub.as_ref().map(|x| x.as_path())
798 | |                     )?)
    | |______________________^

error[E0308]: mismatched types
   --> src/commands/keys.rs:120:59
    |
120 |                         connection.authenticate_key(user, key)
    |                                                           ^^^ expected enum `thrussh::key::Algorithm`, found a different enum `thrussh::key::Algorithm`
    |
    = note: expected type `thrussh::key::Algorithm` (enum `thrussh::key::Algorithm`)
               found type `thrussh::key::Algorithm` (enum `thrussh::key::Algorithm`)
note: Perhaps two different versions of crate `thrussh` are being used?
   --> src/commands/keys.rs:120:59
    |
120 |                         connection.authenticate_key(user, key)
    |                                                           ^^^

error[E0308]: mismatched types
   --> src/commands/keys.rs:177:75
    |
177 |         match thrussh_keys::check_known_hosts_path(&self.host, self.port, &server_public_key, &path) {
    |                                                                           ^^^^^^^^^^^^^^^^^^ expected enum `thrussh::key::PublicKey`, found reference
    |
    = note: expected type `&thrussh::key::PublicKey`
               found type `&&thrussh::key::PublicKey`

error[E0308]: mismatched types
   --> src/commands/keys.rs:186:58
    |
186 |                                                          &server_public_key,
    |                                                          ^^^^^^^^^^^^^^^^^^ expected enum `thrussh::key::PublicKey`, found reference
    |
    = note: expected type `&thrussh::key::PublicKey`
               found type `&&thrussh::key::PublicKey`

error: aborting due to 8 previous errors

error: Could not compile `pijul`.

To learn more, run the command again with --verbose.

Note that: thrussh is still 0.15.3 in pijul/Cargo.toml. If I try to update it in Cargo.toml, I am getting this:

λ cargo build --release                                                                                                                                                                                                          master pijul
   Compiling libpijul v0.8.1 (file:///home/lethom/Repos/ppijul/libpijul)
   Compiling pijul v0.8.0 (file:///home/lethom/Repos/ppijul/pijul)
warning: unused import: `std::str`
 --> src/commands/changes.rs:9:5
  |
9 | use std::str;
  |     ^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

error[E0308]: mismatched types
   --> src/commands/keys.rs:118:42
    |
118 |                     (server, args.port), config, None, client,
    |                                          ^^^^^^ expected struct `std::sync::Arc`, found struct `std::rc::Rc`
    |
    = note: expected type `std::sync::Arc<thrussh::client::Config>`
               found type `std::rc::Rc<thrussh::client::Config>`

error: aborting due to previous error

error: Could not compile `pijul`.

To learn more, run the command again with --verbose.


#6

Alright, I forgot to add the patch to update versions. Since I’m in the middle of writing the base58 thing, I can’t push.