--- a/hgext/largefiles/overrides.py Sun Dec 23 21:54:56 2018 -0500
+++ b/hgext/largefiles/overrides.py Sun Dec 23 17:26:25 2018 -0500
@@ -18,6 +18,7 @@
archival,
cmdutil,
error,
+ exthelper,
hg,
logcmdutil,
match as matchmod,
@@ -35,6 +36,8 @@
storefactory,
)
+eh = exthelper.exthelper()
+
# -- Utility functions: commonly/repeatedly needed functionality ---------------
def composelargefilematcher(match, manifest):
@@ -253,6 +256,11 @@
# -- Wrappers: modify existing commands --------------------------------
+@eh.wrapcommand('add',
+ opts=[('', 'large', None, _('add as largefile')),
+ ('', 'normal', None, _('add as normal file')),
+ ('', 'lfsize', '', _('add all files above this size (in megabytes) '
+ 'as largefiles (default: 10)'))])
def overrideadd(orig, ui, repo, *pats, **opts):
if opts.get(r'normal') and opts.get(r'large'):
raise error.Abort(_('--normal cannot be used with --large'))
@@ -286,6 +294,7 @@
finally:
repo._repo.lfstatus = False
+@eh.wrapcommand('status')
def overridestatus(orig, ui, repo, *pats, **opts):
try:
repo.lfstatus = True
@@ -300,6 +309,7 @@
finally:
repo._repo.lfstatus = False
+@eh.wrapcommand('log')
def overridelog(orig, ui, repo, *pats, **opts):
def overridematchandpats(ctx, pats=(), opts=None, globbed=False,
default='relpath', badfn=None):
@@ -406,6 +416,13 @@
restorematchandpatsfn()
setattr(logcmdutil, '_makenofollowfilematcher', oldmakefilematcher)
+@eh.wrapcommand('verify',
+ opts=[('', 'large', None,
+ _('verify that all largefiles in current revision exists')),
+ ('', 'lfa', None,
+ _('verify largefiles in all revisions, not just current')),
+ ('', 'lfc', None,
+ _('verify local largefile contents, not just existence'))])
def overrideverify(orig, ui, repo, *pats, **opts):
large = opts.pop(r'large', False)
all = opts.pop(r'lfa', False)
@@ -416,6 +433,8 @@
result = result or lfcommands.verifylfiles(ui, repo, all, contents)
return result
+@eh.wrapcommand('debugstate',
+ opts=[('', 'large', None, _('display largefiles dirstate'))])
def overridedebugstate(orig, ui, repo, *pats, **opts):
large = opts.pop(r'large', False)
if large:
@@ -799,6 +818,11 @@
# after pulling changesets, we need to take some extra care to get
# largefiles updated remotely
+@eh.wrapcommand('pull',
+ opts=[('', 'all-largefiles', None,
+ _('download all pulled versions of largefiles (DEPRECATED)')),
+ ('', 'lfrev', [],
+ _('download largefiles for these revisions'), _('REV'))])
def overridepull(orig, ui, repo, source=None, **opts):
revsprepull = len(repo)
if not source:
@@ -822,6 +846,9 @@
ui.status(_("%d largefiles cached\n") % numcached)
return result
+@eh.wrapcommand('push',
+ opts=[('', 'lfrev', [],
+ _('upload largefiles for these revisions'), _('REV'))])
def overridepush(orig, ui, repo, *args, **kwargs):
"""Override push command and store --lfrev parameters in opargs"""
lfrevs = kwargs.pop(r'lfrev', None)
@@ -865,6 +892,9 @@
raise error.Abort(_("pulled() only available in --lfrev"))
return smartset.baseset([r for r in subset if r >= firstpulled])
+@eh.wrapcommand('clone',
+ opts=[('', 'all-largefiles', None,
+ _('download all versions of all largefiles'))])
def overrideclone(orig, ui, source, dest=None, **opts):
d = dest
if d is None:
@@ -900,6 +930,7 @@
return result
+@eh.wrapcommand('rebase', extension='rebase')
def overriderebase(orig, ui, repo, **opts):
if not util.safehasattr(repo, '_largefilesenabled'):
return orig(ui, repo, **opts)
@@ -913,6 +944,7 @@
repo._lfstatuswriters.pop()
repo._lfcommithooks.pop()
+@eh.wrapcommand('archive')
def overridearchivecmd(orig, ui, repo, dest, **opts):
repo.unfiltered().lfstatus = True
@@ -1167,6 +1199,13 @@
showhashes(file)
ui.status('\n')
+@eh.wrapcommand('outgoing',
+ opts=[('', 'large', None, _('display outgoing largefiles'))])
+def _outgoingcmd(orig, *args, **kwargs):
+ # Nothing to do here other than add the extra help option- the hook above
+ # processes it.
+ return orig(*args, **kwargs)
+
def summaryremotehook(ui, repo, opts, changes):
largeopt = opts.get('large', False)
if changes is None:
@@ -1196,6 +1235,8 @@
ui.status(_('largefiles: %d entities for %d files to upload\n')
% (len(lfhashes), len(toupload)))
+@eh.wrapcommand('summary',
+ opts=[('', 'large', None, _('display outgoing largefiles'))])
def overridesummary(orig, ui, repo, *pats, **opts):
try:
repo.lfstatus = True
@@ -1242,6 +1283,7 @@
# Calling purge with --all will cause the largefiles to be deleted.
# Override repo.status to prevent this from happening.
+@eh.wrapcommand('purge', extension='purge')
def overridepurge(orig, ui, repo, *dirs, **opts):
# XXX Monkey patching a repoview will not work. The assigned attribute will
# be set on the unfiltered repo, but we will only lookup attributes in the
@@ -1267,6 +1309,7 @@
orig(ui, repo, *dirs, **opts)
repo.status = oldstatus
+@eh.wrapcommand('rollback')
def overriderollback(orig, ui, repo, **opts):
with repo.wlock():
before = repo.dirstate.parents()
@@ -1304,6 +1347,7 @@
lfdirstate.write()
return result
+@eh.wrapcommand('transplant', extension='transplant')
def overridetransplant(orig, ui, repo, *revs, **opts):
resuming = opts.get(r'continue')
repo._lfcommithooks.append(lfutil.automatedcommithook(resuming))
@@ -1315,6 +1359,7 @@
repo._lfcommithooks.pop()
return result
+@eh.wrapcommand('cat')
def overridecat(orig, ui, repo, file1, *pats, **opts):
opts = pycompat.byteskwargs(opts)
ctx = scmutil.revsingle(repo, opts.get('rev'))