uisetup.py
210 lines
| 8.9 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''' | ||||
|
r29315 | from __future__ import absolute_import | ||
|
r15168 | |||
from mercurial.i18n import _ | ||||
|
r29315 | |||
from mercurial.hgweb import ( | ||||
hgweb_mod, | ||||
webcommands, | ||||
) | ||||
|
r15168 | |||
|
r29315 | from mercurial import ( | ||
archival, | ||||
cmdutil, | ||||
commands, | ||||
copies, | ||||
|
r32180 | debugcommands, | ||
|
r29315 | exchange, | ||
extensions, | ||||
filemerge, | ||||
hg, | ||||
httppeer, | ||||
merge, | ||||
scmutil, | ||||
sshpeer, | ||||
subrepo, | ||||
wireproto, | ||||
) | ||||
from . import ( | ||||
overrides, | ||||
proto, | ||||
) | ||||
|
r15168 | |||
def uisetup(ui): | ||||
|
r32180 | # TODO: debugcommands should use a separate command table | ||
# Side-effect of accessing is debugcommands module is guaranteed to be | ||||
# imported and commands.table is populated. | ||||
debugcommands.command | ||||
|
r15168 | # 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) | ||
|
r17658 | # The scmutil function is called both by the (trivial) addremove command, | ||
# and in the process of handling commit -A (issue3542) | ||||
entry = extensions.wrapfunction(scmutil, 'addremove', | ||||
overrides.scmutiladdremove) | ||||
|
r23886 | extensions.wrapfunction(cmdutil, 'add', overrides.cmdutiladd) | ||
|
r23782 | extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove) | ||
|
r23837 | extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget) | ||
|
r16515 | |||
|
r24230 | extensions.wrapfunction(copies, 'pathcopies', overrides.copiespathcopies) | ||
|
r16515 | # Subrepos call status function | ||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'status', | ||
|
r16247 | overrides.overridestatus) | ||
|
r21084 | entry = extensions.wrapfunction(subrepo.hgsubrepo, 'status', | ||
|
r16515 | overrides.overridestatusfn) | ||
|
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 | |||
|
r18547 | verifyopt = [('', 'large', None, | ||
_('verify that all largefiles in current revision exists')), | ||||
|
r15168 | ('', 'lfa', None, | ||
|
r18547 | _('verify largefiles in all revisions, not just current')), | ||
|
r15168 | ('', 'lfc', None, | ||
|
r18547 | _('verify local largefile contents, not just existence'))] | ||
|
r15168 | entry[1].extend(verifyopt) | ||
|
r18144 | entry = extensions.wrapcommand(commands.table, 'debugstate', | ||
overrides.overridedebugstate) | ||||
debugstateopt = [('', 'large', None, _('display largefiles dirstate'))] | ||||
entry[1].extend(debugstateopt) | ||||
|
r21052 | outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs) | ||
entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing) | ||||
|
r15168 | outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] | ||
entry[1].extend(outgoingopt) | ||||
|
r21052 | cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook) | ||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'summary', | ||
|
r16247 | overrides.overridesummary) | ||
|
r15168 | summaryopt = [('', 'large', None, _('display outgoing largefiles'))] | ||
entry[1].extend(summaryopt) | ||||
|
r21048 | cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook) | ||
|
r15168 | |||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'pull', | ||
|
r16247 | overrides.overridepull) | ||
|
r16692 | pullopt = [('', 'all-largefiles', None, | ||
|
r18982 | _('download all pulled versions of largefiles (DEPRECATED)')), | ||
|
r18978 | ('', 'lfrev', [], | ||
_('download largefiles for these revisions'), _('REV'))] | ||||
|
r16692 | entry[1].extend(pullopt) | ||
|
r18979 | |||
|
r28878 | entry = extensions.wrapcommand(commands.table, 'push', | ||
overrides.overridepush) | ||||
pushopt = [('', 'lfrev', [], | ||||
_('upload largefiles for these revisions'), _('REV'))] | ||||
entry[1].extend(pushopt) | ||||
entry = extensions.wrapfunction(exchange, 'pushoperation', | ||||
overrides.exchangepushoperation) | ||||
|
r16644 | entry = extensions.wrapcommand(commands.table, 'clone', | ||
overrides.overrideclone) | ||||
cloneopt = [('', 'all-largefiles', None, | ||||
_('download all versions of all largefiles'))] | ||||
|
r17601 | entry[1].extend(cloneopt) | ||
entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone) | ||||
|
r31892 | entry = extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare) | ||
|
r16644 | |||
|
r16439 | entry = extensions.wrapcommand(commands.table, 'cat', | ||
overrides.overridecat) | ||||
|
r16093 | entry = extensions.wrapfunction(merge, '_checkunknownfile', | ||
|
r16247 | overrides.overridecheckunknownfile) | ||
|
r20638 | entry = extensions.wrapfunction(merge, 'calculateupdates', | ||
overrides.overridecalculateupdates) | ||||
|
r22196 | entry = extensions.wrapfunction(merge, 'recordupdates', | ||
overrides.mergerecordupdates) | ||||
|
r22288 | entry = extensions.wrapfunction(merge, 'update', | ||
overrides.mergeupdate) | ||||
|
r26605 | entry = extensions.wrapfunction(filemerge, '_filemerge', | ||
|
r16247 | overrides.overridefilemerge) | ||
|
r15170 | entry = extensions.wrapfunction(cmdutil, 'copy', | ||
|
r16247 | overrides.overridecopy) | ||
|
r15168 | |||
|
r16516 | # Summary calls dirty on the subrepos | ||
|
r21084 | entry = extensions.wrapfunction(subrepo.hgsubrepo, 'dirty', | ||
|
r16516 | overrides.overridedirty) | ||
|
r24436 | entry = extensions.wrapfunction(cmdutil, 'revert', | ||
|
r16247 | overrides.overriderevert) | ||
|
r15168 | |||
|
r25811 | extensions.wrapcommand(commands.table, 'archive', | ||
overrides.overridearchivecmd) | ||||
|
r16247 | extensions.wrapfunction(archival, 'archive', overrides.overridearchive) | ||
|
r21084 | extensions.wrapfunction(subrepo.hgsubrepo, 'archive', | ||
overrides.hgsubrepoarchive) | ||||
|
r26417 | extensions.wrapfunction(webcommands, 'archive', | ||
overrides.hgwebarchive) | ||||
|
r15349 | extensions.wrapfunction(cmdutil, 'bailifchanged', | ||
|
r16247 | overrides.overridebailifchanged) | ||
|
r15168 | |||
|
r27944 | extensions.wrapfunction(cmdutil, 'postcommitstatus', | ||
overrides.postcommitstatus) | ||||
|
r22289 | extensions.wrapfunction(scmutil, 'marktouched', | ||
overrides.scmutilmarktouched) | ||||
|
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' | ||||
|
r16449 | extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath) | ||
|
r15168 | # 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 | ||
# can't do this in reposetup because it needs to have happened before | ||||
# wirerepo.__init__ is called | ||||
|
r17192 | proto.ssholdcallstream = sshpeer.sshpeer._callstream | ||
proto.httpoldcallstream = httppeer.httppeer._callstream | ||||
sshpeer.sshpeer._callstream = proto.sshrepocallstream | ||||
httppeer.httppeer._callstream = proto.httprepocallstream | ||||
|
r15168 | |||
# override some extensions' stuff as well | ||||
for name, module in extensions.extensions(): | ||||
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) | ||
|
r23182 | extensions.wrapfunction(module, 'rebase', | ||
overrides.overriderebase) | ||||
|
r15383 | if name == 'transplant': | ||
extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', | ||||
|
r16247 | overrides.overridetransplant) | ||