encoding: fix trim() to be O(n) instead of O(n^2)
`encoding.trim()` iterated over the possible lengths smaller than the
input and created a slice for each. It then calculated the column
width of the result, which is of course O(n), so the overall algorithm
was O(n). This patch rewrites it to iterate over the unicode
characters, keeping track of the length so far. Also, the old
algorithm started from the end of the string, which made it much worse
when the input is large and the limit is small (such as the typical 72
we pass to it).
You can time it by running something like this:
```
time python3 -c 'from mercurial.utils import stringutil; print(stringutil.ellipsis(b"0123456789" * 1000, 5))'
```
That drops from 4.05 s to 83 ms with this patch (and most of that is
of course startup time).
Differential Revision: https://phab.mercurial-scm.org/D12089
== New Features ==
== Default Format Change ==
These changes affects newly created repositories (or new clone) done with
Mercurial 6.1.
The `share-safe` format variant is now enabled by default. It makes
configuration and requirements more consistent across repository and their
shares. This introduces a behavior change as shares from a repository using the
new format will also use their main repository's configuration.
See `hg help config.format.use-share-safe` for details about the feature and
the available options for auto-upgrading existing shares.
== New Experimental Features ==
== Bug Fixes ==
The `--no-check` and `--no-merge` now properly overwrite the behavior from `commands.update.check`.
== Backwards Compatibility Changes ==
The remotefilelog extension now requires an appropiate excludepattern
for subrepositories.
The labels passed to merge tools have changed slightly. Merge tools can get
labels passed to them if you include `$labellocal`, `$labelbase`, and/or
`$labelother` in the `merge-tool.<tool name>.args` configuration. These labels
used to have some space-padding, and truncation to fit within 72 columns. Both
the padding and the truncation has been removed.
Some of the text in labels passed to merge tools has changed. For example,
in conflicts while running `hg histedit`, the labels used to be "local",
"base", and "histedit". They are now "already edited",
"parent of current change", and "current change", respectively.
The use of `share-safe`, means shares (of new repositories) will also use their
main repository's configuration see the `Default Format Change` section
for details.
== Internal API Changes ==
The following functions have been removed:
Miscellaneous: