# Printing patches to the terminal

**URL:** <https://discourse.pijul.org/t/printing-patches-to-the-terminal/96>\
**Category:** Announcements\
**Created:** [October 2, 2017, 4:44am UTC](https://discourse.pijul.org/t/printing-patches-to-the-terminal/96 "2017-10-02T04:44:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [October 2, 2017, 4:44am UTC](https://discourse.pijul.org/t/printing-patches-to-the-terminal/96/1 "2017-10-02T04:44:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![laumann](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/laumann/32/8_2.png) [@laumann](https://discourse.pijul.org/u/laumann)\
**Post date:** [October 2, 2017, 7:59am UTC](https://discourse.pijul.org/t/printing-patches-to-the-terminal/96/2 "2017-10-02T07:59:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [October 2, 2017, 7:59am UTC](https://discourse.pijul.org/t/printing-patches-to-the-terminal/96/3 "2017-10-02T07:59:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [October 2, 2017, 8:20am UTC](https://discourse.pijul.org/t/printing-patches-to-the-terminal/96/4 "2017-10-02T08:20:17Z")

</div>

> [@lthms](#):
>
> It looks like there is an issue with the thrussh versions.

I thought I had been careful with this ☹

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?

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [October 2, 2017, 8:41am UTC](https://discourse.pijul.org/t/printing-patches-to-the-terminal/96/5 "2017-10-02T08:41:13Z")

</div>

There are several issues.

Cloning pijul from upstream, I did the following:

```bash
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:

```bash
λ 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`](https://nest.pijul.com/pijul_org/pijul:master/b69e09cf58f63c468024). If I try to update it in `Cargo.toml`, I am getting this:

```bash
λ 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.

```

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [October 2, 2017, 9:09am UTC](https://discourse.pijul.org/t/printing-patches-to-the-terminal/96/6 "2017-10-02T09:09:39Z")

</div>

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.
