filemerge: make last line of prompts <40 english chars (
issue6158)
I've chosen <40 as the target so that other languages that may have a 2x blowup
in character count can still have a chance to fit into an 80 column screen.
Previously, we would show a prompt like:
```
keep (l)ocal [dest], take (o)ther [source], or leave (u)nresolved for some/potentially/really/long/path?
```
On at least some systems, if readline was in use then the last line of the
prompt would be wrapped strangely if it couldn't fit entirely on one line. This
strange wrapping may be just a carriage return without a line feed, overwriting
the beginning of the line; example (100 columns wide, 65 character filename, and
yes there's 10 spaces on the end, I assume this is to handle the user inputting
longest word we provide as an option, "unresolved"):
```
ng/dir/name/that/does/not/work/well/with/readline/file.txt? ave (u)nresolved for some/lon
```
In some cases it may partially wrap onto the next line, but still be missing
earlier parts in the line, such as below (60 columns wide, 65 character
filename):
```
rev], or leave (u)nresolved for some/long/dir/name/that/do
s/not/work/well/with/readline/file.txt?
```
With this fix, this looks like this on a 60 column screen:
```
tool vim_with_markers (for pattern some/long/dir/name/that/d
oes/not/work/well/with/readline/file.txt) can't handle binar
y
tool meld can't handle binary
tool vim_with_markers can't handle binary
tool internal:merge3 can't handle binary
tool merge can't handle binary
no tool found to merge some/long/dir/name/that/does/not/work
/well/with/readline/file.txt
file 'some/long/dir/name/that/does/not/work/well/with/readli
ne/file.txt' needs to be resolved.
You can keep (l)ocal [working copy], take (o)ther [merge rev
], or leave (u)nresolved.
What do you want to do?
```
Differential Revision: https://phab.mercurial-scm.org/D6562
Added signature for changeset
97ada9b8d51b
Added tag 5.0.2 for changeset
97ada9b8d51b
posix: always seek to EOF when opening a file in append mode
Python 3 already does this, so skip it there.
Consider the program:
#include <stdio.h>
int main() {
FILE *f = fopen("narf", "w");
fprintf(f, "narf\n");
fclose(f);
f = fopen("narf", "a");
printf("%ld\n", ftell(f));
fprintf(f, "troz\n");
printf("%ld\n", ftell(f));
return 0;
}
on macOS, FreeBSD, and Linux with glibc, this program prints
5
10
but on musl libc (Alpine Linux and probably others) this prints
0
10
By my reading of
https://pubs.opengroup.org/onlinepubs/
009695399/functions/fopen.html
this is technically correct, specifically:
> Opening a file with append mode (a as the first character in the
> mode argument) shall cause all subsequent writes to the file to be
> forced to the then current end-of-file, regardless of intervening
> calls to fseek().
in other words, the file position doesn't really matter in append-mode
files, and we can't depend on it being at all meaningful unless we
perform a seek() before tell() after open(..., 'a'). Experimentally
after a .write() we can do a .tell() and it'll always be reasonable,
but I'm unclear from reading the specification if that's a smart thing
to rely on. This matches what we do on Windows and what Python 3 does
for free, so let's just be consistent. Thanks to Yuya for the idea.
tweakdefaults: make hg resolve require --re-merge flag to re-merge
Pulkit suggested it in https://phab.mercurial-scm.org/D4379, and a
discussion with Octobus people reminded me that people still use the
error-prone default behavior of `hg resolve`.
Differential Revision: https://phab.mercurial-scm.org/D6610
unshelve: rename _dounshelve() to dounshelve()
This is a follow-up patch to
3de4f17f4824.
Differential Revision: https://phab.mercurial-scm.org/D6605
rust: remove Deref in favor of explicit methods
Differential Revision: https://phab.mercurial-scm.org/D6593