Show More
@@ -1,74 +1,75 b'' | |||||
1 | # RhodeCode VCSServer provides access to different vcs backends via network. |
|
1 | # RhodeCode VCSServer provides access to different vcs backends via network. | |
2 | # Copyright (C) 2014-2019 RhodeCode GmbH |
|
2 | # Copyright (C) 2014-2019 RhodeCode GmbH | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or modify |
|
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by |
|
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 3 of the License, or |
|
6 | # the Free Software Foundation; either version 3 of the License, or | |
7 | # (at your option) any later version. |
|
7 | # (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software Foundation, |
|
15 | # along with this program; if not, write to the Free Software Foundation, | |
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 |
|
17 | |||
18 | """ |
|
18 | """ | |
19 | Mercurial libs compatibility |
|
19 | Mercurial libs compatibility | |
20 | """ |
|
20 | """ | |
21 |
|
21 | |||
22 | import mercurial |
|
22 | import mercurial | |
23 | from mercurial import demandimport |
|
23 | from mercurial import demandimport | |
24 | # patch demandimport, due to bug in mercurial when it always triggers |
|
24 | # patch demandimport, due to bug in mercurial when it always triggers | |
25 | # demandimport.enable() |
|
25 | # demandimport.enable() | |
26 | demandimport.enable = lambda *args, **kwargs: 1 |
|
26 | demandimport.enable = lambda *args, **kwargs: 1 | |
27 |
|
27 | |||
28 | from mercurial import ui |
|
28 | from mercurial import ui | |
29 | from mercurial import patch |
|
29 | from mercurial import patch | |
30 | from mercurial import config |
|
30 | from mercurial import config | |
31 | from mercurial import extensions |
|
31 | from mercurial import extensions | |
32 | from mercurial import scmutil |
|
32 | from mercurial import scmutil | |
33 | from mercurial import archival |
|
33 | from mercurial import archival | |
34 | from mercurial import discovery |
|
34 | from mercurial import discovery | |
35 | from mercurial import unionrepo |
|
35 | from mercurial import unionrepo | |
36 | from mercurial import localrepo |
|
36 | from mercurial import localrepo | |
37 | from mercurial import merge as hg_merge |
|
37 | from mercurial import merge as hg_merge | |
38 | from mercurial import subrepo |
|
38 | from mercurial import subrepo | |
|
39 | from mercurial import subrepoutil | |||
39 | from mercurial import tags as hg_tag |
|
40 | from mercurial import tags as hg_tag | |
40 |
|
41 | |||
41 | from mercurial.commands import clone, nullid, pull |
|
42 | from mercurial.commands import clone, nullid, pull | |
42 | from mercurial.context import memctx, memfilectx |
|
43 | from mercurial.context import memctx, memfilectx | |
43 | from mercurial.error import ( |
|
44 | from mercurial.error import ( | |
44 | LookupError, RepoError, RepoLookupError, Abort, InterventionRequired, |
|
45 | LookupError, RepoError, RepoLookupError, Abort, InterventionRequired, | |
45 | RequirementError, ProgrammingError) |
|
46 | RequirementError, ProgrammingError) | |
46 | from mercurial.hgweb import hgweb_mod |
|
47 | from mercurial.hgweb import hgweb_mod | |
47 | from mercurial.localrepo import instance |
|
48 | from mercurial.localrepo import instance | |
48 | from mercurial.match import match |
|
49 | from mercurial.match import match | |
49 | from mercurial.mdiff import diffopts |
|
50 | from mercurial.mdiff import diffopts | |
50 | from mercurial.node import bin, hex |
|
51 | from mercurial.node import bin, hex | |
51 | from mercurial.encoding import tolocal |
|
52 | from mercurial.encoding import tolocal | |
52 | from mercurial.discovery import findcommonoutgoing |
|
53 | from mercurial.discovery import findcommonoutgoing | |
53 | from mercurial.hg import peer |
|
54 | from mercurial.hg import peer | |
54 | from mercurial.httppeer import makepeer |
|
55 | from mercurial.httppeer import makepeer | |
55 | from mercurial.util import url as hg_url |
|
56 | from mercurial.util import url as hg_url | |
56 | from mercurial.scmutil import revrange, revsymbol |
|
57 | from mercurial.scmutil import revrange, revsymbol | |
57 | from mercurial.node import nullrev |
|
58 | from mercurial.node import nullrev | |
58 | from mercurial import exchange |
|
59 | from mercurial import exchange | |
59 | from hgext import largefiles |
|
60 | from hgext import largefiles | |
60 |
|
61 | |||
61 | # those authnadlers are patched for python 2.6.5 bug an |
|
62 | # those authnadlers are patched for python 2.6.5 bug an | |
62 | # infinit looping when given invalid resources |
|
63 | # infinit looping when given invalid resources | |
63 | from mercurial.url import httpbasicauthhandler, httpdigestauthhandler |
|
64 | from mercurial.url import httpbasicauthhandler, httpdigestauthhandler | |
64 |
|
65 | |||
65 |
|
66 | |||
66 | def get_ctx(repo, ref): |
|
67 | def get_ctx(repo, ref): | |
67 | try: |
|
68 | try: | |
68 | ctx = repo[ref] |
|
69 | ctx = repo[ref] | |
69 | except ProgrammingError: |
|
70 | except ProgrammingError: | |
70 | # 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 | |
71 | # to slower, but backward compat revsymbol usage |
|
72 | # to slower, but backward compat revsymbol usage | |
72 | ctx = revsymbol(repo, ref) |
|
73 | ctx = revsymbol(repo, ref) | |
73 |
|
74 | |||
74 | return ctx |
|
75 | return ctx |
@@ -1,134 +1,134 b'' | |||||
1 | # RhodeCode VCSServer provides access to different vcs backends via network. |
|
1 | # RhodeCode VCSServer provides access to different vcs backends via network. | |
2 | # Copyright (C) 2014-2019 RhodeCode GmbH |
|
2 | # Copyright (C) 2014-2019 RhodeCode GmbH | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or modify |
|
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by |
|
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 3 of the License, or |
|
6 | # the Free Software Foundation; either version 3 of the License, or | |
7 | # (at your option) any later version. |
|
7 | # (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software Foundation, |
|
15 | # along with this program; if not, write to the Free Software Foundation, | |
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 |
|
17 | |||
18 | """ |
|
18 | """ | |
19 | Adjustments to Mercurial |
|
19 | Adjustments to Mercurial | |
20 |
|
20 | |||
21 | Intentionally kept separate from `hgcompat` and `hg`, so that these patches can |
|
21 | Intentionally kept separate from `hgcompat` and `hg`, so that these patches can | |
22 | be applied without having to import the whole Mercurial machinery. |
|
22 | be applied without having to import the whole Mercurial machinery. | |
23 |
|
23 | |||
24 | Imports are function local, so that just importing this module does not cause |
|
24 | Imports are function local, so that just importing this module does not cause | |
25 | side-effects other than these functions being defined. |
|
25 | side-effects other than these functions being defined. | |
26 | """ |
|
26 | """ | |
27 |
|
27 | |||
28 | import logging |
|
28 | import logging | |
29 |
|
29 | |||
30 |
|
30 | |||
31 | def patch_largefiles_capabilities(): |
|
31 | def patch_largefiles_capabilities(): | |
32 | """ |
|
32 | """ | |
33 | Patches the capabilities function in the largefiles extension. |
|
33 | Patches the capabilities function in the largefiles extension. | |
34 | """ |
|
34 | """ | |
35 | from vcsserver import hgcompat |
|
35 | from vcsserver import hgcompat | |
36 | lfproto = hgcompat.largefiles.proto |
|
36 | lfproto = hgcompat.largefiles.proto | |
37 | wrapper = _dynamic_capabilities_wrapper( |
|
37 | wrapper = _dynamic_capabilities_wrapper( | |
38 | lfproto, hgcompat.extensions.extensions) |
|
38 | lfproto, hgcompat.extensions.extensions) | |
39 | lfproto._capabilities = wrapper |
|
39 | lfproto._capabilities = wrapper | |
40 |
|
40 | |||
41 |
|
41 | |||
42 | def _dynamic_capabilities_wrapper(lfproto, extensions): |
|
42 | def _dynamic_capabilities_wrapper(lfproto, extensions): | |
43 |
|
43 | |||
44 | wrapped_capabilities = lfproto._capabilities |
|
44 | wrapped_capabilities = lfproto._capabilities | |
45 | logger = logging.getLogger('vcsserver.hg') |
|
45 | logger = logging.getLogger('vcsserver.hg') | |
46 |
|
46 | |||
47 | def _dynamic_capabilities(orig, repo, proto): |
|
47 | def _dynamic_capabilities(orig, repo, proto): | |
48 | """ |
|
48 | """ | |
49 | Adds dynamic behavior, so that the capability is only added if the |
|
49 | Adds dynamic behavior, so that the capability is only added if the | |
50 | extension is enabled in the current ui object. |
|
50 | extension is enabled in the current ui object. | |
51 | """ |
|
51 | """ | |
52 | if 'largefiles' in dict(extensions(repo.ui)): |
|
52 | if 'largefiles' in dict(extensions(repo.ui)): | |
53 | logger.debug('Extension largefiles enabled') |
|
53 | logger.debug('Extension largefiles enabled') | |
54 | calc_capabilities = wrapped_capabilities |
|
54 | calc_capabilities = wrapped_capabilities | |
55 | return calc_capabilities(orig, repo, proto) |
|
55 | return calc_capabilities(orig, repo, proto) | |
56 | else: |
|
56 | else: | |
57 | logger.debug('Extension largefiles disabled') |
|
57 | logger.debug('Extension largefiles disabled') | |
58 | return orig(repo, proto) |
|
58 | return orig(repo, proto) | |
59 |
|
59 | |||
60 | return _dynamic_capabilities |
|
60 | return _dynamic_capabilities | |
61 |
|
61 | |||
62 |
|
62 | |||
63 | def patch_subrepo_type_mapping(): |
|
63 | def patch_subrepo_type_mapping(): | |
64 | from collections import defaultdict |
|
64 | from collections import defaultdict | |
65 | from hgcompat import subrepo |
|
65 | from hgcompat import subrepo, subrepoutil | |
66 | from vcsserver.exceptions import SubrepoMergeException |
|
66 | from vcsserver.exceptions import SubrepoMergeException | |
67 |
|
67 | |||
68 | class NoOpSubrepo(subrepo.abstractsubrepo): |
|
68 | class NoOpSubrepo(subrepo.abstractsubrepo): | |
69 |
|
69 | |||
70 | def __init__(self, ctx, path, *args, **kwargs): |
|
70 | def __init__(self, ctx, path, *args, **kwargs): | |
71 | """Initialize abstractsubrepo part |
|
71 | """Initialize abstractsubrepo part | |
72 |
|
72 | |||
73 | ``ctx`` is the context referring this subrepository in the |
|
73 | ``ctx`` is the context referring this subrepository in the | |
74 | parent repository. |
|
74 | parent repository. | |
75 |
|
75 | |||
76 | ``path`` is the path to this subrepository as seen from |
|
76 | ``path`` is the path to this subrepository as seen from | |
77 | innermost repository. |
|
77 | innermost repository. | |
78 | """ |
|
78 | """ | |
79 | self.ui = ctx.repo().ui |
|
79 | self.ui = ctx.repo().ui | |
80 | self._ctx = ctx |
|
80 | self._ctx = ctx | |
81 | self._path = path |
|
81 | self._path = path | |
82 |
|
82 | |||
83 | def storeclean(self, path): |
|
83 | def storeclean(self, path): | |
84 | """ |
|
84 | """ | |
85 | returns true if the repository has not changed since it was last |
|
85 | returns true if the repository has not changed since it was last | |
86 | cloned from or pushed to a given repository. |
|
86 | cloned from or pushed to a given repository. | |
87 | """ |
|
87 | """ | |
88 | return True |
|
88 | return True | |
89 |
|
89 | |||
90 | def dirty(self, ignoreupdate=False, missing=False): |
|
90 | def dirty(self, ignoreupdate=False, missing=False): | |
91 | """returns true if the dirstate of the subrepo is dirty or does not |
|
91 | """returns true if the dirstate of the subrepo is dirty or does not | |
92 | match current stored state. If ignoreupdate is true, only check |
|
92 | match current stored state. If ignoreupdate is true, only check | |
93 | whether the subrepo has uncommitted changes in its dirstate. |
|
93 | whether the subrepo has uncommitted changes in its dirstate. | |
94 | """ |
|
94 | """ | |
95 | return False |
|
95 | return False | |
96 |
|
96 | |||
97 | def basestate(self): |
|
97 | def basestate(self): | |
98 | """current working directory base state, disregarding .hgsubstate |
|
98 | """current working directory base state, disregarding .hgsubstate | |
99 | state and working directory modifications""" |
|
99 | state and working directory modifications""" | |
100 | substate = subrepo.state(self._ctx, self.ui) |
|
100 | substate = subrepoutil.state(self._ctx, self.ui) | |
101 | file_system_path, rev, repotype = substate.get(self._path) |
|
101 | file_system_path, rev, repotype = substate.get(self._path) | |
102 | return rev |
|
102 | return rev | |
103 |
|
103 | |||
104 | def remove(self): |
|
104 | def remove(self): | |
105 | """remove the subrepo |
|
105 | """remove the subrepo | |
106 |
|
106 | |||
107 | (should verify the dirstate is not dirty first) |
|
107 | (should verify the dirstate is not dirty first) | |
108 | """ |
|
108 | """ | |
109 | pass |
|
109 | pass | |
110 |
|
110 | |||
111 | def get(self, state, overwrite=False): |
|
111 | def get(self, state, overwrite=False): | |
112 | """run whatever commands are needed to put the subrepo into |
|
112 | """run whatever commands are needed to put the subrepo into | |
113 | this state |
|
113 | this state | |
114 | """ |
|
114 | """ | |
115 | pass |
|
115 | pass | |
116 |
|
116 | |||
117 | def merge(self, state): |
|
117 | def merge(self, state): | |
118 | """merge currently-saved state with the new state.""" |
|
118 | """merge currently-saved state with the new state.""" | |
119 | raise SubrepoMergeException()() |
|
119 | raise SubrepoMergeException()() | |
120 |
|
120 | |||
121 | def push(self, opts): |
|
121 | def push(self, opts): | |
122 | """perform whatever action is analogous to 'hg push' |
|
122 | """perform whatever action is analogous to 'hg push' | |
123 |
|
123 | |||
124 | This may be a no-op on some systems. |
|
124 | This may be a no-op on some systems. | |
125 | """ |
|
125 | """ | |
126 | pass |
|
126 | pass | |
127 |
|
127 | |||
128 | # Patch subrepo type mapping to always return our NoOpSubrepo class |
|
128 | # Patch subrepo type mapping to always return our NoOpSubrepo class | |
129 | # whenever a subrepo class is looked up. |
|
129 | # whenever a subrepo class is looked up. | |
130 | subrepo.types = { |
|
130 | subrepo.types = { | |
131 | 'hg': NoOpSubrepo, |
|
131 | 'hg': NoOpSubrepo, | |
132 | 'git': NoOpSubrepo, |
|
132 | 'git': NoOpSubrepo, | |
133 | 'svn': NoOpSubrepo |
|
133 | 'svn': NoOpSubrepo | |
134 | } |
|
134 | } |
General Comments 0
You need to be logged in to leave comments.
Login now