It always annoyed me that preferences like force require a complete root specification. When your root looks like ssh://user@host.domain.com:port//a/long/path/to/the/actual/root/and/then/some, you need to copy this whole thing to every single force, prefer, ... (there are many preferences like this) preference value, and it has to match exactly.
This patch makes all those preferences accept a substring of the root to identify it. To identify a root, the following unique substrings are allowed:
an exact prefix or suffix of any length of a root's path
an exact prefix of any length of a remote root's hostname
Examples:
with roots /a/long/path/to/source and /path/to/backup you can specify force=source or force=/a to force the first root and force=backupto force the second root.
with root ssh://user@host.domain.com:port//a/long/path/to/the/actual/root/and/then/some you can simply specify force=host
with roots root1 and root2 you can specify force=1 or force=2
Note that a prefix or suffix of an arbitrary length is accepted, so the examples above would also work with longer and shorter values, as long as one of the roots is uniquely identified.
This PR contains another change. Partially to remove any negative performance impacts caused by the substring matching, partially an improvement in its own right, results of two recurring operations are cached (the first two commits). Without this patch, clroots and values of force, prefer, ... preferences were reparsed every single time they were needed.
(For reviewers: actual code changes are rather small; much of the diff is due to doc changes.)
It always annoyed me that preferences like
force
require a complete root specification. When your root looks likessh://user@host.domain.com:port//a/long/path/to/the/actual/root/and/then/some
, you need to copy this whole thing to every singleforce
,prefer
, ... (there are many preferences like this) preference value, and it has to match exactly.This patch makes all those preferences accept a substring of the root to identify it. To identify a root, the following unique substrings are allowed:
Examples:
/a/long/path/to/source
and/path/to/backup
you can specifyforce=source
orforce=/a
to force the first root andforce=backup
to force the second root.ssh://user@host.domain.com:port//a/long/path/to/the/actual/root/and/then/some
you can simply specifyforce=host
root1
androot2
you can specifyforce=1
orforce=2
Note that a prefix or suffix of an arbitrary length is accepted, so the examples above would also work with longer and shorter values, as long as one of the roots is uniquely identified.
This PR contains another change. Partially to remove any negative performance impacts caused by the substring matching, partially an improvement in its own right, results of two recurring operations are cached (the first two commits). Without this patch, clroots and values of
force
,prefer
, ... preferences were reparsed every single time they were needed.(For reviewers: actual code changes are rather small; much of the diff is due to doc changes.)