Show More
@@ -1,204 +1,198 b'' | |||
|
1 | 1 | # Copyright 2009-2010 Gregory P. Ward |
|
2 | 2 | # Copyright 2009-2010 Intelerad Medical Systems Incorporated |
|
3 | 3 | # Copyright 2010-2011 Fog Creek Software |
|
4 | 4 | # Copyright 2010-2011 Unity Technologies |
|
5 | 5 | # |
|
6 | 6 | # This software may be used and distributed according to the terms of the |
|
7 | 7 | # GNU General Public License version 2 or any later version. |
|
8 | 8 | |
|
9 | 9 | '''setup for largefiles extension: uisetup''' |
|
10 | 10 | from __future__ import absolute_import |
|
11 | 11 | |
|
12 | 12 | from mercurial.i18n import _ |
|
13 | 13 | |
|
14 | 14 | from mercurial.hgweb import ( |
|
15 | 15 | hgweb_mod, |
|
16 | 16 | webcommands, |
|
17 | 17 | ) |
|
18 | 18 | |
|
19 | 19 | from mercurial import ( |
|
20 | 20 | archival, |
|
21 | 21 | cmdutil, |
|
22 | 22 | commands, |
|
23 | 23 | copies, |
|
24 | 24 | exchange, |
|
25 | 25 | extensions, |
|
26 | 26 | filemerge, |
|
27 | 27 | hg, |
|
28 | 28 | httppeer, |
|
29 | 29 | merge, |
|
30 | 30 | scmutil, |
|
31 | 31 | sshpeer, |
|
32 | 32 | subrepo, |
|
33 | 33 | wireproto, |
|
34 | 34 | ) |
|
35 | 35 | |
|
36 | 36 | from . import ( |
|
37 | 37 | overrides, |
|
38 | 38 | proto, |
|
39 | 39 | ) |
|
40 | 40 | |
|
41 | 41 | def uisetup(ui): |
|
42 | 42 | # Disable auto-status for some commands which assume that all |
|
43 | 43 | # files in the result are under Mercurial's control |
|
44 | 44 | |
|
45 | 45 | entry = extensions.wrapcommand(commands.table, 'add', |
|
46 | 46 | overrides.overrideadd) |
|
47 | 47 | addopt = [('', 'large', None, _('add as largefile')), |
|
48 | 48 | ('', 'normal', None, _('add as normal file')), |
|
49 | 49 | ('', 'lfsize', '', _('add all files above this size ' |
|
50 | 50 | '(in megabytes) as largefiles ' |
|
51 | 51 | '(default: 10)'))] |
|
52 | 52 | entry[1].extend(addopt) |
|
53 | 53 | |
|
54 | 54 | # The scmutil function is called both by the (trivial) addremove command, |
|
55 | 55 | # and in the process of handling commit -A (issue3542) |
|
56 |
|
|
|
57 | overrides.scmutiladdremove) | |
|
56 | extensions.wrapfunction(scmutil, 'addremove', overrides.scmutiladdremove) | |
|
58 | 57 | extensions.wrapfunction(cmdutil, 'add', overrides.cmdutiladd) |
|
59 | 58 | extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove) |
|
60 | 59 | extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget) |
|
61 | 60 | |
|
62 | 61 | extensions.wrapfunction(copies, 'pathcopies', overrides.copiespathcopies) |
|
63 | 62 | |
|
64 | 63 | # Subrepos call status function |
|
65 | 64 | entry = extensions.wrapcommand(commands.table, 'status', |
|
66 | 65 | overrides.overridestatus) |
|
67 |
|
|
|
66 | extensions.wrapfunction(subrepo.hgsubrepo, 'status', | |
|
68 | 67 |
|
|
69 | 68 | |
|
70 | 69 | entry = extensions.wrapcommand(commands.table, 'log', |
|
71 | 70 | overrides.overridelog) |
|
72 | 71 | entry = extensions.wrapcommand(commands.table, 'rollback', |
|
73 | 72 | overrides.overriderollback) |
|
74 | 73 | entry = extensions.wrapcommand(commands.table, 'verify', |
|
75 | 74 | overrides.overrideverify) |
|
76 | 75 | |
|
77 | 76 | verifyopt = [('', 'large', None, |
|
78 | 77 | _('verify that all largefiles in current revision exists')), |
|
79 | 78 | ('', 'lfa', None, |
|
80 | 79 | _('verify largefiles in all revisions, not just current')), |
|
81 | 80 | ('', 'lfc', None, |
|
82 | 81 | _('verify local largefile contents, not just existence'))] |
|
83 | 82 | entry[1].extend(verifyopt) |
|
84 | 83 | |
|
85 | 84 | entry = extensions.wrapcommand(commands.table, 'debugstate', |
|
86 | 85 | overrides.overridedebugstate) |
|
87 | 86 | debugstateopt = [('', 'large', None, _('display largefiles dirstate'))] |
|
88 | 87 | entry[1].extend(debugstateopt) |
|
89 | 88 | |
|
90 | 89 | outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs) |
|
91 | 90 | entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing) |
|
92 | 91 | outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] |
|
93 | 92 | entry[1].extend(outgoingopt) |
|
94 | 93 | cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook) |
|
95 | 94 | entry = extensions.wrapcommand(commands.table, 'summary', |
|
96 | 95 | overrides.overridesummary) |
|
97 | 96 | summaryopt = [('', 'large', None, _('display outgoing largefiles'))] |
|
98 | 97 | entry[1].extend(summaryopt) |
|
99 | 98 | cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook) |
|
100 | 99 | |
|
101 | 100 | entry = extensions.wrapcommand(commands.table, 'pull', |
|
102 | 101 | overrides.overridepull) |
|
103 | 102 | pullopt = [('', 'all-largefiles', None, |
|
104 | 103 | _('download all pulled versions of largefiles (DEPRECATED)')), |
|
105 | 104 | ('', 'lfrev', [], |
|
106 | 105 | _('download largefiles for these revisions'), _('REV'))] |
|
107 | 106 | entry[1].extend(pullopt) |
|
108 | 107 | |
|
109 | 108 | entry = extensions.wrapcommand(commands.table, 'push', |
|
110 | 109 | overrides.overridepush) |
|
111 | 110 | pushopt = [('', 'lfrev', [], |
|
112 | 111 | _('upload largefiles for these revisions'), _('REV'))] |
|
113 | 112 | entry[1].extend(pushopt) |
|
114 |
|
|
|
113 | extensions.wrapfunction(exchange, 'pushoperation', | |
|
115 | 114 |
|
|
116 | 115 | |
|
117 | 116 | entry = extensions.wrapcommand(commands.table, 'clone', |
|
118 | 117 | overrides.overrideclone) |
|
119 | 118 | cloneopt = [('', 'all-largefiles', None, |
|
120 | 119 | _('download all versions of all largefiles'))] |
|
121 | 120 | entry[1].extend(cloneopt) |
|
122 |
|
|
|
123 |
|
|
|
121 | extensions.wrapfunction(hg, 'clone', overrides.hgclone) | |
|
122 | extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare) | |
|
124 | 123 | |
|
125 | 124 | entry = extensions.wrapcommand(commands.table, 'cat', |
|
126 | 125 | overrides.overridecat) |
|
127 |
|
|
|
126 | extensions.wrapfunction(merge, '_checkunknownfile', | |
|
128 | 127 |
|
|
129 |
|
|
|
128 | extensions.wrapfunction(merge, 'calculateupdates', | |
|
130 | 129 |
|
|
131 |
|
|
|
130 | extensions.wrapfunction(merge, 'recordupdates', | |
|
132 | 131 |
|
|
133 |
|
|
|
134 | overrides.mergeupdate) | |
|
135 | entry = extensions.wrapfunction(filemerge, '_filemerge', | |
|
132 | extensions.wrapfunction(merge, 'update', overrides.mergeupdate) | |
|
133 | extensions.wrapfunction(filemerge, '_filemerge', | |
|
136 | 134 |
|
|
137 |
|
|
|
138 | overrides.overridecopy) | |
|
135 | extensions.wrapfunction(cmdutil, 'copy', overrides.overridecopy) | |
|
139 | 136 | |
|
140 | 137 | # Summary calls dirty on the subrepos |
|
141 |
|
|
|
142 | overrides.overridedirty) | |
|
138 | extensions.wrapfunction(subrepo.hgsubrepo, 'dirty', overrides.overridedirty) | |
|
143 | 139 | |
|
144 |
|
|
|
145 | overrides.overriderevert) | |
|
140 | extensions.wrapfunction(cmdutil, 'revert', overrides.overriderevert) | |
|
146 | 141 | |
|
147 | 142 | extensions.wrapcommand(commands.table, 'archive', |
|
148 | 143 | overrides.overridearchivecmd) |
|
149 | 144 | extensions.wrapfunction(archival, 'archive', overrides.overridearchive) |
|
150 | 145 | extensions.wrapfunction(subrepo.hgsubrepo, 'archive', |
|
151 | 146 | overrides.hgsubrepoarchive) |
|
152 | extensions.wrapfunction(webcommands, 'archive', | |
|
153 | overrides.hgwebarchive) | |
|
147 | extensions.wrapfunction(webcommands, 'archive', overrides.hgwebarchive) | |
|
154 | 148 | extensions.wrapfunction(cmdutil, 'bailifchanged', |
|
155 | 149 | overrides.overridebailifchanged) |
|
156 | 150 | |
|
157 | 151 | extensions.wrapfunction(cmdutil, 'postcommitstatus', |
|
158 | 152 | overrides.postcommitstatus) |
|
159 | 153 | extensions.wrapfunction(scmutil, 'marktouched', |
|
160 | 154 | overrides.scmutilmarktouched) |
|
161 | 155 | |
|
162 | 156 | # create the new wireproto commands ... |
|
163 | 157 | wireproto.commands['putlfile'] = (proto.putlfile, 'sha') |
|
164 | 158 | wireproto.commands['getlfile'] = (proto.getlfile, 'sha') |
|
165 | 159 | wireproto.commands['statlfile'] = (proto.statlfile, 'sha') |
|
166 | 160 | |
|
167 | 161 | # ... and wrap some existing ones |
|
168 | 162 | wireproto.commands['capabilities'] = (proto.capabilities, '') |
|
169 | 163 | wireproto.commands['heads'] = (proto.heads, '') |
|
170 | 164 | wireproto.commands['lheads'] = (wireproto.heads, '') |
|
171 | 165 | |
|
172 | 166 | # make putlfile behave the same as push and {get,stat}lfile behave |
|
173 | 167 | # the same as pull w.r.t. permissions checks |
|
174 | 168 | hgweb_mod.perms['putlfile'] = 'push' |
|
175 | 169 | hgweb_mod.perms['getlfile'] = 'pull' |
|
176 | 170 | hgweb_mod.perms['statlfile'] = 'pull' |
|
177 | 171 | |
|
178 | 172 | extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath) |
|
179 | 173 | |
|
180 | 174 | # the hello wireproto command uses wireproto.capabilities, so it won't see |
|
181 | 175 | # our largefiles capability unless we replace the actual function as well. |
|
182 | 176 | proto.capabilitiesorig = wireproto.capabilities |
|
183 | 177 | wireproto.capabilities = proto.capabilities |
|
184 | 178 | |
|
185 | 179 | # can't do this in reposetup because it needs to have happened before |
|
186 | 180 | # wirerepo.__init__ is called |
|
187 | 181 | proto.ssholdcallstream = sshpeer.sshpeer._callstream |
|
188 | 182 | proto.httpoldcallstream = httppeer.httppeer._callstream |
|
189 | 183 | sshpeer.sshpeer._callstream = proto.sshrepocallstream |
|
190 | 184 | httppeer.httppeer._callstream = proto.httprepocallstream |
|
191 | 185 | |
|
192 | 186 | # override some extensions' stuff as well |
|
193 | 187 | for name, module in extensions.extensions(): |
|
194 | 188 | if name == 'purge': |
|
195 | 189 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge', |
|
196 | 190 | overrides.overridepurge) |
|
197 | 191 | if name == 'rebase': |
|
198 | 192 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', |
|
199 | 193 | overrides.overriderebase) |
|
200 | 194 | extensions.wrapfunction(module, 'rebase', |
|
201 | 195 | overrides.overriderebase) |
|
202 | 196 | if name == 'transplant': |
|
203 | 197 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', |
|
204 | 198 | overrides.overridetransplant) |
General Comments 0
You need to be logged in to leave comments.
Login now