##// END OF EJS Templates
largefiles: port commands to exthelper...
Matt Harbison -
r41091:98681293 default
parent child Browse files
Show More
@@ -128,6 +128,8 b' from . import ('
128 testedwith = 'ships-with-hg-core'
128 testedwith = 'ships-with-hg-core'
129
129
130 eh = exthelper.exthelper()
130 eh = exthelper.exthelper()
131 eh.merge(lfcommands.eh)
132 eh.merge(overrides.eh)
131
133
132 eh.configitem('largefiles', 'minsize',
134 eh.configitem('largefiles', 'minsize',
133 default=configitems.dynamicdefault,
135 default=configitems.dynamicdefault,
@@ -139,17 +141,20 b" eh.configitem('largefiles', 'usercache',"
139 default=None,
141 default=None,
140 )
142 )
141
143
144 cmdtable = eh.cmdtable
142 configtable = eh.configtable
145 configtable = eh.configtable
146 extsetup = eh.finalextsetup
143 reposetup = reposetup.reposetup
147 reposetup = reposetup.reposetup
148 uisetup = eh.finaluisetup
144
149
145 def featuresetup(ui, supported):
150 def featuresetup(ui, supported):
146 # don't die on seeing a repo with the largefiles requirement
151 # don't die on seeing a repo with the largefiles requirement
147 supported |= {'largefiles'}
152 supported |= {'largefiles'}
148
153
149 def uisetup(ui):
154 @eh.uisetup
155 def _uisetup(ui):
150 localrepo.featuresetupfuncs.add(featuresetup)
156 localrepo.featuresetupfuncs.add(featuresetup)
151 hg.wirepeersetupfuncs.append(proto.wirereposetup)
157 hg.wirepeersetupfuncs.append(proto.wirereposetup)
152 uisetupmod.uisetup(ui)
158 uisetupmod.uisetup(ui)
153
159
154 cmdtable = lfcommands.cmdtable
155 revsetpredicate = overrides.revsetpredicate
160 revsetpredicate = overrides.revsetpredicate
@@ -20,12 +20,12 b' from mercurial import ('
20 cmdutil,
20 cmdutil,
21 context,
21 context,
22 error,
22 error,
23 exthelper,
23 hg,
24 hg,
24 lock,
25 lock,
25 match as matchmod,
26 match as matchmod,
26 node,
27 node,
27 pycompat,
28 pycompat,
28 registrar,
29 scmutil,
29 scmutil,
30 util,
30 util,
31 )
31 )
@@ -44,10 +44,9 b' release = lock.release'
44
44
45 # -- Commands ----------------------------------------------------------
45 # -- Commands ----------------------------------------------------------
46
46
47 cmdtable = {}
47 eh = exthelper.exthelper()
48 command = registrar.command(cmdtable)
49
48
50 @command('lfconvert',
49 @eh.command('lfconvert',
51 [('s', 'size', '',
50 [('s', 'size', '',
52 _('minimum size (MB) for files to be converted as largefiles'), 'SIZE'),
51 _('minimum size (MB) for files to be converted as largefiles'), 'SIZE'),
53 ('', 'to-normal', False,
52 ('', 'to-normal', False,
@@ -560,7 +559,7 b' def updatelfiles(ui, repo, filelist=None'
560 statuswriter(_('%d largefiles updated, %d removed\n') % (updated,
559 statuswriter(_('%d largefiles updated, %d removed\n') % (updated,
561 removed))
560 removed))
562
561
563 @command('lfpull',
562 @eh.command('lfpull',
564 [('r', 'rev', [], _('pull largefiles for these revisions'))
563 [('r', 'rev', [], _('pull largefiles for these revisions'))
565 ] + cmdutil.remoteopts,
564 ] + cmdutil.remoteopts,
566 _('-r REV... [-e CMD] [--remotecmd CMD] [SOURCE]'))
565 _('-r REV... [-e CMD] [--remotecmd CMD] [SOURCE]'))
@@ -599,7 +598,7 b' def lfpull(ui, repo, source="default", *'
599 numcached += len(cached)
598 numcached += len(cached)
600 ui.status(_("%d largefiles cached\n") % numcached)
599 ui.status(_("%d largefiles cached\n") % numcached)
601
600
602 @command('debuglfput',
601 @eh.command('debuglfput',
603 [] + cmdutil.remoteopts,
602 [] + cmdutil.remoteopts,
604 _('FILE'))
603 _('FILE'))
605 def debuglfput(ui, repo, filepath, **kwargs):
604 def debuglfput(ui, repo, filepath, **kwargs):
@@ -18,6 +18,7 b' from mercurial import ('
18 archival,
18 archival,
19 cmdutil,
19 cmdutil,
20 error,
20 error,
21 exthelper,
21 hg,
22 hg,
22 logcmdutil,
23 logcmdutil,
23 match as matchmod,
24 match as matchmod,
@@ -35,6 +36,8 b' from . import ('
35 storefactory,
36 storefactory,
36 )
37 )
37
38
39 eh = exthelper.exthelper()
40
38 # -- Utility functions: commonly/repeatedly needed functionality ---------------
41 # -- Utility functions: commonly/repeatedly needed functionality ---------------
39
42
40 def composelargefilematcher(match, manifest):
43 def composelargefilematcher(match, manifest):
@@ -253,6 +256,11 b' def decodepath(orig, path):'
253
256
254 # -- Wrappers: modify existing commands --------------------------------
257 # -- Wrappers: modify existing commands --------------------------------
255
258
259 @eh.wrapcommand('add',
260 opts=[('', 'large', None, _('add as largefile')),
261 ('', 'normal', None, _('add as normal file')),
262 ('', 'lfsize', '', _('add all files above this size (in megabytes) '
263 'as largefiles (default: 10)'))])
256 def overrideadd(orig, ui, repo, *pats, **opts):
264 def overrideadd(orig, ui, repo, *pats, **opts):
257 if opts.get(r'normal') and opts.get(r'large'):
265 if opts.get(r'normal') and opts.get(r'large'):
258 raise error.Abort(_('--normal cannot be used with --large'))
266 raise error.Abort(_('--normal cannot be used with --large'))
@@ -286,6 +294,7 b' def overridestatusfn(orig, repo, rev2, *'
286 finally:
294 finally:
287 repo._repo.lfstatus = False
295 repo._repo.lfstatus = False
288
296
297 @eh.wrapcommand('status')
289 def overridestatus(orig, ui, repo, *pats, **opts):
298 def overridestatus(orig, ui, repo, *pats, **opts):
290 try:
299 try:
291 repo.lfstatus = True
300 repo.lfstatus = True
@@ -300,6 +309,7 b' def overridedirty(orig, repo, ignoreupda'
300 finally:
309 finally:
301 repo._repo.lfstatus = False
310 repo._repo.lfstatus = False
302
311
312 @eh.wrapcommand('log')
303 def overridelog(orig, ui, repo, *pats, **opts):
313 def overridelog(orig, ui, repo, *pats, **opts):
304 def overridematchandpats(ctx, pats=(), opts=None, globbed=False,
314 def overridematchandpats(ctx, pats=(), opts=None, globbed=False,
305 default='relpath', badfn=None):
315 default='relpath', badfn=None):
@@ -406,6 +416,13 b' def overridelog(orig, ui, repo, *pats, *'
406 restorematchandpatsfn()
416 restorematchandpatsfn()
407 setattr(logcmdutil, '_makenofollowfilematcher', oldmakefilematcher)
417 setattr(logcmdutil, '_makenofollowfilematcher', oldmakefilematcher)
408
418
419 @eh.wrapcommand('verify',
420 opts=[('', 'large', None,
421 _('verify that all largefiles in current revision exists')),
422 ('', 'lfa', None,
423 _('verify largefiles in all revisions, not just current')),
424 ('', 'lfc', None,
425 _('verify local largefile contents, not just existence'))])
409 def overrideverify(orig, ui, repo, *pats, **opts):
426 def overrideverify(orig, ui, repo, *pats, **opts):
410 large = opts.pop(r'large', False)
427 large = opts.pop(r'large', False)
411 all = opts.pop(r'lfa', False)
428 all = opts.pop(r'lfa', False)
@@ -416,6 +433,8 b' def overrideverify(orig, ui, repo, *pats'
416 result = result or lfcommands.verifylfiles(ui, repo, all, contents)
433 result = result or lfcommands.verifylfiles(ui, repo, all, contents)
417 return result
434 return result
418
435
436 @eh.wrapcommand('debugstate',
437 opts=[('', 'large', None, _('display largefiles dirstate'))])
419 def overridedebugstate(orig, ui, repo, *pats, **opts):
438 def overridedebugstate(orig, ui, repo, *pats, **opts):
420 large = opts.pop(r'large', False)
439 large = opts.pop(r'large', False)
421 if large:
440 if large:
@@ -799,6 +818,11 b' def overriderevert(orig, ui, repo, ctx, '
799
818
800 # after pulling changesets, we need to take some extra care to get
819 # after pulling changesets, we need to take some extra care to get
801 # largefiles updated remotely
820 # largefiles updated remotely
821 @eh.wrapcommand('pull',
822 opts=[('', 'all-largefiles', None,
823 _('download all pulled versions of largefiles (DEPRECATED)')),
824 ('', 'lfrev', [],
825 _('download largefiles for these revisions'), _('REV'))])
802 def overridepull(orig, ui, repo, source=None, **opts):
826 def overridepull(orig, ui, repo, source=None, **opts):
803 revsprepull = len(repo)
827 revsprepull = len(repo)
804 if not source:
828 if not source:
@@ -822,6 +846,9 b' def overridepull(orig, ui, repo, source='
822 ui.status(_("%d largefiles cached\n") % numcached)
846 ui.status(_("%d largefiles cached\n") % numcached)
823 return result
847 return result
824
848
849 @eh.wrapcommand('push',
850 opts=[('', 'lfrev', [],
851 _('upload largefiles for these revisions'), _('REV'))])
825 def overridepush(orig, ui, repo, *args, **kwargs):
852 def overridepush(orig, ui, repo, *args, **kwargs):
826 """Override push command and store --lfrev parameters in opargs"""
853 """Override push command and store --lfrev parameters in opargs"""
827 lfrevs = kwargs.pop(r'lfrev', None)
854 lfrevs = kwargs.pop(r'lfrev', None)
@@ -865,6 +892,9 b' def pulledrevsetsymbol(repo, subset, x):'
865 raise error.Abort(_("pulled() only available in --lfrev"))
892 raise error.Abort(_("pulled() only available in --lfrev"))
866 return smartset.baseset([r for r in subset if r >= firstpulled])
893 return smartset.baseset([r for r in subset if r >= firstpulled])
867
894
895 @eh.wrapcommand('clone',
896 opts=[('', 'all-largefiles', None,
897 _('download all versions of all largefiles'))])
868 def overrideclone(orig, ui, source, dest=None, **opts):
898 def overrideclone(orig, ui, source, dest=None, **opts):
869 d = dest
899 d = dest
870 if d is None:
900 if d is None:
@@ -900,6 +930,7 b' def hgclone(orig, ui, opts, *args, **kwa'
900
930
901 return result
931 return result
902
932
933 @eh.wrapcommand('rebase', extension='rebase')
903 def overriderebase(orig, ui, repo, **opts):
934 def overriderebase(orig, ui, repo, **opts):
904 if not util.safehasattr(repo, '_largefilesenabled'):
935 if not util.safehasattr(repo, '_largefilesenabled'):
905 return orig(ui, repo, **opts)
936 return orig(ui, repo, **opts)
@@ -913,6 +944,7 b' def overriderebase(orig, ui, repo, **opt'
913 repo._lfstatuswriters.pop()
944 repo._lfstatuswriters.pop()
914 repo._lfcommithooks.pop()
945 repo._lfcommithooks.pop()
915
946
947 @eh.wrapcommand('archive')
916 def overridearchivecmd(orig, ui, repo, dest, **opts):
948 def overridearchivecmd(orig, ui, repo, dest, **opts):
917 repo.unfiltered().lfstatus = True
949 repo.unfiltered().lfstatus = True
918
950
@@ -1167,6 +1199,13 b' def outgoinghook(ui, repo, other, opts, '
1167 showhashes(file)
1199 showhashes(file)
1168 ui.status('\n')
1200 ui.status('\n')
1169
1201
1202 @eh.wrapcommand('outgoing',
1203 opts=[('', 'large', None, _('display outgoing largefiles'))])
1204 def _outgoingcmd(orig, *args, **kwargs):
1205 # Nothing to do here other than add the extra help option- the hook above
1206 # processes it.
1207 return orig(*args, **kwargs)
1208
1170 def summaryremotehook(ui, repo, opts, changes):
1209 def summaryremotehook(ui, repo, opts, changes):
1171 largeopt = opts.get('large', False)
1210 largeopt = opts.get('large', False)
1172 if changes is None:
1211 if changes is None:
@@ -1196,6 +1235,8 b' def summaryremotehook(ui, repo, opts, ch'
1196 ui.status(_('largefiles: %d entities for %d files to upload\n')
1235 ui.status(_('largefiles: %d entities for %d files to upload\n')
1197 % (len(lfhashes), len(toupload)))
1236 % (len(lfhashes), len(toupload)))
1198
1237
1238 @eh.wrapcommand('summary',
1239 opts=[('', 'large', None, _('display outgoing largefiles'))])
1199 def overridesummary(orig, ui, repo, *pats, **opts):
1240 def overridesummary(orig, ui, repo, *pats, **opts):
1200 try:
1241 try:
1201 repo.lfstatus = True
1242 repo.lfstatus = True
@@ -1242,6 +1283,7 b' def scmutiladdremove(orig, repo, matcher'
1242
1283
1243 # Calling purge with --all will cause the largefiles to be deleted.
1284 # Calling purge with --all will cause the largefiles to be deleted.
1244 # Override repo.status to prevent this from happening.
1285 # Override repo.status to prevent this from happening.
1286 @eh.wrapcommand('purge', extension='purge')
1245 def overridepurge(orig, ui, repo, *dirs, **opts):
1287 def overridepurge(orig, ui, repo, *dirs, **opts):
1246 # XXX Monkey patching a repoview will not work. The assigned attribute will
1288 # XXX Monkey patching a repoview will not work. The assigned attribute will
1247 # be set on the unfiltered repo, but we will only lookup attributes in the
1289 # be set on the unfiltered repo, but we will only lookup attributes in the
@@ -1267,6 +1309,7 b' def overridepurge(orig, ui, repo, *dirs,'
1267 orig(ui, repo, *dirs, **opts)
1309 orig(ui, repo, *dirs, **opts)
1268 repo.status = oldstatus
1310 repo.status = oldstatus
1269
1311
1312 @eh.wrapcommand('rollback')
1270 def overriderollback(orig, ui, repo, **opts):
1313 def overriderollback(orig, ui, repo, **opts):
1271 with repo.wlock():
1314 with repo.wlock():
1272 before = repo.dirstate.parents()
1315 before = repo.dirstate.parents()
@@ -1304,6 +1347,7 b' def overriderollback(orig, ui, repo, **o'
1304 lfdirstate.write()
1347 lfdirstate.write()
1305 return result
1348 return result
1306
1349
1350 @eh.wrapcommand('transplant', extension='transplant')
1307 def overridetransplant(orig, ui, repo, *revs, **opts):
1351 def overridetransplant(orig, ui, repo, *revs, **opts):
1308 resuming = opts.get(r'continue')
1352 resuming = opts.get(r'continue')
1309 repo._lfcommithooks.append(lfutil.automatedcommithook(resuming))
1353 repo._lfcommithooks.append(lfutil.automatedcommithook(resuming))
@@ -1315,6 +1359,7 b' def overridetransplant(orig, ui, repo, *'
1315 repo._lfcommithooks.pop()
1359 repo._lfcommithooks.pop()
1316 return result
1360 return result
1317
1361
1362 @eh.wrapcommand('cat')
1318 def overridecat(orig, ui, repo, file1, *pats, **opts):
1363 def overridecat(orig, ui, repo, file1, *pats, **opts):
1319 opts = pycompat.byteskwargs(opts)
1364 opts = pycompat.byteskwargs(opts)
1320 ctx = scmutil.revsingle(repo, opts.get('rev'))
1365 ctx = scmutil.revsingle(repo, opts.get('rev'))
@@ -9,8 +9,6 b''
9 '''setup for largefiles extension: uisetup'''
9 '''setup for largefiles extension: uisetup'''
10 from __future__ import absolute_import
10 from __future__ import absolute_import
11
11
12 from mercurial.i18n import _
13
14 from mercurial.hgweb import (
12 from mercurial.hgweb import (
15 webcommands,
13 webcommands,
16 )
14 )
@@ -18,7 +16,6 b' from mercurial.hgweb import ('
18 from mercurial import (
16 from mercurial import (
19 archival,
17 archival,
20 cmdutil,
18 cmdutil,
21 commands,
22 copies,
19 copies,
23 exchange,
20 exchange,
24 extensions,
21 extensions,
@@ -43,15 +40,6 b' def uisetup(ui):'
43 # Disable auto-status for some commands which assume that all
40 # Disable auto-status for some commands which assume that all
44 # files in the result are under Mercurial's control
41 # files in the result are under Mercurial's control
45
42
46 entry = extensions.wrapcommand(commands.table, 'add',
47 overrides.overrideadd)
48 addopt = [('', 'large', None, _('add as largefile')),
49 ('', 'normal', None, _('add as normal file')),
50 ('', 'lfsize', '', _('add all files above this size '
51 '(in megabytes) as largefiles '
52 '(default: 10)'))]
53 entry[1].extend(addopt)
54
55 # The scmutil function is called both by the (trivial) addremove command,
43 # The scmutil function is called both by the (trivial) addremove command,
56 # and in the process of handling commit -A (issue3542)
44 # and in the process of handling commit -A (issue3542)
57 extensions.wrapfunction(scmutil, 'addremove', overrides.scmutiladdremove)
45 extensions.wrapfunction(scmutil, 'addremove', overrides.scmutiladdremove)
@@ -68,67 +56,17 b' def uisetup(ui):'
68 overrides.upgraderequirements)
56 overrides.upgraderequirements)
69
57
70 # Subrepos call status function
58 # Subrepos call status function
71 entry = extensions.wrapcommand(commands.table, 'status',
72 overrides.overridestatus)
73 extensions.wrapfunction(subrepo.hgsubrepo, 'status',
59 extensions.wrapfunction(subrepo.hgsubrepo, 'status',
74 overrides.overridestatusfn)
60 overrides.overridestatusfn)
75
61
76 entry = extensions.wrapcommand(commands.table, 'log',
77 overrides.overridelog)
78 entry = extensions.wrapcommand(commands.table, 'rollback',
79 overrides.overriderollback)
80 entry = extensions.wrapcommand(commands.table, 'verify',
81 overrides.overrideverify)
82
83 verifyopt = [('', 'large', None,
84 _('verify that all largefiles in current revision exists')),
85 ('', 'lfa', None,
86 _('verify largefiles in all revisions, not just current')),
87 ('', 'lfc', None,
88 _('verify local largefile contents, not just existence'))]
89 entry[1].extend(verifyopt)
90
91 entry = extensions.wrapcommand(commands.table, 'debugstate',
92 overrides.overridedebugstate)
93 debugstateopt = [('', 'large', None, _('display largefiles dirstate'))]
94 entry[1].extend(debugstateopt)
95
96 outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs)
97 entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
98 outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
99 entry[1].extend(outgoingopt)
100 cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
62 cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
101 entry = extensions.wrapcommand(commands.table, 'summary',
102 overrides.overridesummary)
103 summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
104 entry[1].extend(summaryopt)
105 cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
63 cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
106
64
107 entry = extensions.wrapcommand(commands.table, 'pull',
108 overrides.overridepull)
109 pullopt = [('', 'all-largefiles', None,
110 _('download all pulled versions of largefiles (DEPRECATED)')),
111 ('', 'lfrev', [],
112 _('download largefiles for these revisions'), _('REV'))]
113 entry[1].extend(pullopt)
114
115 entry = extensions.wrapcommand(commands.table, 'push',
116 overrides.overridepush)
117 pushopt = [('', 'lfrev', [],
118 _('upload largefiles for these revisions'), _('REV'))]
119 entry[1].extend(pushopt)
120 extensions.wrapfunction(exchange, 'pushoperation',
65 extensions.wrapfunction(exchange, 'pushoperation',
121 overrides.exchangepushoperation)
66 overrides.exchangepushoperation)
122
67
123 entry = extensions.wrapcommand(commands.table, 'clone',
124 overrides.overrideclone)
125 cloneopt = [('', 'all-largefiles', None,
126 _('download all versions of all largefiles'))]
127 entry[1].extend(cloneopt)
128 extensions.wrapfunction(hg, 'clone', overrides.hgclone)
68 extensions.wrapfunction(hg, 'clone', overrides.hgclone)
129
69
130 entry = extensions.wrapcommand(commands.table, 'cat',
131 overrides.overridecat)
132 extensions.wrapfunction(merge, '_checkunknownfile',
70 extensions.wrapfunction(merge, '_checkunknownfile',
133 overrides.overridecheckunknownfile)
71 overrides.overridecheckunknownfile)
134 extensions.wrapfunction(merge, 'calculateupdates',
72 extensions.wrapfunction(merge, 'calculateupdates',
@@ -145,8 +83,6 b' def uisetup(ui):'
145
83
146 extensions.wrapfunction(cmdutil, 'revert', overrides.overriderevert)
84 extensions.wrapfunction(cmdutil, 'revert', overrides.overriderevert)
147
85
148 extensions.wrapcommand(commands.table, 'archive',
149 overrides.overridearchivecmd)
150 extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
86 extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
151 extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
87 extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
152 overrides.hgsubrepoarchive)
88 overrides.hgsubrepoarchive)
@@ -191,14 +127,6 b' def uisetup(ui):'
191
127
192 # override some extensions' stuff as well
128 # override some extensions' stuff as well
193 for name, module in extensions.extensions():
129 for name, module in extensions.extensions():
194 if name == 'purge':
195 extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
196 overrides.overridepurge)
197 if name == 'rebase':
130 if name == 'rebase':
198 extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
199 overrides.overriderebase)
200 extensions.wrapfunction(module, 'rebase',
131 extensions.wrapfunction(module, 'rebase',
201 overrides.overriderebase)
132 overrides.overriderebase)
202 if name == 'transplant':
203 extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant',
204 overrides.overridetransplant)
General Comments 0
You need to be logged in to leave comments. Login now