hgcompat.py
88 lines
| 3.1 KiB
| text/x-python
|
PythonLexer
/ vcsserver / hgcompat.py
r0 | # RhodeCode VCSServer provides access to different vcs backends via network. | |||
r1126 | # Copyright (C) 2014-2023 RhodeCode GmbH | |||
r0 | # | |||
# This program is free software; you can redistribute it and/or modify | ||||
# it under the terms of the GNU General Public License as published by | ||||
# the Free Software Foundation; either version 3 of the License, or | ||||
# (at your option) any later version. | ||||
# | ||||
# This program is distributed in the hope that it will be useful, | ||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | ||||
# | ||||
# You should have received a copy of the GNU General Public License | ||||
# along with this program; if not, write to the Free Software Foundation, | ||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
""" | ||||
Mercurial libs compatibility | ||||
""" | ||||
import mercurial | ||||
r310 | from mercurial import demandimport | |||
r1042 | ||||
r0 | # patch demandimport, due to bug in mercurial when it always triggers | |||
# demandimport.enable() | ||||
r1060 | from vcsserver.str_utils import safe_bytes | |||
r1050 | ||||
r310 | demandimport.enable = lambda *args, **kwargs: 1 | |||
r0 | ||||
from mercurial import ui | ||||
from mercurial import patch | ||||
from mercurial import config | ||||
from mercurial import extensions | ||||
from mercurial import scmutil | ||||
from mercurial import archival | ||||
from mercurial import discovery | ||||
from mercurial import unionrepo | ||||
from mercurial import localrepo | ||||
from mercurial import merge as hg_merge | ||||
Martin Bornhold
|
r97 | from mercurial import subrepo | ||
r718 | from mercurial import subrepoutil | |||
r274 | from mercurial import tags as hg_tag | |||
r894 | from mercurial import util as hgutil | |||
r1042 | from mercurial.commands import clone, pull | |||
from mercurial.node import nullid | ||||
r0 | from mercurial.context import memctx, memfilectx | |||
from mercurial.error import ( | ||||
LookupError, RepoError, RepoLookupError, Abort, InterventionRequired, | ||||
r657 | RequirementError, ProgrammingError) | |||
r0 | from mercurial.hgweb import hgweb_mod | |||
r656 | from mercurial.localrepo import instance | |||
r894 | from mercurial.match import match, alwaysmatcher, patternmatcher | |||
r0 | from mercurial.mdiff import diffopts | |||
from mercurial.node import bin, hex | ||||
from mercurial.encoding import tolocal | ||||
from mercurial.discovery import findcommonoutgoing | ||||
from mercurial.hg import peer | ||||
r457 | from mercurial.httppeer import makepeer | |||
r1042 | from mercurial.utils.urlutil import url as hg_url | |||
r657 | from mercurial.scmutil import revrange, revsymbol | |||
r0 | from mercurial.node import nullrev | |||
from mercurial import exchange | ||||
from hgext import largefiles | ||||
# those authnadlers are patched for python 2.6.5 bug an | ||||
# infinit looping when given invalid resources | ||||
from mercurial.url import httpbasicauthhandler, httpdigestauthhandler | ||||
r660 | ||||
r1042 | # hg strip is in core now | |||
from mercurial import strip as hgext_strip | ||||
r660 | ||||
def get_ctx(repo, ref): | ||||
r1107 | if not isinstance(ref, int): | |||
ref = safe_bytes(ref) | ||||
r660 | try: | |||
ctx = repo[ref] | ||||
r938 | except (ProgrammingError, TypeError): | |||
r660 | # we're unable to find the rev using a regular lookup, we fallback | |||
# to slower, but backward compat revsymbol usage | ||||
ctx = revsymbol(repo, ref) | ||||
r823 | except (LookupError, RepoLookupError): | |||
# Similar case as above but only for refs that are not numeric | ||||
r1044 | if isinstance(ref, int): | |||
r823 | raise | |||
ctx = revsymbol(repo, ref) | ||||
r660 | return ctx | |||