uisetup.py
205 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''' | ||||
liscju
|
r29315 | from __future__ import absolute_import | ||
various
|
r15168 | |||
from mercurial.i18n import _ | ||||
liscju
|
r29315 | |||
from mercurial.hgweb import ( | ||||
hgweb_mod, | ||||
webcommands, | ||||
) | ||||
various
|
r15168 | |||
liscju
|
r29315 | from mercurial import ( | ||
archival, | ||||
cmdutil, | ||||
commands, | ||||
copies, | ||||
exchange, | ||||
extensions, | ||||
filemerge, | ||||
hg, | ||||
httppeer, | ||||
merge, | ||||
scmutil, | ||||
sshpeer, | ||||
subrepo, | ||||
Boris Feld
|
r35304 | upgrade, | ||
Boris Feld
|
r35580 | url, | ||
liscju
|
r29315 | wireproto, | ||
) | ||||
from . import ( | ||||
overrides, | ||||
proto, | ||||
) | ||||
various
|
r15168 | |||
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) | ||||
Martin von Zweigbergk
|
r34077 | 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) | ||
Boris Feld
|
r35304 | extensions.wrapfunction(upgrade, 'preservedrequirements', | ||
overrides.upgraderequirements) | ||||
extensions.wrapfunction(upgrade, 'supporteddestrequirements', | ||||
overrides.upgraderequirements) | ||||
Matt Harbison
|
r16515 | # Subrepos call status function | ||
Matt Mackall
|
r15170 | entry = extensions.wrapcommand(commands.table, 'status', | ||
Na'Tosha Bard
|
r16247 | overrides.overridestatus) | ||
Martin von Zweigbergk
|
r34077 | extensions.wrapfunction(subrepo.hgsubrepo, 'status', | ||
overrides.overridestatusfn) | ||||
Matt Harbison
|
r16515 | |||
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) | ||||
Martin von Zweigbergk
|
r34077 | extensions.wrapfunction(exchange, 'pushoperation', | ||
overrides.exchangepushoperation) | ||||
Mads Kiilerich
|
r28878 | |||
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) | ||
Martin von Zweigbergk
|
r34077 | extensions.wrapfunction(hg, 'clone', overrides.hgclone) | ||
extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare) | ||||
Na'Tosha Bard
|
r16644 | |||
Na'Tosha Bard
|
r16439 | entry = extensions.wrapcommand(commands.table, 'cat', | ||
overrides.overridecat) | ||||
Martin von Zweigbergk
|
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) | ||||
various
|
r15168 | |||
Matt Harbison
|
r16516 | # Summary calls dirty on the subrepos | ||
Martin von Zweigbergk
|
r34077 | extensions.wrapfunction(subrepo.hgsubrepo, 'dirty', overrides.overridedirty) | ||
Matt Harbison
|
r16516 | |||
Martin von Zweigbergk
|
r34077 | extensions.wrapfunction(cmdutil, 'revert', 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) | ||||
Martin von Zweigbergk
|
r34077 | 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) | ||||
Boris Feld
|
r35580 | extensions.wrapfunction(url, 'open', | ||
overrides.openlargefile) | ||||
various
|
r15168 | # create the new wireproto commands ... | ||
Gregory Szorc
|
r36001 | wireproto.wireprotocommand('putlfile', 'sha')(proto.putlfile) | ||
wireproto.wireprotocommand('getlfile', 'sha')(proto.getlfile) | ||||
wireproto.wireprotocommand('statlfile', 'sha')(proto.statlfile) | ||||
wireproto.wireprotocommand('lheads', '')(wireproto.heads) | ||||
various
|
r15168 | |||
# ... and wrap some existing ones | ||||
Gregory Szorc
|
r36001 | wireproto.commands['heads'].func = proto.heads | ||
various
|
r15168 | |||
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) | ||
Matt Harbison
|
r35523 | extensions.wrapfunction(wireproto, '_capabilities', proto._capabilities) | ||
various
|
r15168 | |||
# can't do this in reposetup because it needs to have happened before | ||||
# wirerepo.__init__ is called | ||||
Gregory Szorc
|
r35995 | proto.ssholdcallstream = sshpeer.sshv1peer._callstream | ||
Peter Arrenbrecht
|
r17192 | proto.httpoldcallstream = httppeer.httppeer._callstream | ||
Gregory Szorc
|
r35995 | sshpeer.sshv1peer._callstream = proto.sshrepocallstream | ||
Peter Arrenbrecht
|
r17192 | 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) | ||