annotate hgext/largefiles/uisetup.py @ 15168:cfccd3bee7b3

hgext: add largefiles extension This code has a number of contributors and a complicated history prior to its introduction that can be seen by visiting: https://developers.kilnhg.com/Repo/Kiln/largefiles/largefiles http://hg.gerg.ca/hg-bfiles and looking at the included copyright notices and contributors list.
author various
date Sat, 24 Sep 2011 17:35:45 +0200
parents
children aa262fff87ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
1 # Copyright 2009-2010 Gregory P. Ward
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
2 # Copyright 2009-2010 Intelerad Medical Systems Incorporated
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
3 # Copyright 2010-2011 Fog Creek Software
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
4 # Copyright 2010-2011 Unity Technologies
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
5 #
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
6 # This software may be used and distributed according to the terms of the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
7 # GNU General Public License version 2 or any later version.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
8
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
9 '''setup for largefiles extension: uisetup'''
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
10
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
11 from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
12 httprepo, localrepo, sshrepo, sshserver, wireproto
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
13 from mercurial.i18n import _
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
14 from mercurial.hgweb import hgweb_mod, protocol
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
15
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
16 import overrides
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
17 import proto
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
18
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
19 def uisetup(ui):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
20 # Disable auto-status for some commands which assume that all
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
21 # files in the result are under Mercurial's control
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
22
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
23 entry = extensions.wrapcommand(commands.table, 'add', overrides.override_add)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
24 addopt = [('', 'large', None, _('add as largefile')),
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
25 ('', 'lfsize', '', _('add all files above this size (in megabytes)'
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
26 'as largefiles (default: 10)'))]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
27 entry[1].extend(addopt)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
28
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
29 entry = extensions.wrapcommand(commands.table, 'addremove',
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
30 overrides.override_addremove)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
31 entry = extensions.wrapcommand(commands.table, 'remove', overrides.override_remove)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
32 entry = extensions.wrapcommand(commands.table, 'forget', overrides.override_forget)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
33 entry = extensions.wrapcommand(commands.table, 'status', overrides.override_status)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
34 entry = extensions.wrapcommand(commands.table, 'log', overrides.override_log)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
35 entry = extensions.wrapcommand(commands.table, 'rollback',
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
36 overrides.override_rollback)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
37
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
38 entry = extensions.wrapcommand(commands.table, 'verify', overrides.override_verify)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
39 verifyopt = [('', 'large', None, _('verify largefiles')),
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
40 ('', 'lfa', None,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
41 _('verify all revisions of largefiles not just current')),
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
42 ('', 'lfc', None,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
43 _('verify largefile contents not just existence'))]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
44 entry[1].extend(verifyopt)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
45
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
46 entry = extensions.wrapcommand(commands.table, 'outgoing',
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
47 overrides.override_outgoing)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
48 outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
49 entry[1].extend(outgoingopt)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
50 entry = extensions.wrapcommand(commands.table, 'summary', overrides.override_summary)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
51 summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
52 entry[1].extend(summaryopt)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
53
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
54 entry = extensions.wrapcommand(commands.table, 'update', overrides.override_update)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
55 entry = extensions.wrapcommand(commands.table, 'pull', overrides.override_pull)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
56 entry = extensions.wrapfunction(filemerge, 'filemerge', overrides.override_filemerge)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
57 entry = extensions.wrapfunction(cmdutil, 'copy', overrides.override_copy)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
58
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
59 # Backout calls revert so we need to override both the command and the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
60 # function
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
61 entry = extensions.wrapcommand(commands.table, 'revert', overrides.override_revert)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
62 entry = extensions.wrapfunction(commands, 'revert', overrides.override_revert)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
63
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
64 # clone uses hg._update instead of hg.update even though they are the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
65 # same function... so wrap both of them)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
66 extensions.wrapfunction(hg, 'update', overrides.hg_update)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
67 extensions.wrapfunction(hg, '_update', overrides.hg_update)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
68 extensions.wrapfunction(hg, 'clean', overrides.hg_clean)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
69 extensions.wrapfunction(hg, 'merge', overrides.hg_merge)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
70
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
71 extensions.wrapfunction(archival, 'archive', overrides.override_archive)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
72 if hasattr(cmdutil, 'bailifchanged'):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
73 extensions.wrapfunction(cmdutil, 'bailifchanged',
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
74 overrides.override_bailifchanged)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
75 else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
76 extensions.wrapfunction(cmdutil, 'bail_if_changed',
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
77 overrides.override_bailifchanged)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
78
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
79 # create the new wireproto commands ...
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
80 wireproto.commands['putlfile'] = (proto.putlfile, 'sha')
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
81 wireproto.commands['getlfile'] = (proto.getlfile, 'sha')
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
82 wireproto.commands['statlfile'] = (proto.statlfile, 'sha')
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
83
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
84 # ... and wrap some existing ones
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
85 wireproto.commands['capabilities'] = (proto.capabilities, '')
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
86 wireproto.commands['heads'] = (proto.heads, '')
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
87 wireproto.commands['lheads'] = (wireproto.heads, '')
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
88
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
89 # make putlfile behave the same as push and {get,stat}lfile behave the same
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
90 # as pull w.r.t. permissions checks
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
91 hgweb_mod.perms['putlfile'] = 'push'
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
92 hgweb_mod.perms['getlfile'] = 'pull'
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
93 hgweb_mod.perms['statlfile'] = 'pull'
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
94
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
95 # the hello wireproto command uses wireproto.capabilities, so it won't see
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
96 # our largefiles capability unless we replace the actual function as well.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
97 proto.capabilities_orig = wireproto.capabilities
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
98 wireproto.capabilities = proto.capabilities
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
99
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
100 # these let us reject non-lfiles clients and make them display our error
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
101 # messages
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
102 protocol.webproto.refuseclient = proto.webproto_refuseclient
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
103 sshserver.sshserver.refuseclient = proto.sshproto_refuseclient
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
104
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
105 # can't do this in reposetup because it needs to have happened before
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
106 # wirerepo.__init__ is called
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
107 proto.ssh_oldcallstream = sshrepo.sshrepository._callstream
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
108 proto.http_oldcallstream = httprepo.httprepository._callstream
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
109 sshrepo.sshrepository._callstream = proto.sshrepo_callstream
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
110 httprepo.httprepository._callstream = proto.httprepo_callstream
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
111
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
112 # don't die on seeing a repo with the largefiles requirement
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
113 localrepo.localrepository.supported |= set(['largefiles'])
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
114
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
115 # override some extensions' stuff as well
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
116 for name, module in extensions.extensions():
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
117 if name == 'fetch':
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
118 extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch',
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
119 overrides.override_fetch)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
120 if name == 'purge':
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
121 extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
122 overrides.override_purge)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
123 if name == 'rebase':
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
124 extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
125 overrides.override_rebase)