Show More
@@ -57,3 +57,7 b' 5e0c2990e095bba1dc903cf0e6ef6ac035e0ccf9' | |||||
57 | 8a824544d95037d76d99b104b5d2363858101d53 v4.17.2 |
|
57 | 8a824544d95037d76d99b104b5d2363858101d53 v4.17.2 | |
58 | ccd806a2d9482f61bd7e8956a02a28eb24a1d46a v4.17.3 |
|
58 | ccd806a2d9482f61bd7e8956a02a28eb24a1d46a v4.17.3 | |
59 | e533ca02ccc205189b7bad9f227a312212772022 v4.17.4 |
|
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 | from dulwich.server import update_server_info |
|
39 | from dulwich.server import update_server_info | |
40 |
|
40 | |||
41 | from vcsserver import exceptions, settings, subprocessio |
|
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 | from vcsserver.base import RepoFactory, obfuscate_qs |
|
43 | from vcsserver.base import RepoFactory, obfuscate_qs | |
44 | from vcsserver.hgcompat import ( |
|
44 | from vcsserver.hgcompat import ( | |
45 | hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler) |
|
45 | hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler) | |
@@ -840,7 +840,11 b' class GitRemote(RemoteBase):' | |||||
840 | if author.email: |
|
840 | if author.email: | |
841 | return u"{} <{}>".format(author.name, author.email) |
|
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 | return _author(repo_id, commit_id) |
|
848 | return _author(repo_id, commit_id) | |
845 |
|
849 | |||
846 | @reraise_safe_exceptions |
|
850 | @reraise_safe_exceptions |
@@ -27,6 +27,7 b' from hgext.strip import strip as hgext_s' | |||||
27 | from mercurial import commands |
|
27 | from mercurial import commands | |
28 | from mercurial import unionrepo |
|
28 | from mercurial import unionrepo | |
29 | from mercurial import verify |
|
29 | from mercurial import verify | |
|
30 | from mercurial import repair | |||
30 |
|
31 | |||
31 | import vcsserver |
|
32 | import vcsserver | |
32 | from vcsserver import exceptions |
|
33 | from vcsserver import exceptions | |
@@ -151,6 +152,21 b' class MercurialFactory(RepoFactory):' | |||||
151 | return self._create_repo(wire, create) |
|
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 | class HgRemote(RemoteBase): |
|
170 | class HgRemote(RemoteBase): | |
155 |
|
171 | |||
156 | def __init__(self, factory): |
|
172 | def __init__(self, factory): | |
@@ -706,12 +722,8 b' class HgRemote(RemoteBase):' | |||||
706 | def verify(self, wire,): |
|
722 | def verify(self, wire,): | |
707 | repo = self._factory.repo(wire) |
|
723 | repo = self._factory.repo(wire) | |
708 | baseui = self._factory._create_config(wire['config']) |
|
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): |
|
726 | baseui, output = patch_ui_message_output(baseui) | |
713 | output.write(data) |
|
|||
714 | baseui.write = write |
|
|||
715 |
|
727 | |||
716 | repo.ui = baseui |
|
728 | repo.ui = baseui | |
717 | verify.verify(repo) |
|
729 | verify.verify(repo) | |
@@ -721,12 +733,7 b' class HgRemote(RemoteBase):' | |||||
721 | def hg_update_cache(self, wire,): |
|
733 | def hg_update_cache(self, wire,): | |
722 | repo = self._factory.repo(wire) |
|
734 | repo = self._factory.repo(wire) | |
723 | baseui = self._factory._create_config(wire['config']) |
|
735 | baseui = self._factory._create_config(wire['config']) | |
724 | baseui.setconfig('ui', 'quiet', 'false') |
|
736 | baseui, output = patch_ui_message_output(baseui) | |
725 | output = io.BytesIO() |
|
|||
726 |
|
||||
727 | def write(data, **unused_kwargs): |
|
|||
728 | output.write(data) |
|
|||
729 | baseui.write = write |
|
|||
730 |
|
737 | |||
731 | repo.ui = baseui |
|
738 | repo.ui = baseui | |
732 | with repo.wlock(), repo.lock(): |
|
739 | with repo.wlock(), repo.lock(): | |
@@ -735,6 +742,18 b' class HgRemote(RemoteBase):' | |||||
735 | return output.getvalue() |
|
742 | return output.getvalue() | |
736 |
|
743 | |||
737 | @reraise_safe_exceptions |
|
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 | def tags(self, wire): |
|
757 | def tags(self, wire): | |
739 | cache_on, context_uid, repo_id = self._cache_on(wire) |
|
758 | cache_on, context_uid, repo_id = self._cache_on(wire) | |
740 | @self.region.conditional_cache_on_arguments(condition=cache_on) |
|
759 | @self.region.conditional_cache_on_arguments(condition=cache_on) |
@@ -71,5 +71,9 b' def get_ctx(repo, ref):' | |||||
71 | # we're unable to find the rev using a regular lookup, we fallback |
|
71 | # we're unable to find the rev using a regular lookup, we fallback | |
72 | # to slower, but backward compat revsymbol usage |
|
72 | # to slower, but backward compat revsymbol usage | |
73 | ctx = revsymbol(repo, ref) |
|
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 | return ctx |
|
79 | return ctx |
@@ -691,7 +691,14 b' def svn_post_commit(repo_path, commit_da' | |||||
691 | """ |
|
691 | """ | |
692 | commit_data is path, rev, txn_id |
|
692 | commit_data is path, rev, txn_id | |
693 | """ |
|
693 | """ | |
694 | path, commit_id, txn_id = commit_data |
|
694 | if len(commit_data) == 3: | |
|
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 | branches = [] |
|
702 | branches = [] | |
696 | tags = [] |
|
703 | tags = [] | |
697 |
|
704 |
@@ -37,18 +37,16 b' def safe_int(val, default=None):' | |||||
37 | return val |
|
37 | return val | |
38 |
|
38 | |||
39 |
|
39 | |||
40 |
def safe_str(unicode_, to_encoding= |
|
40 | def safe_str(unicode_, to_encoding=None): | |
41 | """ |
|
41 | """ | |
42 | safe str function. Does few trick to turn unicode_ into string |
|
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 | :param unicode_: unicode to encode |
|
44 | :param unicode_: unicode to encode | |
|
45 | :param to_encoding: encode to this type UTF8 default | |||
48 | :rtype: str |
|
46 | :rtype: str | |
49 | :returns: str object |
|
47 | :returns: str object | |
50 | """ |
|
48 | """ | |
51 |
|
49 | to_encoding = to_encoding or ['utf8'] | ||
52 | # if it's not basestr cast to str |
|
50 | # if it's not basestr cast to str | |
53 | if not isinstance(unicode_, basestring): |
|
51 | if not isinstance(unicode_, basestring): | |
54 | return str(unicode_) |
|
52 | return str(unicode_) | |
@@ -65,15 +63,38 b" def safe_str(unicode_, to_encoding=['utf" | |||||
65 | except UnicodeEncodeError: |
|
63 | except UnicodeEncodeError: | |
66 | pass |
|
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 | try: |
|
86 | try: | |
69 | import chardet |
|
87 | return unicode(str_) | |
70 | encoding = chardet.detect(unicode_)['encoding'] |
|
88 | except UnicodeDecodeError: | |
71 | if encoding is None: |
|
89 | pass | |
72 | raise UnicodeEncodeError() |
|
|||
73 |
|
90 | |||
74 | return unicode_.encode(encoding) |
|
91 | for enc in from_encoding: | |
75 | except (ImportError, UnicodeEncodeError): |
|
92 | try: | |
76 | return unicode_.encode(to_encoding[0], 'replace') |
|
93 | return unicode(str_, enc) | |
|
94 | except UnicodeDecodeError: | |||
|
95 | pass | |||
|
96 | ||||
|
97 | return unicode(str_, from_encoding[0], 'replace') | |||
77 |
|
98 | |||
78 |
|
99 | |||
79 | class AttributeDict(dict): |
|
100 | class AttributeDict(dict): |
General Comments 0
You need to be logged in to leave comments.
Login now