##// END OF EJS Templates
interfaces: move peer `capabilities()` to the `ipeercapabilities` interface...
interfaces: move peer `capabilities()` to the `ipeercapabilities` interface I'm not sure why this was on the `ipeercommands` interface. It appears to be because these interfaces started out as `_basewirecommands` to hold wire commands, back in 558f5b2ee10e. The capabilities interface wasn't split out until 98861a2298b5, when it pulled the capability related methods off of the `ipeerbase` interface. Perhaps it was an oversight to not look at the commands interface because, while this is a wire command, both `sshpeer` and `httppeer` now perform a handshake while instantiating the peer object, and cache a fixed list of capabilities in that object. Likewise, `localpeer` is given a fixed set of capabilities when instantiated. Back in 558f5b2ee10e, `httppeer` looks like it issued a wire command when this method was called, but `sshpeer` obtained and cached the capabilities when instantiated, and this method always returned a fixed value. There's a perfectly good interface with other capability related methods, and having it here makes it easier to implement the base `peer` mixin class.

File last commit:

r52756:f4733654 default
r53417:1554bd50 default
Show More
txnutil.py
33 lines | 978 B | text/x-python | PythonLexer
# txnutil.py - transaction related utilities
#
# Copyright FUJIWARA Katsunori <foozy@lares.dti.ne.jp> and others
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import annotations
from . import encoding
def mayhavepending(root):
"""return whether 'root' may have pending changes, which are
visible to this process.
"""
return root == encoding.environ.get(b'HG_PENDING')
def trypending(root, vfs, filename, **kwargs):
"""Open file to be read according to HG_PENDING environment variable
This opens '.pending' of specified 'filename' only when HG_PENDING
is equal to 'root'.
This returns '(fp, is_pending_opened)' tuple.
"""
if mayhavepending(root):
try:
return (vfs(b'%s.pending' % filename, **kwargs), True)
except FileNotFoundError:
pass
return (vfs(filename, **kwargs), False)