##// END OF EJS Templates
largefiles: wrap "rebase.rebase" for functions using it directly...
FUJIWARA Katsunori -
r23182:9b6c3947 default
parent child Browse files
Show More
@@ -1,181 +1,183 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
10
11 from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \
11 from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \
12 httppeer, merge, scmutil, sshpeer, wireproto, revset, subrepo
12 httppeer, merge, scmutil, sshpeer, wireproto, revset, subrepo
13 from mercurial.i18n import _
13 from mercurial.i18n import _
14 from mercurial.hgweb import hgweb_mod, webcommands
14 from mercurial.hgweb import hgweb_mod, webcommands
15
15
16 import overrides
16 import overrides
17 import proto
17 import proto
18
18
19 def uisetup(ui):
19 def uisetup(ui):
20 # Disable auto-status for some commands which assume that all
20 # Disable auto-status for some commands which assume that all
21 # files in the result are under Mercurial's control
21 # files in the result are under Mercurial's control
22
22
23 entry = extensions.wrapcommand(commands.table, 'add',
23 entry = extensions.wrapcommand(commands.table, 'add',
24 overrides.overrideadd)
24 overrides.overrideadd)
25 addopt = [('', 'large', None, _('add as largefile')),
25 addopt = [('', 'large', None, _('add as largefile')),
26 ('', 'normal', None, _('add as normal file')),
26 ('', 'normal', None, _('add as normal file')),
27 ('', 'lfsize', '', _('add all files above this size '
27 ('', 'lfsize', '', _('add all files above this size '
28 '(in megabytes) as largefiles '
28 '(in megabytes) as largefiles '
29 '(default: 10)'))]
29 '(default: 10)'))]
30 entry[1].extend(addopt)
30 entry[1].extend(addopt)
31
31
32 # The scmutil function is called both by the (trivial) addremove command,
32 # The scmutil function is called both by the (trivial) addremove command,
33 # and in the process of handling commit -A (issue3542)
33 # and in the process of handling commit -A (issue3542)
34 entry = extensions.wrapfunction(scmutil, 'addremove',
34 entry = extensions.wrapfunction(scmutil, 'addremove',
35 overrides.scmutiladdremove)
35 overrides.scmutiladdremove)
36 entry = extensions.wrapcommand(commands.table, 'remove',
36 entry = extensions.wrapcommand(commands.table, 'remove',
37 overrides.overrideremove)
37 overrides.overrideremove)
38 entry = extensions.wrapcommand(commands.table, 'forget',
38 entry = extensions.wrapcommand(commands.table, 'forget',
39 overrides.overrideforget)
39 overrides.overrideforget)
40
40
41 # Subrepos call status function
41 # Subrepos call status function
42 entry = extensions.wrapcommand(commands.table, 'status',
42 entry = extensions.wrapcommand(commands.table, 'status',
43 overrides.overridestatus)
43 overrides.overridestatus)
44 entry = extensions.wrapfunction(subrepo.hgsubrepo, 'status',
44 entry = extensions.wrapfunction(subrepo.hgsubrepo, 'status',
45 overrides.overridestatusfn)
45 overrides.overridestatusfn)
46
46
47 entry = extensions.wrapcommand(commands.table, 'log',
47 entry = extensions.wrapcommand(commands.table, 'log',
48 overrides.overridelog)
48 overrides.overridelog)
49 entry = extensions.wrapcommand(commands.table, 'rollback',
49 entry = extensions.wrapcommand(commands.table, 'rollback',
50 overrides.overriderollback)
50 overrides.overriderollback)
51 entry = extensions.wrapcommand(commands.table, 'verify',
51 entry = extensions.wrapcommand(commands.table, 'verify',
52 overrides.overrideverify)
52 overrides.overrideverify)
53
53
54 verifyopt = [('', 'large', None,
54 verifyopt = [('', 'large', None,
55 _('verify that all largefiles in current revision exists')),
55 _('verify that all largefiles in current revision exists')),
56 ('', 'lfa', None,
56 ('', 'lfa', None,
57 _('verify largefiles in all revisions, not just current')),
57 _('verify largefiles in all revisions, not just current')),
58 ('', 'lfc', None,
58 ('', 'lfc', None,
59 _('verify local largefile contents, not just existence'))]
59 _('verify local largefile contents, not just existence'))]
60 entry[1].extend(verifyopt)
60 entry[1].extend(verifyopt)
61
61
62 entry = extensions.wrapcommand(commands.table, 'debugstate',
62 entry = extensions.wrapcommand(commands.table, 'debugstate',
63 overrides.overridedebugstate)
63 overrides.overridedebugstate)
64 debugstateopt = [('', 'large', None, _('display largefiles dirstate'))]
64 debugstateopt = [('', 'large', None, _('display largefiles dirstate'))]
65 entry[1].extend(debugstateopt)
65 entry[1].extend(debugstateopt)
66
66
67 outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs)
67 outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs)
68 entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
68 entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
69 outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
69 outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
70 entry[1].extend(outgoingopt)
70 entry[1].extend(outgoingopt)
71 cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
71 cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
72 entry = extensions.wrapcommand(commands.table, 'summary',
72 entry = extensions.wrapcommand(commands.table, 'summary',
73 overrides.overridesummary)
73 overrides.overridesummary)
74 summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
74 summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
75 entry[1].extend(summaryopt)
75 entry[1].extend(summaryopt)
76 cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
76 cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
77
77
78 entry = extensions.wrapcommand(commands.table, 'update',
78 entry = extensions.wrapcommand(commands.table, 'update',
79 overrides.overrideupdate)
79 overrides.overrideupdate)
80 entry = extensions.wrapcommand(commands.table, 'pull',
80 entry = extensions.wrapcommand(commands.table, 'pull',
81 overrides.overridepull)
81 overrides.overridepull)
82 pullopt = [('', 'all-largefiles', None,
82 pullopt = [('', 'all-largefiles', None,
83 _('download all pulled versions of largefiles (DEPRECATED)')),
83 _('download all pulled versions of largefiles (DEPRECATED)')),
84 ('', 'lfrev', [],
84 ('', 'lfrev', [],
85 _('download largefiles for these revisions'), _('REV'))]
85 _('download largefiles for these revisions'), _('REV'))]
86 entry[1].extend(pullopt)
86 entry[1].extend(pullopt)
87 revset.symbols['pulled'] = overrides.pulledrevsetsymbol
87 revset.symbols['pulled'] = overrides.pulledrevsetsymbol
88
88
89 entry = extensions.wrapcommand(commands.table, 'clone',
89 entry = extensions.wrapcommand(commands.table, 'clone',
90 overrides.overrideclone)
90 overrides.overrideclone)
91 cloneopt = [('', 'all-largefiles', None,
91 cloneopt = [('', 'all-largefiles', None,
92 _('download all versions of all largefiles'))]
92 _('download all versions of all largefiles'))]
93 entry[1].extend(cloneopt)
93 entry[1].extend(cloneopt)
94 entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone)
94 entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone)
95
95
96 entry = extensions.wrapcommand(commands.table, 'cat',
96 entry = extensions.wrapcommand(commands.table, 'cat',
97 overrides.overridecat)
97 overrides.overridecat)
98 entry = extensions.wrapfunction(merge, '_checkunknownfile',
98 entry = extensions.wrapfunction(merge, '_checkunknownfile',
99 overrides.overridecheckunknownfile)
99 overrides.overridecheckunknownfile)
100 entry = extensions.wrapfunction(merge, 'calculateupdates',
100 entry = extensions.wrapfunction(merge, 'calculateupdates',
101 overrides.overridecalculateupdates)
101 overrides.overridecalculateupdates)
102 entry = extensions.wrapfunction(merge, 'recordupdates',
102 entry = extensions.wrapfunction(merge, 'recordupdates',
103 overrides.mergerecordupdates)
103 overrides.mergerecordupdates)
104 entry = extensions.wrapfunction(merge, 'update',
104 entry = extensions.wrapfunction(merge, 'update',
105 overrides.mergeupdate)
105 overrides.mergeupdate)
106 entry = extensions.wrapfunction(filemerge, 'filemerge',
106 entry = extensions.wrapfunction(filemerge, 'filemerge',
107 overrides.overridefilemerge)
107 overrides.overridefilemerge)
108 entry = extensions.wrapfunction(cmdutil, 'copy',
108 entry = extensions.wrapfunction(cmdutil, 'copy',
109 overrides.overridecopy)
109 overrides.overridecopy)
110
110
111 # Summary calls dirty on the subrepos
111 # Summary calls dirty on the subrepos
112 entry = extensions.wrapfunction(subrepo.hgsubrepo, 'dirty',
112 entry = extensions.wrapfunction(subrepo.hgsubrepo, 'dirty',
113 overrides.overridedirty)
113 overrides.overridedirty)
114
114
115 # Backout calls revert so we need to override both the command and the
115 # Backout calls revert so we need to override both the command and the
116 # function
116 # function
117 entry = extensions.wrapcommand(commands.table, 'revert',
117 entry = extensions.wrapcommand(commands.table, 'revert',
118 overrides.overriderevert)
118 overrides.overriderevert)
119 entry = extensions.wrapfunction(commands, 'revert',
119 entry = extensions.wrapfunction(commands, 'revert',
120 overrides.overriderevert)
120 overrides.overriderevert)
121
121
122 extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
122 extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
123 extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
123 extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
124 overrides.hgsubrepoarchive)
124 overrides.hgsubrepoarchive)
125 extensions.wrapfunction(cmdutil, 'bailifchanged',
125 extensions.wrapfunction(cmdutil, 'bailifchanged',
126 overrides.overridebailifchanged)
126 overrides.overridebailifchanged)
127
127
128 extensions.wrapfunction(scmutil, 'marktouched',
128 extensions.wrapfunction(scmutil, 'marktouched',
129 overrides.scmutilmarktouched)
129 overrides.scmutilmarktouched)
130
130
131 # create the new wireproto commands ...
131 # create the new wireproto commands ...
132 wireproto.commands['putlfile'] = (proto.putlfile, 'sha')
132 wireproto.commands['putlfile'] = (proto.putlfile, 'sha')
133 wireproto.commands['getlfile'] = (proto.getlfile, 'sha')
133 wireproto.commands['getlfile'] = (proto.getlfile, 'sha')
134 wireproto.commands['statlfile'] = (proto.statlfile, 'sha')
134 wireproto.commands['statlfile'] = (proto.statlfile, 'sha')
135
135
136 # ... and wrap some existing ones
136 # ... and wrap some existing ones
137 wireproto.commands['capabilities'] = (proto.capabilities, '')
137 wireproto.commands['capabilities'] = (proto.capabilities, '')
138 wireproto.commands['heads'] = (proto.heads, '')
138 wireproto.commands['heads'] = (proto.heads, '')
139 wireproto.commands['lheads'] = (wireproto.heads, '')
139 wireproto.commands['lheads'] = (wireproto.heads, '')
140
140
141 # make putlfile behave the same as push and {get,stat}lfile behave
141 # make putlfile behave the same as push and {get,stat}lfile behave
142 # the same as pull w.r.t. permissions checks
142 # the same as pull w.r.t. permissions checks
143 hgweb_mod.perms['putlfile'] = 'push'
143 hgweb_mod.perms['putlfile'] = 'push'
144 hgweb_mod.perms['getlfile'] = 'pull'
144 hgweb_mod.perms['getlfile'] = 'pull'
145 hgweb_mod.perms['statlfile'] = 'pull'
145 hgweb_mod.perms['statlfile'] = 'pull'
146
146
147 extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
147 extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
148
148
149 # the hello wireproto command uses wireproto.capabilities, so it won't see
149 # the hello wireproto command uses wireproto.capabilities, so it won't see
150 # our largefiles capability unless we replace the actual function as well.
150 # our largefiles capability unless we replace the actual function as well.
151 proto.capabilitiesorig = wireproto.capabilities
151 proto.capabilitiesorig = wireproto.capabilities
152 wireproto.capabilities = proto.capabilities
152 wireproto.capabilities = proto.capabilities
153
153
154 # can't do this in reposetup because it needs to have happened before
154 # can't do this in reposetup because it needs to have happened before
155 # wirerepo.__init__ is called
155 # wirerepo.__init__ is called
156 proto.ssholdcallstream = sshpeer.sshpeer._callstream
156 proto.ssholdcallstream = sshpeer.sshpeer._callstream
157 proto.httpoldcallstream = httppeer.httppeer._callstream
157 proto.httpoldcallstream = httppeer.httppeer._callstream
158 sshpeer.sshpeer._callstream = proto.sshrepocallstream
158 sshpeer.sshpeer._callstream = proto.sshrepocallstream
159 httppeer.httppeer._callstream = proto.httprepocallstream
159 httppeer.httppeer._callstream = proto.httprepocallstream
160
160
161 # override some extensions' stuff as well
161 # override some extensions' stuff as well
162 for name, module in extensions.extensions():
162 for name, module in extensions.extensions():
163 if name == 'fetch':
163 if name == 'fetch':
164 extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch',
164 extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch',
165 overrides.overridefetch)
165 overrides.overridefetch)
166 if name == 'purge':
166 if name == 'purge':
167 extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
167 extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
168 overrides.overridepurge)
168 overrides.overridepurge)
169 if name == 'rebase':
169 if name == 'rebase':
170 extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
170 extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
171 overrides.overriderebase)
171 overrides.overriderebase)
172 extensions.wrapfunction(module, 'rebase',
173 overrides.overriderebase)
172 if name == 'transplant':
174 if name == 'transplant':
173 extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant',
175 extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant',
174 overrides.overridetransplant)
176 overrides.overridetransplant)
175 if name == 'convert':
177 if name == 'convert':
176 convcmd = getattr(module, 'convcmd')
178 convcmd = getattr(module, 'convcmd')
177 hgsink = getattr(convcmd, 'mercurial_sink')
179 hgsink = getattr(convcmd, 'mercurial_sink')
178 extensions.wrapfunction(hgsink, 'before',
180 extensions.wrapfunction(hgsink, 'before',
179 overrides.mercurialsinkbefore)
181 overrides.mercurialsinkbefore)
180 extensions.wrapfunction(hgsink, 'after',
182 extensions.wrapfunction(hgsink, 'after',
181 overrides.mercurialsinkafter)
183 overrides.mercurialsinkafter)
General Comments 0
You need to be logged in to leave comments. Login now