author | Mads Kiilerich <mads@kiilerich.com> |
Sun, 31 Oct 2010 18:29:55 +0100 | |
changeset 15245 | aa2c35057f47 |
parent 15188 | 8e115063950d |
child 15252 | 6e809bb4f969 |
permissions | -rw-r--r-- |
15168 | 1 |
# Copyright 2009-2010 Gregory P. Ward |
2 |
# Copyright 2009-2010 Intelerad Medical Systems Incorporated |
|
3 |
# Copyright 2010-2011 Fog Creek Software |
|
4 |
# Copyright 2010-2011 Unity Technologies |
|
5 |
# |
|
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. |
|
8 |
||
9 |
'''setup for largefiles extension: uisetup''' |
|
10 |
||
11 |
from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \ |
|
15188
8e115063950d
largefiles: don't break existing tests (syntax error, bad imports)
Greg Ward <greg@gerg.ca>
parents:
15170
diff
changeset
|
12 |
httprepo, localrepo, sshrepo, sshserver, util, wireproto |
15168 | 13 |
from mercurial.i18n import _ |
14 |
from mercurial.hgweb import hgweb_mod, protocol |
|
15 |
||
16 |
import overrides |
|
17 |
import proto |
|
18 |
||
19 |
def uisetup(ui): |
|
20 |
# Disable auto-status for some commands which assume that all |
|
21 |
# files in the result are under Mercurial's control |
|
22 |
||
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
23 |
entry = extensions.wrapcommand(commands.table, 'add', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
24 |
overrides.override_add) |
15168 | 25 |
addopt = [('', 'large', None, _('add as largefile')), |
26 |
('', 'lfsize', '', _('add all files above this size (in megabytes)' |
|
27 |
'as largefiles (default: 10)'))] |
|
28 |
entry[1].extend(addopt) |
|
29 |
||
30 |
entry = extensions.wrapcommand(commands.table, 'addremove', |
|
31 |
overrides.override_addremove) |
|
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
32 |
entry = extensions.wrapcommand(commands.table, 'remove', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
33 |
overrides.override_remove) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
34 |
entry = extensions.wrapcommand(commands.table, 'forget', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
35 |
overrides.override_forget) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
36 |
entry = extensions.wrapcommand(commands.table, 'status', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
37 |
overrides.override_status) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
38 |
entry = extensions.wrapcommand(commands.table, 'log', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
39 |
overrides.override_log) |
15168 | 40 |
entry = extensions.wrapcommand(commands.table, 'rollback', |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
41 |
overrides.override_rollback) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
42 |
entry = extensions.wrapcommand(commands.table, 'verify', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
43 |
overrides.override_verify) |
15168 | 44 |
|
45 |
verifyopt = [('', 'large', None, _('verify largefiles')), |
|
46 |
('', 'lfa', None, |
|
47 |
_('verify all revisions of largefiles not just current')), |
|
48 |
('', 'lfc', None, |
|
49 |
_('verify largefile contents not just existence'))] |
|
50 |
entry[1].extend(verifyopt) |
|
51 |
||
52 |
entry = extensions.wrapcommand(commands.table, 'outgoing', |
|
53 |
overrides.override_outgoing) |
|
54 |
outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] |
|
55 |
entry[1].extend(outgoingopt) |
|
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
56 |
entry = extensions.wrapcommand(commands.table, 'summary', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
57 |
overrides.override_summary) |
15168 | 58 |
summaryopt = [('', 'large', None, _('display outgoing largefiles'))] |
59 |
entry[1].extend(summaryopt) |
|
60 |
||
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
61 |
entry = extensions.wrapcommand(commands.table, 'update', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
62 |
overrides.override_update) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
63 |
entry = extensions.wrapcommand(commands.table, 'pull', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
64 |
overrides.override_pull) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
65 |
entry = extensions.wrapfunction(filemerge, 'filemerge', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
66 |
overrides.override_filemerge) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
67 |
entry = extensions.wrapfunction(cmdutil, 'copy', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
68 |
overrides.override_copy) |
15168 | 69 |
|
70 |
# Backout calls revert so we need to override both the command and the |
|
71 |
# function |
|
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
72 |
entry = extensions.wrapcommand(commands.table, 'revert', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
73 |
overrides.override_revert) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
74 |
entry = extensions.wrapfunction(commands, 'revert', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
75 |
overrides.override_revert) |
15168 | 76 |
|
77 |
# clone uses hg._update instead of hg.update even though they are the |
|
78 |
# same function... so wrap both of them) |
|
79 |
extensions.wrapfunction(hg, 'update', overrides.hg_update) |
|
80 |
extensions.wrapfunction(hg, '_update', overrides.hg_update) |
|
81 |
extensions.wrapfunction(hg, 'clean', overrides.hg_clean) |
|
82 |
extensions.wrapfunction(hg, 'merge', overrides.hg_merge) |
|
83 |
||
84 |
extensions.wrapfunction(archival, 'archive', overrides.override_archive) |
|
15169
aa262fff87ac
largefile: fix up hasattr usage
Matt Mackall <mpm@selenic.com>
parents:
15168
diff
changeset
|
85 |
if util.safehasattr(cmdutil, 'bailifchanged'): |
15168 | 86 |
extensions.wrapfunction(cmdutil, 'bailifchanged', |
87 |
overrides.override_bailifchanged) |
|
88 |
else: |
|
89 |
extensions.wrapfunction(cmdutil, 'bail_if_changed', |
|
90 |
overrides.override_bailifchanged) |
|
91 |
||
92 |
# create the new wireproto commands ... |
|
93 |
wireproto.commands['putlfile'] = (proto.putlfile, 'sha') |
|
94 |
wireproto.commands['getlfile'] = (proto.getlfile, 'sha') |
|
95 |
wireproto.commands['statlfile'] = (proto.statlfile, 'sha') |
|
96 |
||
97 |
# ... and wrap some existing ones |
|
98 |
wireproto.commands['capabilities'] = (proto.capabilities, '') |
|
99 |
wireproto.commands['heads'] = (proto.heads, '') |
|
100 |
wireproto.commands['lheads'] = (wireproto.heads, '') |
|
101 |
||
102 |
# make putlfile behave the same as push and {get,stat}lfile behave the same |
|
103 |
# as pull w.r.t. permissions checks |
|
104 |
hgweb_mod.perms['putlfile'] = 'push' |
|
105 |
hgweb_mod.perms['getlfile'] = 'pull' |
|
106 |
hgweb_mod.perms['statlfile'] = 'pull' |
|
107 |
||
108 |
# the hello wireproto command uses wireproto.capabilities, so it won't see |
|
109 |
# our largefiles capability unless we replace the actual function as well. |
|
110 |
proto.capabilities_orig = wireproto.capabilities |
|
111 |
wireproto.capabilities = proto.capabilities |
|
112 |
||
113 |
# these let us reject non-lfiles clients and make them display our error |
|
114 |
# messages |
|
115 |
protocol.webproto.refuseclient = proto.webproto_refuseclient |
|
116 |
sshserver.sshserver.refuseclient = proto.sshproto_refuseclient |
|
117 |
||
118 |
# can't do this in reposetup because it needs to have happened before |
|
119 |
# wirerepo.__init__ is called |
|
120 |
proto.ssh_oldcallstream = sshrepo.sshrepository._callstream |
|
121 |
proto.http_oldcallstream = httprepo.httprepository._callstream |
|
122 |
sshrepo.sshrepository._callstream = proto.sshrepo_callstream |
|
123 |
httprepo.httprepository._callstream = proto.httprepo_callstream |
|
124 |
||
125 |
# don't die on seeing a repo with the largefiles requirement |
|
126 |
localrepo.localrepository.supported |= set(['largefiles']) |
|
127 |
||
128 |
# override some extensions' stuff as well |
|
129 |
for name, module in extensions.extensions(): |
|
130 |
if name == 'fetch': |
|
131 |
extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch', |
|
132 |
overrides.override_fetch) |
|
133 |
if name == 'purge': |
|
134 |
extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge', |
|
135 |
overrides.override_purge) |
|
136 |
if name == 'rebase': |
|
137 |
extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', |
|
138 |
overrides.override_rebase) |