uisetup.py
202 lines
| 8.3 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 ( | ||||
webcommands, | ||||
) | ||||
|
r15168 | |||
|
r29315 | from mercurial import ( | ||
archival, | ||||
cmdutil, | ||||
commands, | ||||
copies, | ||||
exchange, | ||||
extensions, | ||||
filemerge, | ||||
hg, | ||||
httppeer, | ||||
merge, | ||||
scmutil, | ||||
sshpeer, | ||||
subrepo, | ||||
|
r35304 | upgrade, | ||
|
r35580 | url, | ||
|
r29315 | wireproto, | ||
) | ||||
from . import ( | ||||
overrides, | ||||
proto, | ||||
) | ||||
|
r15168 | |||
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) | ||
|
r17658 | # The scmutil function is called both by the (trivial) addremove command, | ||
# and in the process of handling commit -A (issue3542) | ||||
|
r34077 | 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) | ||
|
r35304 | extensions.wrapfunction(upgrade, 'preservedrequirements', | ||
overrides.upgraderequirements) | ||||
extensions.wrapfunction(upgrade, 'supporteddestrequirements', | ||||
overrides.upgraderequirements) | ||||
|
r16515 | # Subrepos call status function | ||
|
r15170 | entry = extensions.wrapcommand(commands.table, 'status', | ||
|
r16247 | overrides.overridestatus) | ||
|
r34077 | extensions.wrapfunction(subrepo.hgsubrepo, 'status', | ||
overrides.overridestatusfn) | ||||
|
r16515 | |||
|
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) | ||||
|
r34077 | extensions.wrapfunction(exchange, 'pushoperation', | ||
overrides.exchangepushoperation) | ||||
|
r28878 | |||
|
r16644 | entry = extensions.wrapcommand(commands.table, 'clone', | ||
overrides.overrideclone) | ||||
cloneopt = [('', 'all-largefiles', None, | ||||
_('download all versions of all largefiles'))] | ||||
|
r17601 | entry[1].extend(cloneopt) | ||
|
r34077 | extensions.wrapfunction(hg, 'clone', overrides.hgclone) | ||
extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare) | ||||
|
r16644 | |||
|
r16439 | entry = extensions.wrapcommand(commands.table, 'cat', | ||
overrides.overridecat) | ||||
|
r34077 | extensions.wrapfunction(merge, '_checkunknownfile', | ||
overrides.overridecheckunknownfile) | ||||
extensions.wrapfunction(merge, 'calculateupdates', | ||||
overrides.overridecalculateupdates) | ||||
extensions.wrapfunction(merge, 'recordupdates', | ||||
overrides.mergerecordupdates) | ||||
extensions.wrapfunction(merge, 'update', overrides.mergeupdate) | ||||
extensions.wrapfunction(filemerge, '_filemerge', | ||||
overrides.overridefilemerge) | ||||
extensions.wrapfunction(cmdutil, 'copy', overrides.overridecopy) | ||||
|
r15168 | |||
|
r16516 | # Summary calls dirty on the subrepos | ||
|
r34077 | extensions.wrapfunction(subrepo.hgsubrepo, 'dirty', overrides.overridedirty) | ||
|
r16516 | |||
|
r34077 | extensions.wrapfunction(cmdutil, 'revert', 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) | ||||
|
r34077 | 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) | ||||
|
r35580 | extensions.wrapfunction(url, 'open', | ||
overrides.openlargefile) | ||||
|
r15168 | # create the new wireproto commands ... | ||
|
r36818 | wireproto.wireprotocommand('putlfile', 'sha', permission='push')( | ||
proto.putlfile) | ||||
wireproto.wireprotocommand('getlfile', 'sha', permission='pull')( | ||||
proto.getlfile) | ||||
wireproto.wireprotocommand('statlfile', 'sha', permission='pull')( | ||||
proto.statlfile) | ||||
wireproto.wireprotocommand('lheads', '', permission='pull')( | ||||
wireproto.heads) | ||||
|
r15168 | |||
# ... and wrap some existing ones | ||||
|
r36001 | wireproto.commands['heads'].func = proto.heads | ||
|
r15168 | |||
|
r16449 | extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath) | ||
|
r35523 | extensions.wrapfunction(wireproto, '_capabilities', proto._capabilities) | ||
|
r15168 | |||
# can't do this in reposetup because it needs to have happened before | ||||
# wirerepo.__init__ is called | ||||
|
r35995 | proto.ssholdcallstream = sshpeer.sshv1peer._callstream | ||
|
r17192 | proto.httpoldcallstream = httppeer.httppeer._callstream | ||
|
r35995 | sshpeer.sshv1peer._callstream = proto.sshrepocallstream | ||
|
r17192 | 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) | ||