uisetup.py
143 lines
| 6.6 KiB
| text/x-python
|
PythonLexer
|
r15168 | # Copyright 2009-2010 Gregory P. Ward | ||
# Copyright 2009-2010 Intelerad Medical Systems Incorporated | ||||
# Copyright 2010-2011 Fog Creek Software | ||||
# Copyright 2010-2011 Unity Technologies | ||||
# | ||||
# This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | ||||
'''setup for largefiles extension: uisetup''' | ||||
from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \ | ||||
|
r15663 | httprepo, localrepo, merge, sshrepo, sshserver, wireproto | ||
|
r15168 | from mercurial.i18n import _ | ||
from mercurial.hgweb import hgweb_mod, protocol | ||||
import overrides | ||||
import proto | ||||
def uisetup(ui): | ||||
# Disable auto-status for some commands which assume that all | ||||
# files in the result are under Mercurial's control | ||||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'add', | ||
|
r16247 | overrides.overrideadd) | ||
|
r15168 | addopt = [('', 'large', None, _('add as largefile')), | ||
|
r15944 | ('', 'normal', None, _('add as normal file')), | ||
|
r15627 | ('', 'lfsize', '', _('add all files above this size ' | ||
'(in megabytes) as largefiles ' | ||||
'(default: 10)'))] | ||||
|
r15168 | entry[1].extend(addopt) | ||
entry = extensions.wrapcommand(commands.table, 'addremove', | ||||
|
r16247 | overrides.overrideaddremove) | ||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'remove', | ||
|
r16247 | overrides.overrideremove) | ||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'forget', | ||
|
r16247 | overrides.overrideforget) | ||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'status', | ||
|
r16247 | overrides.overridestatus) | ||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'log', | ||
|
r16247 | overrides.overridelog) | ||
|
r15168 | entry = extensions.wrapcommand(commands.table, 'rollback', | ||
|
r16247 | overrides.overriderollback) | ||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'verify', | ||
|
r16247 | overrides.overrideverify) | ||
|
r15168 | |||
verifyopt = [('', 'large', None, _('verify largefiles')), | ||||
('', 'lfa', None, | ||||
_('verify all revisions of largefiles not just current')), | ||||
('', 'lfc', None, | ||||
_('verify largefile contents not just existence'))] | ||||
entry[1].extend(verifyopt) | ||||
entry = extensions.wrapcommand(commands.table, 'outgoing', | ||||
|
r16247 | overrides.overrideoutgoing) | ||
|
r15168 | outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] | ||
entry[1].extend(outgoingopt) | ||||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'summary', | ||
|
r16247 | overrides.overridesummary) | ||
|
r15168 | summaryopt = [('', 'large', None, _('display outgoing largefiles'))] | ||
entry[1].extend(summaryopt) | ||||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'update', | ||
|
r16247 | overrides.overrideupdate) | ||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'pull', | ||
|
r16247 | overrides.overridepull) | ||
|
r16093 | entry = extensions.wrapfunction(merge, '_checkunknownfile', | ||
|
r16247 | overrides.overridecheckunknownfile) | ||
|
r15663 | entry = extensions.wrapfunction(merge, 'manifestmerge', | ||
|
r16247 | overrides.overridemanifestmerge) | ||
|
r15170 | entry = extensions.wrapfunction(filemerge, 'filemerge', | ||
|
r16247 | overrides.overridefilemerge) | ||
|
r15170 | entry = extensions.wrapfunction(cmdutil, 'copy', | ||
|
r16247 | overrides.overridecopy) | ||
|
r15168 | |||
# Backout calls revert so we need to override both the command and the | ||||
# function | ||||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'revert', | ||
|
r16247 | overrides.overriderevert) | ||
|
r15170 | entry = extensions.wrapfunction(commands, 'revert', | ||
|
r16247 | overrides.overriderevert) | ||
|
r15168 | |||
# clone uses hg._update instead of hg.update even though they are the | ||||
# same function... so wrap both of them) | ||||
|
r16247 | extensions.wrapfunction(hg, 'update', overrides.hgupdate) | ||
extensions.wrapfunction(hg, '_update', overrides.hgupdate) | ||||
extensions.wrapfunction(hg, 'clean', overrides.hgclean) | ||||
extensions.wrapfunction(hg, 'merge', overrides.hgmerge) | ||||
|
r15168 | |||
|
r16247 | extensions.wrapfunction(archival, 'archive', overrides.overridearchive) | ||
|
r15349 | extensions.wrapfunction(cmdutil, 'bailifchanged', | ||
|
r16247 | overrides.overridebailifchanged) | ||
|
r15168 | |||
# create the new wireproto commands ... | ||||
wireproto.commands['putlfile'] = (proto.putlfile, 'sha') | ||||
wireproto.commands['getlfile'] = (proto.getlfile, 'sha') | ||||
wireproto.commands['statlfile'] = (proto.statlfile, 'sha') | ||||
# ... and wrap some existing ones | ||||
wireproto.commands['capabilities'] = (proto.capabilities, '') | ||||
wireproto.commands['heads'] = (proto.heads, '') | ||||
wireproto.commands['lheads'] = (wireproto.heads, '') | ||||
|
r15254 | # make putlfile behave the same as push and {get,stat}lfile behave | ||
# the same as pull w.r.t. permissions checks | ||||
|
r15168 | hgweb_mod.perms['putlfile'] = 'push' | ||
hgweb_mod.perms['getlfile'] = 'pull' | ||||
hgweb_mod.perms['statlfile'] = 'pull' | ||||
# the hello wireproto command uses wireproto.capabilities, so it won't see | ||||
# our largefiles capability unless we replace the actual function as well. | ||||
|
r16247 | proto.capabilitiesorig = wireproto.capabilities | ||
|
r15168 | wireproto.capabilities = proto.capabilities | ||
|
r15252 | # these let us reject non-largefiles clients and make them display | ||
# our error messages | ||||
|
r16247 | protocol.webproto.refuseclient = proto.webprotorefuseclient | ||
sshserver.sshserver.refuseclient = proto.sshprotorefuseclient | ||||
|
r15168 | |||
# can't do this in reposetup because it needs to have happened before | ||||
# wirerepo.__init__ is called | ||||
|
r16247 | proto.ssholdcallstream = sshrepo.sshrepository._callstream | ||
proto.httpoldcallstream = httprepo.httprepository._callstream | ||||
sshrepo.sshrepository._callstream = proto.sshrepocallstream | ||||
httprepo.httprepository._callstream = proto.httprepocallstream | ||||
|
r15168 | |||
# don't die on seeing a repo with the largefiles requirement | ||||
localrepo.localrepository.supported |= set(['largefiles']) | ||||
# override some extensions' stuff as well | ||||
for name, module in extensions.extensions(): | ||||
if name == 'fetch': | ||||
extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch', | ||||
|
r16247 | overrides.overridefetch) | ||
|
r15168 | if name == 'purge': | ||
extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge', | ||||
|
r16247 | overrides.overridepurge) | ||
|
r15168 | if name == 'rebase': | ||
extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', | ||||
|
r16247 | overrides.overriderebase) | ||
|
r15383 | if name == 'transplant': | ||
extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', | ||||
|
r16247 | overrides.overridetransplant) | ||