##// END OF EJS Templates
py3: compat and code fixes
super-admin -
r1042:b2b1b1e7 python3
parent child Browse files
Show More
@@ -57,7 +57,7 b' def _get_process_rss(pid=None):'
57 57
58 58
59 59 def _get_config(ini_path):
60 import configparser
60 import configparser
61 61
62 62 try:
63 63 config = configparser.RawConfigParser()
@@ -1,4 +1,4 b''
1 RhodeCode VCSServer provides access to different vcs backends via network.
1 # RhodeCode VCSServer provides access to different vcs backends via network.
2 2 # Copyright (C) 2014-2020 RhodeCode GmbH
3 3 #
4 4 # This program is free software; you can redistribute it and/or modify
@@ -14,17 +14,16 b''
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software Foundation,
16 16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 import functools
17
18 18 import io
19 19 import logging
20 import os
21 20 import stat
22 21 import urllib.request, urllib.parse, urllib.error
23 22 import urllib.request, urllib.error, urllib.parse
24 23 import traceback
25 24
26 25 from hgext import largefiles, rebase, purge
27 from hgext.strip import strip as hgext_strip
26
28 27 from mercurial import commands
29 28 from mercurial import unionrepo
30 29 from mercurial import verify
@@ -39,7 +38,7 b' from vcsserver.hgcompat import ('
39 38 makepeer, instance, match, memctx, exchange, memfilectx, nullrev, hg_merge,
40 39 patch, peer, revrange, ui, hg_tag, Abort, LookupError, RepoError,
41 40 RepoLookupError, InterventionRequired, RequirementError,
42 alwaysmatcher, patternmatcher, hgutil)
41 alwaysmatcher, patternmatcher, hgutil, hgext_strip)
43 42 from vcsserver.vcs_base import RemoteBase
44 43
45 44 log = logging.getLogger(__name__)
@@ -21,6 +21,7 b' Mercurial libs compatibility'
21 21
22 22 import mercurial
23 23 from mercurial import demandimport
24
24 25 # patch demandimport, due to bug in mercurial when it always triggers
25 26 # demandimport.enable()
26 27 demandimport.enable = lambda *args, **kwargs: 1
@@ -39,7 +40,8 b' from mercurial import subrepo'
39 40 from mercurial import subrepoutil
40 41 from mercurial import tags as hg_tag
41 42 from mercurial import util as hgutil
42 from mercurial.commands import clone, nullid, pull
43 from mercurial.commands import clone, pull
44 from mercurial.node import nullid
43 45 from mercurial.context import memctx, memfilectx
44 46 from mercurial.error import (
45 47 LookupError, RepoError, RepoLookupError, Abort, InterventionRequired,
@@ -53,7 +55,7 b' from mercurial.encoding import tolocal'
53 55 from mercurial.discovery import findcommonoutgoing
54 56 from mercurial.hg import peer
55 57 from mercurial.httppeer import makepeer
56 from mercurial.util import url as hg_url
58 from mercurial.utils.urlutil import url as hg_url
57 59 from mercurial.scmutil import revrange, revsymbol
58 60 from mercurial.node import nullrev
59 61 from mercurial import exchange
@@ -63,6 +65,9 b' from hgext import largefiles'
63 65 # infinit looping when given invalid resources
64 66 from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
65 67
68 # hg strip is in core now
69 from mercurial import strip as hgext_strip
70
66 71
67 72 def get_ctx(repo, ref):
68 73 try:
@@ -21,10 +21,8 b' import logging'
21 21 import functools
22 22
23 23 from dogpile.cache import CacheRegion
24 from dogpile.cache.util import compat
25 24
26 25 from vcsserver.utils import safe_str, sha1
27
28 26 from vcsserver.lib.rc_cache import region_meta
29 27
30 28 log = logging.getLogger(__name__)
@@ -36,7 +34,7 b' class RhodeCodeCacheRegion(CacheRegion):'
36 34 self, namespace=None,
37 35 expiration_time=None,
38 36 should_cache_fn=None,
39 to_str=compat.string_type,
37 to_str=str,
40 38 function_key_generator=None,
41 39 condition=True):
42 40 """
@@ -44,7 +42,7 b' class RhodeCodeCacheRegion(CacheRegion):'
44 42 condition isn't meet. This works a bit different than should_cache_fn
45 43 And it's faster in cases we don't ever want to compute cached values
46 44 """
47 expiration_time_is_callable = compat.callable(expiration_time)
45 expiration_time_is_callable = callable(expiration_time)
48 46
49 47 if function_key_generator is None:
50 48 function_key_generator = self.function_key_generator
@@ -53,7 +51,7 b' class RhodeCodeCacheRegion(CacheRegion):'
53 51 # once we've migrated to py3
54 52 if 'cython' == 'cython':
55 53 def decorator(fn):
56 if to_str is compat.string_type:
54 if to_str is str:
57 55 # backwards compatible
58 56 key_generator = function_key_generator(namespace, fn)
59 57 else:
@@ -123,7 +121,7 b' class RhodeCodeCacheRegion(CacheRegion):'
123 121 return self.get_or_create(key, user_func, timeout, should_cache_fn, (arg, kw))
124 122
125 123 def cache_decorator(user_func):
126 if to_str is compat.string_type:
124 if to_str is str:
127 125 # backwards compatible
128 126 key_generator = function_key_generator(namespace, user_func)
129 127 else:
@@ -176,7 +174,7 b' def get_default_cache_settings(settings,'
176 174 if key.startswith(prefix):
177 175 name = key.split(prefix)[1].strip()
178 176 val = settings[key]
179 if isinstance(val, compat.string_types):
177 if isinstance(val, str):
180 178 val = val.strip()
181 179 cache_settings[name] = val
182 180 return cache_settings
@@ -16,10 +16,8 b''
16 16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 17
18 18
19
20 19 import os
21 20 import subprocess
22 import time
23 21 from urllib.error import URLError
24 22 import urllib.parse
25 23 import logging
@@ -507,12 +505,12 b' class SvnRemote(RemoteBase):'
507 505 if safe_call:
508 506 return '', safe_str(err).strip()
509 507 else:
510 cmd = ' '.join(cmd) # human friendly CMD
511 tb_err = ("Couldn't run svn command (%s).\n"
512 "Original error was:%s\n"
513 "Call options:%s\n"
514 % (cmd, err, _opts))
515 log.exception(tb_err)
508 cmd = ' '.join(cmd) # human friendly CMD
509 tb_err = ("Couldn't run svn command (%s).\n"
510 "Original error was:%s\n"
511 "Call options:%s\n"
512 % (cmd, err, _opts))
513 log.exception(tb_err)
516 514 raise exceptions.VcsException()(tb_err)
517 515
518 516 @reraise_safe_exceptions
General Comments 0
You need to be logged in to leave comments. Login now