##// END OF EJS Templates
release: merge back stable branch into default
marcink -
r830:96a2fc09 merge default
parent child Browse files
Show More
@@ -57,3 +57,7 b' 5e0c2990e095bba1dc903cf0e6ef6ac035e0ccf9'
57 57 8a824544d95037d76d99b104b5d2363858101d53 v4.17.2
58 58 ccd806a2d9482f61bd7e8956a02a28eb24a1d46a v4.17.3
59 59 e533ca02ccc205189b7bad9f227a312212772022 v4.17.4
60 ba6a6dc9ecd7fd8b1dcd6eb0c4ee0210e897c426 v4.18.0
61 17bc818b41bcf6883b9ff0da31f01d8c2a5d0781 v4.18.1
62 1e9f12aa01f82c335abc9017efe94ce1c30b52ba v4.18.2
63 f4cc6b3c5680bdf4541d7d442fbb7086640fb547 v4.18.3
@@ -39,7 +39,7 b' from dulwich.repo import Repo as Dulwich'
39 39 from dulwich.server import update_server_info
40 40
41 41 from vcsserver import exceptions, settings, subprocessio
42 from vcsserver.utils import safe_str, safe_int
42 from vcsserver.utils import safe_str, safe_int, safe_unicode
43 43 from vcsserver.base import RepoFactory, obfuscate_qs
44 44 from vcsserver.hgcompat import (
45 45 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler)
@@ -840,7 +840,11 b' class GitRemote(RemoteBase):'
840 840 if author.email:
841 841 return u"{} <{}>".format(author.name, author.email)
842 842
843 return u"{}".format(author.raw_name)
843 try:
844 return u"{}".format(author.name)
845 except Exception:
846 return u"{}".format(safe_unicode(author.raw_name))
847
844 848 return _author(repo_id, commit_id)
845 849
846 850 @reraise_safe_exceptions
@@ -27,6 +27,7 b' from hgext.strip import strip as hgext_s'
27 27 from mercurial import commands
28 28 from mercurial import unionrepo
29 29 from mercurial import verify
30 from mercurial import repair
30 31
31 32 import vcsserver
32 33 from vcsserver import exceptions
@@ -151,6 +152,21 b' class MercurialFactory(RepoFactory):'
151 152 return self._create_repo(wire, create)
152 153
153 154
155 def patch_ui_message_output(baseui):
156 baseui.setconfig('ui', 'quiet', 'false')
157 output = io.BytesIO()
158
159 def write(data, **unused_kwargs):
160 output.write(data)
161
162 baseui.status = write
163 baseui.write = write
164 baseui.warn = write
165 baseui.debug = write
166
167 return baseui, output
168
169
154 170 class HgRemote(RemoteBase):
155 171
156 172 def __init__(self, factory):
@@ -706,12 +722,8 b' class HgRemote(RemoteBase):'
706 722 def verify(self, wire,):
707 723 repo = self._factory.repo(wire)
708 724 baseui = self._factory._create_config(wire['config'])
709 baseui.setconfig('ui', 'quiet', 'false')
710 output = io.BytesIO()
711 725
712 def write(data, **unused_kwargs):
713 output.write(data)
714 baseui.write = write
726 baseui, output = patch_ui_message_output(baseui)
715 727
716 728 repo.ui = baseui
717 729 verify.verify(repo)
@@ -721,12 +733,7 b' class HgRemote(RemoteBase):'
721 733 def hg_update_cache(self, wire,):
722 734 repo = self._factory.repo(wire)
723 735 baseui = self._factory._create_config(wire['config'])
724 baseui.setconfig('ui', 'quiet', 'false')
725 output = io.BytesIO()
726
727 def write(data, **unused_kwargs):
728 output.write(data)
729 baseui.write = write
736 baseui, output = patch_ui_message_output(baseui)
730 737
731 738 repo.ui = baseui
732 739 with repo.wlock(), repo.lock():
@@ -735,6 +742,18 b' class HgRemote(RemoteBase):'
735 742 return output.getvalue()
736 743
737 744 @reraise_safe_exceptions
745 def hg_rebuild_fn_cache(self, wire,):
746 repo = self._factory.repo(wire)
747 baseui = self._factory._create_config(wire['config'])
748 baseui, output = patch_ui_message_output(baseui)
749
750 repo.ui = baseui
751
752 repair.rebuildfncache(baseui, repo)
753
754 return output.getvalue()
755
756 @reraise_safe_exceptions
738 757 def tags(self, wire):
739 758 cache_on, context_uid, repo_id = self._cache_on(wire)
740 759 @self.region.conditional_cache_on_arguments(condition=cache_on)
@@ -71,5 +71,9 b' def get_ctx(repo, ref):'
71 71 # we're unable to find the rev using a regular lookup, we fallback
72 72 # to slower, but backward compat revsymbol usage
73 73 ctx = revsymbol(repo, ref)
74
74 except (LookupError, RepoLookupError):
75 # Similar case as above but only for refs that are not numeric
76 if isinstance(ref, (int, long)):
77 raise
78 ctx = revsymbol(repo, ref)
75 79 return ctx
@@ -691,7 +691,14 b' def svn_post_commit(repo_path, commit_da'
691 691 """
692 692 commit_data is path, rev, txn_id
693 693 """
694 if len(commit_data) == 3:
694 695 path, commit_id, txn_id = commit_data
696 elif len(commit_data) == 2:
697 log.error('Failed to extract txn_id from commit_data using legacy method. '
698 'Some functionality might be limited')
699 path, commit_id = commit_data
700 txn_id = None
701
695 702 branches = []
696 703 tags = []
697 704
@@ -37,18 +37,16 b' def safe_int(val, default=None):'
37 37 return val
38 38
39 39
40 def safe_str(unicode_, to_encoding=['utf8']):
40 def safe_str(unicode_, to_encoding=None):
41 41 """
42 42 safe str function. Does few trick to turn unicode_ into string
43 43
44 In case of UnicodeEncodeError, we try to return it with encoding detected
45 by chardet library if it fails fallback to string with errors replaced
46
47 44 :param unicode_: unicode to encode
45 :param to_encoding: encode to this type UTF8 default
48 46 :rtype: str
49 47 :returns: str object
50 48 """
51
49 to_encoding = to_encoding or ['utf8']
52 50 # if it's not basestr cast to str
53 51 if not isinstance(unicode_, basestring):
54 52 return str(unicode_)
@@ -65,15 +63,38 b" def safe_str(unicode_, to_encoding=['utf"
65 63 except UnicodeEncodeError:
66 64 pass
67 65
66 return unicode_.encode(to_encoding[0], 'replace')
67
68
69 def safe_unicode(str_, from_encoding=None):
70 """
71 safe unicode function. Does few trick to turn str_ into unicode
72
73 :param str_: string to decode
74 :param from_encoding: encode from this type UTF8 default
75 :rtype: unicode
76 :returns: unicode object
77 """
78 from_encoding = from_encoding or ['utf8']
79
80 if isinstance(str_, unicode):
81 return str_
82
83 if not isinstance(from_encoding, (list, tuple)):
84 from_encoding = [from_encoding]
85
68 86 try:
69 import chardet
70 encoding = chardet.detect(unicode_)['encoding']
71 if encoding is None:
72 raise UnicodeEncodeError()
87 return unicode(str_)
88 except UnicodeDecodeError:
89 pass
73 90
74 return unicode_.encode(encoding)
75 except (ImportError, UnicodeEncodeError):
76 return unicode_.encode(to_encoding[0], 'replace')
91 for enc in from_encoding:
92 try:
93 return unicode(str_, enc)
94 except UnicodeDecodeError:
95 pass
96
97 return unicode(str_, from_encoding[0], 'replace')
77 98
78 99
79 100 class AttributeDict(dict):
General Comments 0
You need to be logged in to leave comments. Login now