2011-09-24 19:35:45 +04:00
|
|
|
# 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'''
|
2016-05-10 16:14:41 +03:00
|
|
|
from __future__ import absolute_import
|
2011-09-24 19:35:45 +04:00
|
|
|
|
|
|
|
from mercurial.i18n import _
|
|
|
|
|
2016-05-10 16:14:41 +03:00
|
|
|
from mercurial.hgweb import (
|
|
|
|
hgweb_mod,
|
|
|
|
webcommands,
|
|
|
|
)
|
|
|
|
|
|
|
|
from mercurial import (
|
|
|
|
archival,
|
|
|
|
cmdutil,
|
|
|
|
commands,
|
|
|
|
copies,
|
|
|
|
exchange,
|
|
|
|
extensions,
|
|
|
|
filemerge,
|
|
|
|
hg,
|
|
|
|
httppeer,
|
|
|
|
merge,
|
|
|
|
scmutil,
|
|
|
|
sshpeer,
|
|
|
|
subrepo,
|
|
|
|
wireproto,
|
|
|
|
)
|
|
|
|
|
|
|
|
from . import (
|
|
|
|
overrides,
|
|
|
|
proto,
|
|
|
|
)
|
2011-09-24 19:35:45 +04:00
|
|
|
|
|
|
|
def uisetup(ui):
|
|
|
|
# Disable auto-status for some commands which assume that all
|
|
|
|
# files in the result are under Mercurial's control
|
|
|
|
|
2011-09-30 02:04:57 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'add',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overrideadd)
|
2011-09-24 19:35:45 +04:00
|
|
|
addopt = [('', 'large', None, _('add as largefile')),
|
2011-12-02 21:20:32 +04:00
|
|
|
('', 'normal', None, _('add as normal file')),
|
2011-12-09 20:34:56 +04:00
|
|
|
('', 'lfsize', '', _('add all files above this size '
|
|
|
|
'(in megabytes) as largefiles '
|
|
|
|
'(default: 10)'))]
|
2011-09-24 19:35:45 +04:00
|
|
|
entry[1].extend(addopt)
|
|
|
|
|
largefiles: handle commit -A properly, after a --large commit (issue3542)
Previous to this, 'commit -A' would add as normal files, files that were already
committed as largefiles, resulting in files being listed twice by 'status -A'.
It also missed when (only) a largefile was deleted, even though status reported
it as '!'. This also has the side effect of properly reporting the state of the
affected largefiles in the post commit hook after a remove that also affected a
normal file (the largefiles used to be 'R', now are properly absent).
Since scmutil.addremove() is called both by the ui command (after some trivial
argument validation) and during the commit process when -A is specified, it
seems like a more appropriate method to wrap than the addremove command.
Currently, a repo is only enabled to use largefiles after an add that explicitly
identifies some file as large, and a subsequent commit. Therefore, this patch
only changes behavior after such a largefile enabling commit.
Note that in the test, if the final commit had a '-v', 'removing large8' would
be printed twice. Both of these originate in removelargefiles(). The first
print is in verbose mode after traversing remove + forget, the second is because
the '_isaddremove' attr is set and 'after' is not.
2012-07-31 04:56:41 +04:00
|
|
|
# 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)
|
2015-01-13 05:44:43 +03:00
|
|
|
extensions.wrapfunction(cmdutil, 'add', overrides.cmdutiladd)
|
2014-12-31 05:12:52 +03:00
|
|
|
extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove)
|
2015-01-12 07:20:51 +03:00
|
|
|
extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget)
|
2012-04-22 11:47:34 +04:00
|
|
|
|
2015-01-25 10:45:49 +03:00
|
|
|
extensions.wrapfunction(copies, 'pathcopies', overrides.copiespathcopies)
|
|
|
|
|
2012-04-22 11:47:34 +04:00
|
|
|
# Subrepos call status function
|
2011-09-30 02:04:57 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'status',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridestatus)
|
2014-04-08 02:48:36 +04:00
|
|
|
entry = extensions.wrapfunction(subrepo.hgsubrepo, 'status',
|
2012-04-22 11:47:34 +04:00
|
|
|
overrides.overridestatusfn)
|
|
|
|
|
2011-09-30 02:04:57 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'log',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridelog)
|
2011-09-24 19:35:45 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'rollback',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overriderollback)
|
2011-09-30 02:04:57 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'verify',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overrideverify)
|
2011-09-24 19:35:45 +04:00
|
|
|
|
2013-01-25 02:57:44 +04:00
|
|
|
verifyopt = [('', 'large', None,
|
|
|
|
_('verify that all largefiles in current revision exists')),
|
2011-09-24 19:35:45 +04:00
|
|
|
('', 'lfa', None,
|
2013-01-25 02:57:44 +04:00
|
|
|
_('verify largefiles in all revisions, not just current')),
|
2011-09-24 19:35:45 +04:00
|
|
|
('', 'lfc', None,
|
2013-01-25 02:57:44 +04:00
|
|
|
_('verify local largefile contents, not just existence'))]
|
2011-09-24 19:35:45 +04:00
|
|
|
entry[1].extend(verifyopt)
|
|
|
|
|
2012-12-28 14:55:57 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'debugstate',
|
|
|
|
overrides.overridedebugstate)
|
|
|
|
debugstateopt = [('', 'large', None, _('display largefiles dirstate'))]
|
|
|
|
entry[1].extend(debugstateopt)
|
|
|
|
|
2014-04-15 19:37:24 +04:00
|
|
|
outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs)
|
|
|
|
entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
|
2011-09-24 19:35:45 +04:00
|
|
|
outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
|
|
|
|
entry[1].extend(outgoingopt)
|
2014-04-15 19:37:24 +04:00
|
|
|
cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
|
2011-09-30 02:04:57 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'summary',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridesummary)
|
2011-09-24 19:35:45 +04:00
|
|
|
summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
|
|
|
|
entry[1].extend(summaryopt)
|
2014-04-15 19:37:24 +04:00
|
|
|
cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
|
2011-09-24 19:35:45 +04:00
|
|
|
|
2011-09-30 02:04:57 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'pull',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridepull)
|
2012-05-12 13:45:22 +04:00
|
|
|
pullopt = [('', 'all-largefiles', None,
|
2013-04-15 03:59:11 +04:00
|
|
|
_('download all pulled versions of largefiles (DEPRECATED)')),
|
2013-04-15 03:57:16 +04:00
|
|
|
('', 'lfrev', [],
|
|
|
|
_('download largefiles for these revisions'), _('REV'))]
|
2012-05-12 13:45:22 +04:00
|
|
|
entry[1].extend(pullopt)
|
2013-04-15 03:59:04 +04:00
|
|
|
|
2016-03-27 23:00:28 +03:00
|
|
|
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)
|
|
|
|
|
2012-05-12 01:11:43 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'clone',
|
|
|
|
overrides.overrideclone)
|
|
|
|
cloneopt = [('', 'all-largefiles', None,
|
|
|
|
_('download all versions of all largefiles'))]
|
|
|
|
entry[1].extend(cloneopt)
|
2012-09-09 20:43:24 +04:00
|
|
|
entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone)
|
2017-04-12 03:54:50 +03:00
|
|
|
entry = extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare)
|
2012-09-09 20:43:24 +04:00
|
|
|
|
2012-04-16 19:03:39 +04:00
|
|
|
entry = extensions.wrapcommand(commands.table, 'cat',
|
|
|
|
overrides.overridecat)
|
2012-02-10 02:50:19 +04:00
|
|
|
entry = extensions.wrapfunction(merge, '_checkunknownfile',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridecheckunknownfile)
|
2014-03-02 21:30:41 +04:00
|
|
|
entry = extensions.wrapfunction(merge, 'calculateupdates',
|
|
|
|
overrides.overridecalculateupdates)
|
2014-08-15 15:28:51 +04:00
|
|
|
entry = extensions.wrapfunction(merge, 'recordupdates',
|
|
|
|
overrides.mergerecordupdates)
|
largefiles: update largefiles even if rebase is aborted by conflict
Before this patch, largefiles in the working directory aren't updated
correctly, if rebase is aborted by conflict. This prevents users from
viewing appropriate largefiles while resolving conflicts.
While rebase, largefiles in the working directory are updated only at
successful committing in the special code path of
"lfilesrepo.commit()".
To update largefiles even if rebase is aborted by conflict, this patch
centralizes the logic of updating largefiles in the working directory
into the "mergeupdate" wrapping "merge.update".
This is a temporary way to fix with less changes. For fundamental
resolution of this kind of problems in the future, largefiles in the
working directory should be updated with other (normal) files
simultaneously while "merge.update" execution: maybe by hooking
"applyupdates".
"Action list based updating" introduced by hooking "applyupdates" will
also improve performance of updating, because it automatically
decreases target files to be checked.
Just after this patch, there are some improper things in "Case 0" code
path of "lfilesrepo.commit()":
- "updatelfiles" invocation is redundant for rebase
- detailed comment doesn't meet to rebase behavior
These will be resolved after the subsequent patch for transplant,
because this code path is shared with transplant.
Even though replacing "merge.update" in rebase extension by "hg.merge"
can also avoid this problem, this patch chooses centralizing the logic
into "mergeupdate", because:
- "merge.update" invocation in rebase extension can't be directly
replaced by "hg.merge", because:
- rebase requires some extra arguments, which "hg.merge" doesn't
take (e.g. "ancestor")
- rebase doesn't require statistics information forcibly displayed
in "hg.merge"
- introducing "mergeupdate" can resolve also problem of some other
code paths directly using "merge.update"
largefiles in the working directory aren't updated regardless of
the result of commands below, before this patch:
- backout (for revisions other than the parent revision of the
working directory without "--merge")
- graft
- histedit (for revisions other than the parent of the working
directory
When "partial" is specified, "merge.update" doesn't update dirstate
entries for standins, even though standins themselves are updated.
In this case, "normallookup" should be used to mark largefiles as
"possibly dirty" forcibly, because applying "normal" on lfdirstate
treats them as "clean" unexpectedly.
This is reason why "normallookup=partial" is specified for
"lfcommands.updatelfiles".
This patch doesn't test "hg rebase --continue", because it doesn't
work correctly if largefiles in the working directory are modified
manually while resolving conflicts. This will be fixed in the next
step of refactoring for largefiles.
All changes of tests/*.t files other than test-largefiles-update.t in
this patch come from invoking "updatelfiles" not after but before
statistics output of "hg.update", "hg.clean" and "hg.merge".
2014-08-24 18:47:26 +04:00
|
|
|
entry = extensions.wrapfunction(merge, 'update',
|
|
|
|
overrides.mergeupdate)
|
2015-10-11 22:31:08 +03:00
|
|
|
entry = extensions.wrapfunction(filemerge, '_filemerge',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridefilemerge)
|
2011-09-30 02:04:57 +04:00
|
|
|
entry = extensions.wrapfunction(cmdutil, 'copy',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridecopy)
|
2011-09-24 19:35:45 +04:00
|
|
|
|
2012-04-22 21:19:22 +04:00
|
|
|
# Summary calls dirty on the subrepos
|
2014-04-08 02:48:36 +04:00
|
|
|
entry = extensions.wrapfunction(subrepo.hgsubrepo, 'dirty',
|
2012-04-22 21:19:22 +04:00
|
|
|
overrides.overridedirty)
|
|
|
|
|
2015-03-20 20:05:31 +03:00
|
|
|
entry = extensions.wrapfunction(cmdutil, 'revert',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overriderevert)
|
2011-09-24 19:35:45 +04:00
|
|
|
|
2015-07-12 06:26:33 +03:00
|
|
|
extensions.wrapcommand(commands.table, 'archive',
|
|
|
|
overrides.overridearchivecmd)
|
2012-03-09 19:11:52 +04:00
|
|
|
extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
|
2014-04-08 02:48:36 +04:00
|
|
|
extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
|
|
|
|
overrides.hgsubrepoarchive)
|
2015-09-30 06:29:44 +03:00
|
|
|
extensions.wrapfunction(webcommands, 'archive',
|
|
|
|
overrides.hgwebarchive)
|
2011-10-23 18:23:31 +04:00
|
|
|
extensions.wrapfunction(cmdutil, 'bailifchanged',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridebailifchanged)
|
2011-09-24 19:35:45 +04:00
|
|
|
|
2016-01-24 07:32:49 +03:00
|
|
|
extensions.wrapfunction(cmdutil, 'postcommitstatus',
|
|
|
|
overrides.postcommitstatus)
|
2014-08-24 18:47:26 +04:00
|
|
|
extensions.wrapfunction(scmutil, 'marktouched',
|
|
|
|
overrides.scmutilmarktouched)
|
|
|
|
|
2011-09-24 19:35:45 +04:00
|
|
|
# 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, '')
|
|
|
|
|
2011-10-14 04:45:49 +04:00
|
|
|
# make putlfile behave the same as push and {get,stat}lfile behave
|
|
|
|
# the same as pull w.r.t. permissions checks
|
2011-09-24 19:35:45 +04:00
|
|
|
hgweb_mod.perms['putlfile'] = 'push'
|
|
|
|
hgweb_mod.perms['getlfile'] = 'pull'
|
|
|
|
hgweb_mod.perms['statlfile'] = 'pull'
|
|
|
|
|
2012-04-15 18:05:57 +04:00
|
|
|
extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
|
|
|
|
|
2011-09-24 19:35:45 +04:00
|
|
|
# the hello wireproto command uses wireproto.capabilities, so it won't see
|
|
|
|
# our largefiles capability unless we replace the actual function as well.
|
2012-03-09 19:11:52 +04:00
|
|
|
proto.capabilitiesorig = wireproto.capabilities
|
2011-09-24 19:35:45 +04:00
|
|
|
wireproto.capabilities = proto.capabilities
|
|
|
|
|
|
|
|
# can't do this in reposetup because it needs to have happened before
|
|
|
|
# wirerepo.__init__ is called
|
2012-07-13 23:47:06 +04:00
|
|
|
proto.ssholdcallstream = sshpeer.sshpeer._callstream
|
|
|
|
proto.httpoldcallstream = httppeer.httppeer._callstream
|
|
|
|
sshpeer.sshpeer._callstream = proto.sshrepocallstream
|
|
|
|
httppeer.httppeer._callstream = proto.httprepocallstream
|
2011-09-24 19:35:45 +04:00
|
|
|
|
|
|
|
# override some extensions' stuff as well
|
|
|
|
for name, module in extensions.extensions():
|
|
|
|
if name == 'purge':
|
|
|
|
extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridepurge)
|
2011-09-24 19:35:45 +04:00
|
|
|
if name == 'rebase':
|
|
|
|
extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overriderebase)
|
2014-11-05 17:24:47 +03:00
|
|
|
extensions.wrapfunction(module, 'rebase',
|
|
|
|
overrides.overriderebase)
|
2011-10-28 20:48:24 +04:00
|
|
|
if name == 'transplant':
|
|
|
|
extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant',
|
2012-03-09 19:11:52 +04:00
|
|
|
overrides.overridetransplant)
|