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