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, \
|
|
12 httprepo, localrepo, sshrepo, sshserver, wireproto
|
|
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
|
|
23 entry = extensions.wrapcommand(commands.table, 'add', overrides.override_add)
|
|
24 addopt = [('', 'large', None, _('add as largefile')),
|
|
25 ('', 'lfsize', '', _('add all files above this size (in megabytes)'
|
|
26 'as largefiles (default: 10)'))]
|
|
27 entry[1].extend(addopt)
|
|
28
|
|
29 entry = extensions.wrapcommand(commands.table, 'addremove',
|
|
30 overrides.override_addremove)
|
|
31 entry = extensions.wrapcommand(commands.table, 'remove', overrides.override_remove)
|
|
32 entry = extensions.wrapcommand(commands.table, 'forget', overrides.override_forget)
|
|
33 entry = extensions.wrapcommand(commands.table, 'status', overrides.override_status)
|
|
34 entry = extensions.wrapcommand(commands.table, 'log', overrides.override_log)
|
|
35 entry = extensions.wrapcommand(commands.table, 'rollback',
|
|
36 overrides.override_rollback)
|
|
37
|
|
38 entry = extensions.wrapcommand(commands.table, 'verify', overrides.override_verify)
|
|
39 verifyopt = [('', 'large', None, _('verify largefiles')),
|
|
40 ('', 'lfa', None,
|
|
41 _('verify all revisions of largefiles not just current')),
|
|
42 ('', 'lfc', None,
|
|
43 _('verify largefile contents not just existence'))]
|
|
44 entry[1].extend(verifyopt)
|
|
45
|
|
46 entry = extensions.wrapcommand(commands.table, 'outgoing',
|
|
47 overrides.override_outgoing)
|
|
48 outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
|
|
49 entry[1].extend(outgoingopt)
|
|
50 entry = extensions.wrapcommand(commands.table, 'summary', overrides.override_summary)
|
|
51 summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
|
|
52 entry[1].extend(summaryopt)
|
|
53
|
|
54 entry = extensions.wrapcommand(commands.table, 'update', overrides.override_update)
|
|
55 entry = extensions.wrapcommand(commands.table, 'pull', overrides.override_pull)
|
|
56 entry = extensions.wrapfunction(filemerge, 'filemerge', overrides.override_filemerge)
|
|
57 entry = extensions.wrapfunction(cmdutil, 'copy', overrides.override_copy)
|
|
58
|
|
59 # Backout calls revert so we need to override both the command and the
|
|
60 # function
|
|
61 entry = extensions.wrapcommand(commands.table, 'revert', overrides.override_revert)
|
|
62 entry = extensions.wrapfunction(commands, 'revert', overrides.override_revert)
|
|
63
|
|
64 # clone uses hg._update instead of hg.update even though they are the
|
|
65 # same function... so wrap both of them)
|
|
66 extensions.wrapfunction(hg, 'update', overrides.hg_update)
|
|
67 extensions.wrapfunction(hg, '_update', overrides.hg_update)
|
|
68 extensions.wrapfunction(hg, 'clean', overrides.hg_clean)
|
|
69 extensions.wrapfunction(hg, 'merge', overrides.hg_merge)
|
|
70
|
|
71 extensions.wrapfunction(archival, 'archive', overrides.override_archive)
|
|
72 if hasattr(cmdutil, 'bailifchanged'):
|
|
73 extensions.wrapfunction(cmdutil, 'bailifchanged',
|
|
74 overrides.override_bailifchanged)
|
|
75 else:
|
|
76 extensions.wrapfunction(cmdutil, 'bail_if_changed',
|
|
77 overrides.override_bailifchanged)
|
|
78
|
|
79 # create the new wireproto commands ...
|
|
80 wireproto.commands['putlfile'] = (proto.putlfile, 'sha')
|
|
81 wireproto.commands['getlfile'] = (proto.getlfile, 'sha')
|
|
82 wireproto.commands['statlfile'] = (proto.statlfile, 'sha')
|
|
83
|
|
84 # ... and wrap some existing ones
|
|
85 wireproto.commands['capabilities'] = (proto.capabilities, '')
|
|
86 wireproto.commands['heads'] = (proto.heads, '')
|
|
87 wireproto.commands['lheads'] = (wireproto.heads, '')
|
|
88
|
|
89 # make putlfile behave the same as push and {get,stat}lfile behave the same
|
|
90 # as pull w.r.t. permissions checks
|
|
91 hgweb_mod.perms['putlfile'] = 'push'
|
|
92 hgweb_mod.perms['getlfile'] = 'pull'
|
|
93 hgweb_mod.perms['statlfile'] = 'pull'
|
|
94
|
|
95 # the hello wireproto command uses wireproto.capabilities, so it won't see
|
|
96 # our largefiles capability unless we replace the actual function as well.
|
|
97 proto.capabilities_orig = wireproto.capabilities
|
|
98 wireproto.capabilities = proto.capabilities
|
|
99
|
|
100 # these let us reject non-lfiles clients and make them display our error
|
|
101 # messages
|
|
102 protocol.webproto.refuseclient = proto.webproto_refuseclient
|
|
103 sshserver.sshserver.refuseclient = proto.sshproto_refuseclient
|
|
104
|
|
105 # can't do this in reposetup because it needs to have happened before
|
|
106 # wirerepo.__init__ is called
|
|
107 proto.ssh_oldcallstream = sshrepo.sshrepository._callstream
|
|
108 proto.http_oldcallstream = httprepo.httprepository._callstream
|
|
109 sshrepo.sshrepository._callstream = proto.sshrepo_callstream
|
|
110 httprepo.httprepository._callstream = proto.httprepo_callstream
|
|
111
|
|
112 # don't die on seeing a repo with the largefiles requirement
|
|
113 localrepo.localrepository.supported |= set(['largefiles'])
|
|
114
|
|
115 # override some extensions' stuff as well
|
|
116 for name, module in extensions.extensions():
|
|
117 if name == 'fetch':
|
|
118 extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch',
|
|
119 overrides.override_fetch)
|
|
120 if name == 'purge':
|
|
121 extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
|
|
122 overrides.override_purge)
|
|
123 if name == 'rebase':
|
|
124 extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
|
|
125 overrides.override_rebase)
|