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