uisetup.py
181 lines
| 8.5 KiB
| text/x-python
|
PythonLexer
various
|
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, \ | ||||
Mads Kiilerich
|
r28878 | httppeer, merge, scmutil, sshpeer, wireproto, subrepo, copies, exchange | ||
various
|
r15168 | from mercurial.i18n import _ | ||
Mads Kiilerich
|
r18298 | from mercurial.hgweb import hgweb_mod, webcommands | ||
various
|
r15168 | |||
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 | ||||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'add', | ||
Na'Tosha Bard
|
r16247 | overrides.overrideadd) | ||
various
|
r15168 | addopt = [('', 'large', None, _('add as largefile')), | ||
Na'Tosha Bard
|
r15944 | ('', 'normal', None, _('add as normal file')), | ||
Martin Geisler
|
r15627 | ('', 'lfsize', '', _('add all files above this size ' | ||
'(in megabytes) as largefiles ' | ||||
'(default: 10)'))] | ||||
various
|
r15168 | entry[1].extend(addopt) | ||
Matt Harbison
|
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) | ||||
Matt Harbison
|
r23886 | extensions.wrapfunction(cmdutil, 'add', overrides.cmdutiladd) | ||
Matt Harbison
|
r23782 | extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove) | ||
Matt Harbison
|
r23837 | extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget) | ||
Matt Harbison
|
r16515 | |||
Matt Harbison
|
r24230 | extensions.wrapfunction(copies, 'pathcopies', overrides.copiespathcopies) | ||
Matt Harbison
|
r16515 | # Subrepos call status function | ||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'status', | ||
Na'Tosha Bard
|
r16247 | overrides.overridestatus) | ||
Mads Kiilerich
|
r21084 | entry = extensions.wrapfunction(subrepo.hgsubrepo, 'status', | ||
Matt Harbison
|
r16515 | overrides.overridestatusfn) | ||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'log', | ||
Na'Tosha Bard
|
r16247 | overrides.overridelog) | ||
various
|
r15168 | entry = extensions.wrapcommand(commands.table, 'rollback', | ||
Na'Tosha Bard
|
r16247 | overrides.overriderollback) | ||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'verify', | ||
Na'Tosha Bard
|
r16247 | overrides.overrideverify) | ||
various
|
r15168 | |||
Mads Kiilerich
|
r18547 | verifyopt = [('', 'large', None, | ||
_('verify that all largefiles in current revision exists')), | ||||
various
|
r15168 | ('', 'lfa', None, | ||
Mads Kiilerich
|
r18547 | _('verify largefiles in all revisions, not just current')), | ||
various
|
r15168 | ('', 'lfc', None, | ||
Mads Kiilerich
|
r18547 | _('verify local largefile contents, not just existence'))] | ||
various
|
r15168 | entry[1].extend(verifyopt) | ||
Mads Kiilerich
|
r18144 | entry = extensions.wrapcommand(commands.table, 'debugstate', | ||
overrides.overridedebugstate) | ||||
debugstateopt = [('', 'large', None, _('display largefiles dirstate'))] | ||||
entry[1].extend(debugstateopt) | ||||
FUJIWARA Katsunori
|
r21052 | outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs) | ||
entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing) | ||||
various
|
r15168 | outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] | ||
entry[1].extend(outgoingopt) | ||||
FUJIWARA Katsunori
|
r21052 | cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook) | ||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'summary', | ||
Na'Tosha Bard
|
r16247 | overrides.overridesummary) | ||
various
|
r15168 | summaryopt = [('', 'large', None, _('display outgoing largefiles'))] | ||
entry[1].extend(summaryopt) | ||||
FUJIWARA Katsunori
|
r21048 | cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook) | ||
various
|
r15168 | |||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'pull', | ||
Na'Tosha Bard
|
r16247 | overrides.overridepull) | ||
Na'Tosha Bard
|
r16692 | pullopt = [('', 'all-largefiles', None, | ||
Mads Kiilerich
|
r18982 | _('download all pulled versions of largefiles (DEPRECATED)')), | ||
Mads Kiilerich
|
r18978 | ('', 'lfrev', [], | ||
_('download largefiles for these revisions'), _('REV'))] | ||||
Na'Tosha Bard
|
r16692 | entry[1].extend(pullopt) | ||
Mads Kiilerich
|
r18979 | |||
Mads Kiilerich
|
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) | ||||
Na'Tosha Bard
|
r16644 | entry = extensions.wrapcommand(commands.table, 'clone', | ||
overrides.overrideclone) | ||||
cloneopt = [('', 'all-largefiles', None, | ||||
_('download all versions of all largefiles'))] | ||||
Matt Harbison
|
r17601 | entry[1].extend(cloneopt) | ||
entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone) | ||||
Na'Tosha Bard
|
r16644 | |||
Na'Tosha Bard
|
r16439 | entry = extensions.wrapcommand(commands.table, 'cat', | ||
overrides.overridecat) | ||||
Matt Mackall
|
r16093 | entry = extensions.wrapfunction(merge, '_checkunknownfile', | ||
Na'Tosha Bard
|
r16247 | overrides.overridecheckunknownfile) | ||
Mads Kiilerich
|
r20638 | entry = extensions.wrapfunction(merge, 'calculateupdates', | ||
overrides.overridecalculateupdates) | ||||
FUJIWARA Katsunori
|
r22196 | entry = extensions.wrapfunction(merge, 'recordupdates', | ||
overrides.mergerecordupdates) | ||||
FUJIWARA Katsunori
|
r22288 | entry = extensions.wrapfunction(merge, 'update', | ||
overrides.mergeupdate) | ||||
Siddharth Agarwal
|
r26605 | entry = extensions.wrapfunction(filemerge, '_filemerge', | ||
Na'Tosha Bard
|
r16247 | overrides.overridefilemerge) | ||
Matt Mackall
|
r15170 | entry = extensions.wrapfunction(cmdutil, 'copy', | ||
Na'Tosha Bard
|
r16247 | overrides.overridecopy) | ||
various
|
r15168 | |||
Matt Harbison
|
r16516 | # Summary calls dirty on the subrepos | ||
Mads Kiilerich
|
r21084 | entry = extensions.wrapfunction(subrepo.hgsubrepo, 'dirty', | ||
Matt Harbison
|
r16516 | overrides.overridedirty) | ||
Martin von Zweigbergk
|
r24436 | entry = extensions.wrapfunction(cmdutil, 'revert', | ||
Na'Tosha Bard
|
r16247 | overrides.overriderevert) | ||
various
|
r15168 | |||
Matt Harbison
|
r25811 | extensions.wrapcommand(commands.table, 'archive', | ||
overrides.overridearchivecmd) | ||||
Na'Tosha Bard
|
r16247 | extensions.wrapfunction(archival, 'archive', overrides.overridearchive) | ||
Mads Kiilerich
|
r21084 | extensions.wrapfunction(subrepo.hgsubrepo, 'archive', | ||
overrides.hgsubrepoarchive) | ||||
Matt Harbison
|
r26417 | extensions.wrapfunction(webcommands, 'archive', | ||
overrides.hgwebarchive) | ||||
Greg Ward
|
r15349 | extensions.wrapfunction(cmdutil, 'bailifchanged', | ||
Na'Tosha Bard
|
r16247 | overrides.overridebailifchanged) | ||
various
|
r15168 | |||
Matt Harbison
|
r27944 | extensions.wrapfunction(cmdutil, 'postcommitstatus', | ||
overrides.postcommitstatus) | ||||
FUJIWARA Katsunori
|
r22289 | extensions.wrapfunction(scmutil, 'marktouched', | ||
overrides.scmutilmarktouched) | ||||
various
|
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, '') | ||||
Greg Ward
|
r15254 | # make putlfile behave the same as push and {get,stat}lfile behave | ||
# the same as pull w.r.t. permissions checks | ||||
various
|
r15168 | hgweb_mod.perms['putlfile'] = 'push' | ||
hgweb_mod.perms['getlfile'] = 'pull' | ||||
hgweb_mod.perms['statlfile'] = 'pull' | ||||
Martin Geisler
|
r16449 | extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath) | ||
various
|
r15168 | # the hello wireproto command uses wireproto.capabilities, so it won't see | ||
# our largefiles capability unless we replace the actual function as well. | ||||
Na'Tosha Bard
|
r16247 | proto.capabilitiesorig = wireproto.capabilities | ||
various
|
r15168 | wireproto.capabilities = proto.capabilities | ||
# can't do this in reposetup because it needs to have happened before | ||||
# wirerepo.__init__ is called | ||||
Peter Arrenbrecht
|
r17192 | proto.ssholdcallstream = sshpeer.sshpeer._callstream | ||
proto.httpoldcallstream = httppeer.httppeer._callstream | ||||
sshpeer.sshpeer._callstream = proto.sshrepocallstream | ||||
httppeer.httppeer._callstream = proto.httprepocallstream | ||||
various
|
r15168 | |||
# override some extensions' stuff as well | ||||
for name, module in extensions.extensions(): | ||||
if name == 'purge': | ||||
extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge', | ||||
Na'Tosha Bard
|
r16247 | overrides.overridepurge) | ||
various
|
r15168 | if name == 'rebase': | ||
extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', | ||||
Na'Tosha Bard
|
r16247 | overrides.overriderebase) | ||
FUJIWARA Katsunori
|
r23182 | extensions.wrapfunction(module, 'rebase', | ||
overrides.overriderebase) | ||||
Na'Tosha Bard
|
r15383 | if name == 'transplant': | ||
extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', | ||||
Na'Tosha Bard
|
r16247 | overrides.overridetransplant) | ||