##// END OF EJS Templates
Closing branch: `python3`
Closing branch: `python3`

File last commit:

r1126:f96985cd python3
r1253:a71b3ca1 python3
Show More
hgpatches.py
134 lines | 4.5 KiB | text/x-python | PythonLexer
initial commit
r0 # RhodeCode VCSServer provides access to different vcs backends via network.
source-code: updated copyrights to 2023
r1126 # Copyright (C) 2014-2023 RhodeCode GmbH
initial commit
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
"""
Adjustments to Mercurial
Intentionally kept separate from `hgcompat` and `hg`, so that these patches can
be applied without having to import the whole Mercurial machinery.
Imports are function local, so that just importing this module does not cause
side-effects other than these functions being defined.
"""
import logging
def patch_largefiles_capabilities():
"""
Patches the capabilities function in the largefiles extension.
"""
from vcsserver import hgcompat
lfproto = hgcompat.largefiles.proto
wrapper = _dynamic_capabilities_wrapper(
lfproto, hgcompat.extensions.extensions)
hg: fixed code after version upgrade to 4.6.0 release
r432 lfproto._capabilities = wrapper
initial commit
r0
def _dynamic_capabilities_wrapper(lfproto, extensions):
hg: fixed code after version upgrade to 4.6.0 release
r432 wrapped_capabilities = lfproto._capabilities
initial commit
r0 logger = logging.getLogger('vcsserver.hg')
hg: fixed code after version upgrade to 4.6.0 release
r432 def _dynamic_capabilities(orig, repo, proto):
initial commit
r0 """
Adds dynamic behavior, so that the capability is only added if the
extension is enabled in the current ui object.
"""
if 'largefiles' in dict(extensions(repo.ui)):
logger.debug('Extension largefiles enabled')
calc_capabilities = wrapped_capabilities
hg: fixed code after version upgrade to 4.6.0 release
r432 return calc_capabilities(orig, repo, proto)
initial commit
r0 else:
logger.debug('Extension largefiles disabled')
hg: fixed code after version upgrade to 4.6.0 release
r432 return orig(repo, proto)
initial commit
r0
return _dynamic_capabilities
Martin Bornhold
subrepo: Add patch to turn off mercurial subrepo handling.
r97
def patch_subrepo_type_mapping():
from collections import defaultdict
py3: import/code fixes
r987 from .hgcompat import subrepo, subrepoutil
imports: fixed usage of exceptions in import statements as it's reserved in python3
r629 from vcsserver.exceptions import SubrepoMergeException
Martin Bornhold
subrepo: Add patch to turn off mercurial subrepo handling.
r97
class NoOpSubrepo(subrepo.abstractsubrepo):
def __init__(self, ctx, path, *args, **kwargs):
"""Initialize abstractsubrepo part
``ctx`` is the context referring this subrepository in the
parent repository.
``path`` is the path to this subrepository as seen from
innermost repository.
"""
self.ui = ctx.repo().ui
self._ctx = ctx
self._path = path
def storeclean(self, path):
"""
returns true if the repository has not changed since it was last
cloned from or pushed to a given repository.
"""
return True
mercurial: fix hgpatches for full hg 4.4.2 compatability....
r398 def dirty(self, ignoreupdate=False, missing=False):
Martin Bornhold
subrepo: Add patch to turn off mercurial subrepo handling.
r97 """returns true if the dirstate of the subrepo is dirty or does not
match current stored state. If ignoreupdate is true, only check
whether the subrepo has uncommitted changes in its dirstate.
"""
return False
def basestate(self):
"""current working directory base state, disregarding .hgsubstate
state and working directory modifications"""
pull-requests: fixed subrepo case for pull-requests for new mercurial.
r718 substate = subrepoutil.state(self._ctx, self.ui)
Martin Bornhold
subrepo: Add patch to turn off mercurial subrepo handling.
r97 file_system_path, rev, repotype = substate.get(self._path)
return rev
def remove(self):
"""remove the subrepo
(should verify the dirstate is not dirty first)
"""
pass
def get(self, state, overwrite=False):
"""run whatever commands are needed to put the subrepo into
this state
"""
pass
def merge(self, state):
"""merge currently-saved state with the new state."""
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 raise SubrepoMergeException()()
Martin Bornhold
subrepo: Add patch to turn off mercurial subrepo handling.
r97
def push(self, opts):
"""perform whatever action is analogous to 'hg push'
This may be a no-op on some systems.
"""
pass
# Patch subrepo type mapping to always return our NoOpSubrepo class
# whenever a subrepo class is looked up.
subrepo.types = {
'hg': NoOpSubrepo,
'git': NoOpSubrepo,
'svn': NoOpSubrepo
}