uisetup.py
182 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, \ | ||||
Matt Harbison
|
r17658 | httppeer, localrepo, merge, scmutil, sshpeer, sshserver, wireproto | ||
various
|
r15168 | from mercurial.i18n import _ | ||
Martin Geisler
|
r16449 | from mercurial.hgweb import hgweb_mod, protocol, webcommands | ||
Matt Harbison
|
r16515 | from mercurial.subrepo import hgsubrepo | ||
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 Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'remove', | ||
Na'Tosha Bard
|
r16247 | overrides.overrideremove) | ||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'forget', | ||
Na'Tosha Bard
|
r16247 | overrides.overrideforget) | ||
Matt Harbison
|
r16515 | |||
# Subrepos call status function | ||||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'status', | ||
Na'Tosha Bard
|
r16247 | overrides.overridestatus) | ||
Matt Harbison
|
r16515 | entry = extensions.wrapfunction(hgsubrepo, 'status', | ||
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 | |||
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) | ||||
Mads Kiilerich
|
r18144 | entry = extensions.wrapcommand(commands.table, 'debugstate', | ||
overrides.overridedebugstate) | ||||
debugstateopt = [('', 'large', None, _('display largefiles dirstate'))] | ||||
entry[1].extend(debugstateopt) | ||||
various
|
r15168 | entry = extensions.wrapcommand(commands.table, 'outgoing', | ||
Na'Tosha Bard
|
r16247 | overrides.overrideoutgoing) | ||
various
|
r15168 | outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] | ||
entry[1].extend(outgoingopt) | ||||
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) | ||||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'update', | ||
Na'Tosha Bard
|
r16247 | overrides.overrideupdate) | ||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'pull', | ||
Na'Tosha Bard
|
r16247 | overrides.overridepull) | ||
Na'Tosha Bard
|
r16692 | pullopt = [('', 'all-largefiles', None, | ||
_('download all pulled versions of largefiles'))] | ||||
entry[1].extend(pullopt) | ||||
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) | ||
Martin Geisler
|
r15663 | entry = extensions.wrapfunction(merge, 'manifestmerge', | ||
Na'Tosha Bard
|
r16247 | overrides.overridemanifestmerge) | ||
Matt Mackall
|
r15170 | 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 | ||
entry = extensions.wrapfunction(hgsubrepo, 'dirty', | ||||
overrides.overridedirty) | ||||
various
|
r15168 | # Backout calls revert so we need to override both the command and the | ||
# function | ||||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'revert', | ||
Na'Tosha Bard
|
r16247 | overrides.overriderevert) | ||
Matt Mackall
|
r15170 | entry = extensions.wrapfunction(commands, 'revert', | ||
Na'Tosha Bard
|
r16247 | overrides.overriderevert) | ||
various
|
r15168 | |||
# clone uses hg._update instead of hg.update even though they are the | ||||
# same function... so wrap both of them) | ||||
Na'Tosha Bard
|
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) | ||||
various
|
r15168 | |||
Na'Tosha Bard
|
r16247 | extensions.wrapfunction(archival, 'archive', overrides.overridearchive) | ||
Matt Harbison
|
r16578 | extensions.wrapfunction(hgsubrepo, 'archive', overrides.hgsubrepoarchive) | ||
Greg Ward
|
r15349 | extensions.wrapfunction(cmdutil, 'bailifchanged', | ||
Na'Tosha Bard
|
r16247 | overrides.overridebailifchanged) | ||
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 | ||
Greg Ward
|
r15252 | # these let us reject non-largefiles clients and make them display | ||
# our error messages | ||||
Na'Tosha Bard
|
r16247 | protocol.webproto.refuseclient = proto.webprotorefuseclient | ||
sshserver.sshserver.refuseclient = proto.sshprotorefuseclient | ||||
various
|
r15168 | |||
# 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 | |||
# 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', | ||||
Na'Tosha Bard
|
r16247 | overrides.overridefetch) | ||
various
|
r15168 | 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) | ||
Na'Tosha Bard
|
r15383 | if name == 'transplant': | ||
extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', | ||||
Na'Tosha Bard
|
r16247 | overrides.overridetransplant) | ||
Matt Harbison
|
r17878 | if name == 'convert': | ||
convcmd = getattr(module, 'convcmd') | ||||
hgsink = getattr(convcmd, 'mercurial_sink') | ||||
extensions.wrapfunction(hgsink, 'before', | ||||
overrides.mercurialsinkbefore) | ||||
extensions.wrapfunction(hgsink, 'after', | ||||
overrides.mercurialsinkafter) | ||||