typing: add type hints related to message output in mercurial/ui.py
This will shake loose some bytes vs str issues in the doc checker.
typing: add type hints related to progress bars in mercurial/ui.py
Pretty low hanging fruit while trying to deal with other more complicated parts
of this module.
pytype: stop excluding mercurial/ui.py
ui.extractchoices() is perhaps making assumptions that it shouldn't about the
pattern always matching, but presumably we have test coverage for that.
PyCharm flags the updated classes with a warning "Class xxx must implement all
abstract methods", and suggests adding `abc.ABC` to the superclasses. I'm not
sure why, unless it doesn't recognize the `__getattr__()` delegation pattern.
Additionally, we can't unconditionally subclass `typing.BinaryIO` because that
defeats the `__getattr__` delegation to the wrapped object at runtime. Instead,
it has to only subclass during the type checking phase[1].
In any event, this fixes:
File "/mnt/c/Users/Matt/hg/mercurial/ui.py", line 1518, in _runpager:
Function subprocess.Popen.__new__ was called with the wrong arguments [wrong-arg-types]
Expected: (cls, args, bufsize, executable, stdin,
stdout: Optional[Union[IO, int]] = ..., ...)
Actually passed: (cls, args, bufsize, stdin,
stdout: Union[mercurial.utils.procutil.WriteAllWrapper,
mercurial.windows.winstdout], ...)
File "/mnt/c/Users/Matt/hg/mercurial/ui.py", line 1798, in extractchoices:
No attribute 'group' on None [attribute-error]
In Optional[Match[bytes]]
File "/mnt/c/Users/Matt/hg/mercurial/ui.py", line 1799, in extractchoices:
No attribute 'group' on None [attribute-error]
In Optional[Match[bytes]]
[1] https://stackoverflow.com/q/
71365594
hghave: detect newer pylint
Older versions (e.g. 2.7.2) say: "Usage: pylint [options]"
Newer versions (e.g. 2.15.5) say: "usage: pylint [options]"
emitrevision: consider ancestors revision to emit as available base
This should make more delta base valid. This notably affects:
* case where we skipped some parent with empty delta to directly delta against
an ancestors
* case where an intermediate snapshots is stored.
This change means we could sent largish intermediate snapshots over the wire.
However this is actually a sub goal here. Sending snapshots over the wire means
the client have a high odd of simply storing the pre-computed delta instead of
doing a lengthy process that will… end up doing the same intermediate snapshot.
In addition the overall size of snapshot (or any level) is "only" some or the
overall delta size. (0.17% for my mercurial clone, 20% for my clone of Mozilla
try). So Sending them other the wire is unlikely to change large impact on the
bandwidth used.
If we decide that minimising the bandwidth is an explicit goal, we should
introduce new logic to filter-out snapshot as delta. The current code has no
notion explicite of snapshot so far, they just tended to fall into the wobbly
filtering options.
In some cases, this patch can yield large improvement to the bundling time:
### data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog
# benchmark.name = perf-bundle
# benchmark.variants.revs = last-100000
before: 68.787066 seconds
after: 47.552677 seconds (-30.87%)
That translate to large improvement to the pull time :
### data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog
# benchmark.name = pull
# benchmark.variants.
issue6528 = disabled
# benchmark.variants.revs = last-100000
before: 142.186625 seconds
after: 75.897745 seconds (-46.62%)
No significant negative impact have been observed.
sqlitestore: add an `ancestors` method
We will need it during bundling.
The implementation mirror the one in revlog.
emitrevision: if we need to compute a delta on the fly, try p1 or p2 first
Falling back to `prev` does not yield any real value on modern storage and
result in pathological changes to be created on the other side. Doing a delta
against a parent will likely be smaller (helping the network) and will be safer
to apply on the client (helping future pulls by Triggering intermediate
snapshop where they will be needed by later deltas).
emitrevision: simplify the fallback to computed delta
Not using the stored delta, or having a full snapshot on disk behave the same
ways, so lets use the same code path for that, this is simpler, and it update
will be simpler.
emitrevision: also check the parents in the availability closure
One of the point of having a closure is to gather the logic in it. So we gather
the logic.
The `parents[:]` part is a bit ugly but will be replaced by better code soon
anyway.