##// END OF EJS Templates
interfaces: mark `completelocalrepository` as a Protocol class...
interfaces: mark `completelocalrepository` as a Protocol class This is just for completeness, since everything else in here is explicitly marked. The *.pyi file generated for this module is unchanged, because this class currently has no methods or attrs of its own (other than `__doc__`). With this, the odyssey of converting the zope interfaces to Protocol classes is complete. There's a little bit of mopping up in making sure the previously converted Protocols use `@abc.abstractmethod` where appropriate, but that can be deferred for now.

File last commit:

r52756:f4733654 default
r53397:3abf9bc1 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)