Mercurial > public > mercurial-scm > hg-stable
diff mercurial/interfaces/misc.py @ 52908:180591a9a6a1
typing: add a protocol for `urlutil.path`
That is the last external import for the repository interface module.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 10 Feb 2025 00:16:22 +0100 |
parents | ba343f763595 |
children |
line wrap: on
line diff
--- a/mercurial/interfaces/misc.py Mon Feb 10 00:15:22 2025 +0100 +++ b/mercurial/interfaces/misc.py Mon Feb 10 00:16:22 2025 +0100 @@ -7,6 +7,7 @@ from typing import ( Callable, + Dict, Iterator, List, Optional, @@ -108,3 +109,41 @@ @abc.abstractmethod def islocal(self) -> bool: ... + + +class IPath(Protocol): + """Represents an individual path and its configuration.""" + + name: bytes + main_path: Optional[IPath] + url: IUrl + raw_url: IUrl + branch: bytes + rawloc: bytes + loc: bytes + + @abc.abstractmethod + def copy(self, new_raw_location: Optional[bytes] = None) -> IPath: + ... + + @property + @abc.abstractmethod + def is_push_variant(self) -> bool: + """is this a path variant to be used for pushing""" + + @abc.abstractmethod + def get_push_variant(self) -> IPath: + """get a "copy" of the path, but suitable for pushing + + This means using the value of the `pushurl` option (if any) as the url. + + The original path is available in the `main_path` attribute. + """ + + @property + @abc.abstractmethod + def suboptions(self) -> Dict[bytes, bytes]: + """Return sub-options and their values for this path. + + This is intended to be used for presentation purposes. + """