Without this check, linking an entry with itself yields the following
error:
ERROR[ 1]: Entry is already borrowed: StoreId { base: Some("/home/m/.imag/store"), id: "notes/test" }
ERROR[ 2]: Error when calling retrieve() -- caused:
ERROR[ 3]: Error when calling get()
Which is semantically correct, but the user may get confused by that.
Instead, we print a nice error message that the entry cannot be linked
to itself.
This is not fixed in libimagentrylink itself, because libimagentrylink
cannot be called for the same entry.
If this would be possible, we would pass two `Entry` objects
mutably to the link functionality routines. This is not possible with
Rusts borrow semantics and therefor yields above error.
We compare strings to check whether the user accidentially linked an
entry with itself because we cannot get StoreIds from Entries because we
cannot get the Entry two times from the store in the first place. So
this is the best we have.
This patch is a rewrite for the imag-link commandline to automatically
recognize whether an internal or an external link is about to be made
and automatically do the right thing.
The commandline got a lot easier and also smaller in size (as in number
of commands), but the functionality should remain the same.
This patch removes unused crate imports reported by newer rust versions.
Some crates were only required for tests, some only for tests with
macro_import - these things were fixed with feature gates.