##// END OF EJS Templates
largefiles: port wrapped functions to exthelper...
Matt Harbison -
r41092:0a7f582f default
parent child Browse files
Show More
@@ -130,6 +130,7 b" testedwith = 'ships-with-hg-core'"
130 130 eh = exthelper.exthelper()
131 131 eh.merge(lfcommands.eh)
132 132 eh.merge(overrides.eh)
133 eh.merge(proto.eh)
133 134
134 135 eh.configitem('largefiles', 'minsize',
135 136 default=configitems.dynamicdefault,
@@ -14,19 +14,30 b' import os'
14 14
15 15 from mercurial.i18n import _
16 16
17 from mercurial.hgweb import (
18 webcommands,
19 )
20
17 21 from mercurial import (
18 22 archival,
19 23 cmdutil,
24 copies as copiesmod,
20 25 error,
26 exchange,
21 27 exthelper,
28 filemerge,
22 29 hg,
23 30 logcmdutil,
24 31 match as matchmod,
32 merge,
25 33 pathutil,
26 34 pycompat,
27 35 registrar,
28 36 scmutil,
29 37 smartset,
38 subrepo,
39 upgrade,
40 url as urlmod,
30 41 util,
31 42 )
32 43
@@ -251,6 +262,7 b' def removelargefiles(ui, repo, isaddremo'
251 262
252 263 # For overriding mercurial.hgweb.webcommands so that largefiles will
253 264 # appear at their right place in the manifests.
265 @eh.wrapfunction(webcommands, 'decodepath')
254 266 def decodepath(orig, path):
255 267 return lfutil.splitstandin(path) or path
256 268
@@ -266,6 +278,7 b' def overrideadd(orig, ui, repo, *pats, *'
266 278 raise error.Abort(_('--normal cannot be used with --large'))
267 279 return orig(ui, repo, *pats, **opts)
268 280
281 @eh.wrapfunction(cmdutil, 'add')
269 282 def cmdutiladd(orig, ui, repo, matcher, prefix, explicitonly, **opts):
270 283 # The --normal flag short circuits this override
271 284 if opts.get(r'normal'):
@@ -279,6 +292,7 b' def cmdutiladd(orig, ui, repo, matcher, '
279 292 bad.extend(f for f in lbad)
280 293 return bad
281 294
295 @eh.wrapfunction(cmdutil, 'remove')
282 296 def cmdutilremove(orig, ui, repo, matcher, prefix, after, force, subrepos,
283 297 dryrun):
284 298 normalmatcher = composenormalfilematcher(matcher, repo[None].manifest())
@@ -287,6 +301,7 b' def cmdutilremove(orig, ui, repo, matche'
287 301 return removelargefiles(ui, repo, False, matcher, dryrun, after=after,
288 302 force=force) or result
289 303
304 @eh.wrapfunction(subrepo.hgsubrepo, 'status')
290 305 def overridestatusfn(orig, repo, rev2, **opts):
291 306 try:
292 307 repo._repo.lfstatus = True
@@ -302,6 +317,7 b' def overridestatus(orig, ui, repo, *pats'
302 317 finally:
303 318 repo.lfstatus = False
304 319
320 @eh.wrapfunction(subrepo.hgsubrepo, 'dirty')
305 321 def overridedirty(orig, repo, ignoreupdate=False, missing=False):
306 322 try:
307 323 repo._repo.lfstatus = True
@@ -454,6 +470,7 b' def overridedebugstate(orig, ui, repo, *'
454 470 # The overridden function filters the unknown files by removing any
455 471 # largefiles. This makes the merge proceed and we can then handle this
456 472 # case further in the overridden calculateupdates function below.
473 @eh.wrapfunction(merge, '_checkunknownfile')
457 474 def overridecheckunknownfile(origfn, repo, wctx, mctx, f, f2=None):
458 475 if lfutil.standin(repo.dirstate.normalize(f)) in wctx:
459 476 return False
@@ -485,6 +502,7 b' def overridecheckunknownfile(origfn, rep'
485 502 # Finally, the merge.applyupdates function will then take care of
486 503 # writing the files into the working copy and lfcommands.updatelfiles
487 504 # will update the largefiles.
505 @eh.wrapfunction(merge, 'calculateupdates')
488 506 def overridecalculateupdates(origfn, repo, p1, p2, pas, branchmerge, force,
489 507 acceptremote, *args, **kwargs):
490 508 overwrite = force and not branchmerge
@@ -553,6 +571,7 b' def overridecalculateupdates(origfn, rep'
553 571
554 572 return actions, diverge, renamedelete
555 573
574 @eh.wrapfunction(merge, 'recordupdates')
556 575 def mergerecordupdates(orig, repo, actions, branchmerge):
557 576 if 'lfmr' in actions:
558 577 lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
@@ -568,6 +587,7 b' def mergerecordupdates(orig, repo, actio'
568 587
569 588 # Override filemerge to prompt the user about how they wish to merge
570 589 # largefiles. This will handle identical edits without prompting the user.
590 @eh.wrapfunction(filemerge, '_filemerge')
571 591 def overridefilemerge(origfn, premerge, repo, wctx, mynode, orig, fcd, fco, fca,
572 592 labels=None):
573 593 if not lfutil.isstandin(orig) or fcd.isabsent() or fco.isabsent():
@@ -589,6 +609,7 b' def overridefilemerge(origfn, premerge, '
589 609 repo.wwrite(fcd.path(), fco.data(), fco.flags())
590 610 return True, 0, False
591 611
612 @eh.wrapfunction(copiesmod, 'pathcopies')
592 613 def copiespathcopies(orig, ctx1, ctx2, match=None):
593 614 copies = orig(ctx1, ctx2, match=match)
594 615 updated = {}
@@ -603,6 +624,7 b' def copiespathcopies(orig, ctx1, ctx2, m'
603 624 # checks if the destination largefile already exists. It also keeps a
604 625 # list of copied files so that the largefiles can be copied and the
605 626 # dirstate updated.
627 @eh.wrapfunction(cmdutil, 'copy')
606 628 def overridecopy(orig, ui, repo, pats, opts, rename=False):
607 629 # doesn't remove largefile on rename
608 630 if len(pats) < 2:
@@ -748,6 +770,7 b' def overridecopy(orig, ui, repo, pats, o'
748 770 # commits. Update the standins then run the original revert, changing
749 771 # the matcher to hit standins instead of largefiles. Based on the
750 772 # resulting standins update the largefiles.
773 @eh.wrapfunction(cmdutil, 'revert')
751 774 def overriderevert(orig, ui, repo, ctx, parents, *pats, **opts):
752 775 # Because we put the standins in a bad state (by updating them)
753 776 # and then return them to a correct state we need to lock to
@@ -857,6 +880,7 b' def overridepush(orig, ui, repo, *args, '
857 880 opargs['lfrevs'] = scmutil.revrange(repo, lfrevs)
858 881 return orig(ui, repo, *args, **kwargs)
859 882
883 @eh.wrapfunction(exchange, 'pushoperation')
860 884 def exchangepushoperation(orig, *args, **kwargs):
861 885 """Override pushoperation constructor and store lfrevs parameter"""
862 886 lfrevs = kwargs.pop(r'lfrevs', None)
@@ -906,6 +930,7 b' def overrideclone(orig, ui, source, dest'
906 930
907 931 return orig(ui, source, dest, **opts)
908 932
933 @eh.wrapfunction(hg, 'clone')
909 934 def hgclone(orig, ui, opts, *args, **kwargs):
910 935 result = orig(ui, opts, *args, **kwargs)
911 936
@@ -953,6 +978,7 b' def overridearchivecmd(orig, ui, repo, d'
953 978 finally:
954 979 repo.unfiltered().lfstatus = False
955 980
981 @eh.wrapfunction(webcommands, 'archive')
956 982 def hgwebarchive(orig, web):
957 983 web.repo.lfstatus = True
958 984
@@ -961,6 +987,7 b' def hgwebarchive(orig, web):'
961 987 finally:
962 988 web.repo.lfstatus = False
963 989
990 @eh.wrapfunction(archival, 'archive')
964 991 def overridearchive(orig, repo, dest, node, kind, decode=True, match=None,
965 992 prefix='', mtime=None, subrepos=None):
966 993 # For some reason setting repo.lfstatus in hgwebarchive only changes the
@@ -1029,6 +1056,7 b' def overridearchive(orig, repo, dest, no'
1029 1056
1030 1057 archiver.done()
1031 1058
1059 @eh.wrapfunction(subrepo.hgsubrepo, 'archive')
1032 1060 def hgsubrepoarchive(orig, repo, archiver, prefix, match=None, decode=True):
1033 1061 lfenabled = util.safehasattr(repo._repo, '_largefilesenabled')
1034 1062 if not lfenabled or not repo._repo.lfstatus:
@@ -1083,6 +1111,7 b' def hgsubrepoarchive(orig, repo, archive'
1083 1111 # standin until a commit. cmdutil.bailifchanged() raises an exception
1084 1112 # if the repo has uncommitted changes. Wrap it to also check if
1085 1113 # largefiles were changed. This is used by bisect, backout and fetch.
1114 @eh.wrapfunction(cmdutil, 'bailifchanged')
1086 1115 def overridebailifchanged(orig, repo, *args, **kwargs):
1087 1116 orig(repo, *args, **kwargs)
1088 1117 repo.lfstatus = True
@@ -1091,6 +1120,7 b' def overridebailifchanged(orig, repo, *a'
1091 1120 if s.modified or s.added or s.removed or s.deleted:
1092 1121 raise error.Abort(_('uncommitted changes'))
1093 1122
1123 @eh.wrapfunction(cmdutil, 'postcommitstatus')
1094 1124 def postcommitstatus(orig, repo, *args, **kwargs):
1095 1125 repo.lfstatus = True
1096 1126 try:
@@ -1098,6 +1128,7 b' def postcommitstatus(orig, repo, *args, '
1098 1128 finally:
1099 1129 repo.lfstatus = False
1100 1130
1131 @eh.wrapfunction(cmdutil, 'forget')
1101 1132 def cmdutilforget(orig, ui, repo, match, prefix, explicitonly, dryrun,
1102 1133 interactive):
1103 1134 normalmatcher = composenormalfilematcher(match, repo[None].manifest())
@@ -1244,6 +1275,7 b' def overridesummary(orig, ui, repo, *pat'
1244 1275 finally:
1245 1276 repo.lfstatus = False
1246 1277
1278 @eh.wrapfunction(scmutil, 'addremove')
1247 1279 def scmutiladdremove(orig, repo, matcher, prefix, opts=None):
1248 1280 if opts is None:
1249 1281 opts = {}
@@ -1420,6 +1452,7 b' def overridecat(orig, ui, repo, file1, *'
1420 1452 err = 0
1421 1453 return err
1422 1454
1455 @eh.wrapfunction(merge, 'update')
1423 1456 def mergeupdate(orig, repo, node, branchmerge, force,
1424 1457 *args, **kwargs):
1425 1458 matcher = kwargs.get(r'matcher', None)
@@ -1497,6 +1530,7 b' def mergeupdate(orig, repo, node, branch'
1497 1530
1498 1531 return result
1499 1532
1533 @eh.wrapfunction(scmutil, 'marktouched')
1500 1534 def scmutilmarktouched(orig, repo, files, *args, **kwargs):
1501 1535 result = orig(repo, files, *args, **kwargs)
1502 1536
@@ -1511,6 +1545,8 b' def scmutilmarktouched(orig, repo, files'
1511 1545
1512 1546 return result
1513 1547
1548 @eh.wrapfunction(upgrade, 'preservedrequirements')
1549 @eh.wrapfunction(upgrade, 'supporteddestrequirements')
1514 1550 def upgraderequirements(orig, repo):
1515 1551 reqs = orig(repo)
1516 1552 if 'largefiles' in repo.requirements:
@@ -1518,6 +1554,8 b' def upgraderequirements(orig, repo):'
1518 1554 return reqs
1519 1555
1520 1556 _lfscheme = 'largefile://'
1557
1558 @eh.wrapfunction(urlmod, 'open')
1521 1559 def openlargefile(orig, ui, url_, data=None):
1522 1560 if url_.startswith(_lfscheme):
1523 1561 if data:
@@ -11,10 +11,12 b' from mercurial.i18n import _'
11 11
12 12 from mercurial import (
13 13 error,
14 exthelper,
14 15 httppeer,
15 16 util,
16 17 wireprototypes,
17 18 wireprotov1peer,
19 wireprotov1server,
18 20 )
19 21
20 22 from . import (
@@ -28,6 +30,8 b" LARGEFILES_REQUIRED_MSG = ('\\nThis repos"
28 30 '\n\nPlease enable it in your Mercurial config '
29 31 'file.\n')
30 32
33 eh = exthelper.exthelper()
34
31 35 # these will all be replaced by largefiles.uisetup
32 36 ssholdcallstream = None
33 37 httpoldcallstream = None
@@ -162,6 +166,7 b' def wirereposetup(ui, repo):'
162 166 repo.__class__ = lfileswirerepository
163 167
164 168 # advertise the largefiles=serve capability
169 @eh.wrapfunction(wireprotov1server, '_capabilities')
165 170 def _capabilities(orig, repo, proto):
166 171 '''announce largefile server capability'''
167 172 caps = orig(repo, proto)
@@ -9,25 +9,11 b''
9 9 '''setup for largefiles extension: uisetup'''
10 10 from __future__ import absolute_import
11 11
12 from mercurial.hgweb import (
13 webcommands,
14 )
15
16 12 from mercurial import (
17 archival,
18 13 cmdutil,
19 copies,
20 exchange,
21 14 extensions,
22 filemerge,
23 hg,
24 15 httppeer,
25 merge,
26 scmutil,
27 16 sshpeer,
28 subrepo,
29 upgrade,
30 url,
31 17 wireprotov1server,
32 18 )
33 19
@@ -37,67 +23,10 b' from . import ('
37 23 )
38 24
39 25 def uisetup(ui):
40 # Disable auto-status for some commands which assume that all
41 # files in the result are under Mercurial's control
42
43 # The scmutil function is called both by the (trivial) addremove command,
44 # and in the process of handling commit -A (issue3542)
45 extensions.wrapfunction(scmutil, 'addremove', overrides.scmutiladdremove)
46 extensions.wrapfunction(cmdutil, 'add', overrides.cmdutiladd)
47 extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove)
48 extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget)
49
50 extensions.wrapfunction(copies, 'pathcopies', overrides.copiespathcopies)
51
52 extensions.wrapfunction(upgrade, 'preservedrequirements',
53 overrides.upgraderequirements)
54
55 extensions.wrapfunction(upgrade, 'supporteddestrequirements',
56 overrides.upgraderequirements)
57
58 # Subrepos call status function
59 extensions.wrapfunction(subrepo.hgsubrepo, 'status',
60 overrides.overridestatusfn)
61 26
62 27 cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
63 28 cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
64 29
65 extensions.wrapfunction(exchange, 'pushoperation',
66 overrides.exchangepushoperation)
67
68 extensions.wrapfunction(hg, 'clone', overrides.hgclone)
69
70 extensions.wrapfunction(merge, '_checkunknownfile',
71 overrides.overridecheckunknownfile)
72 extensions.wrapfunction(merge, 'calculateupdates',
73 overrides.overridecalculateupdates)
74 extensions.wrapfunction(merge, 'recordupdates',
75 overrides.mergerecordupdates)
76 extensions.wrapfunction(merge, 'update', overrides.mergeupdate)
77 extensions.wrapfunction(filemerge, '_filemerge',
78 overrides.overridefilemerge)
79 extensions.wrapfunction(cmdutil, 'copy', overrides.overridecopy)
80
81 # Summary calls dirty on the subrepos
82 extensions.wrapfunction(subrepo.hgsubrepo, 'dirty', overrides.overridedirty)
83
84 extensions.wrapfunction(cmdutil, 'revert', overrides.overriderevert)
85
86 extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
87 extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
88 overrides.hgsubrepoarchive)
89 extensions.wrapfunction(webcommands, 'archive', overrides.hgwebarchive)
90 extensions.wrapfunction(cmdutil, 'bailifchanged',
91 overrides.overridebailifchanged)
92
93 extensions.wrapfunction(cmdutil, 'postcommitstatus',
94 overrides.postcommitstatus)
95 extensions.wrapfunction(scmutil, 'marktouched',
96 overrides.scmutilmarktouched)
97
98 extensions.wrapfunction(url, 'open',
99 overrides.openlargefile)
100
101 30 # create the new wireproto commands ...
102 31 wireprotov1server.wireprotocommand('putlfile', 'sha', permission='push')(
103 32 proto.putlfile)
@@ -108,16 +37,10 b' def uisetup(ui):'
108 37 wireprotov1server.wireprotocommand('lheads', '', permission='pull')(
109 38 wireprotov1server.heads)
110 39
111 # ... and wrap some existing ones
112 40 extensions.wrapfunction(wireprotov1server.commands['heads'], 'func',
113 41 proto.heads)
114 42 # TODO also wrap wireproto.commandsv2 once heads is implemented there.
115 43
116 extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
117
118 extensions.wrapfunction(wireprotov1server, '_capabilities',
119 proto._capabilities)
120
121 44 # can't do this in reposetup because it needs to have happened before
122 45 # wirerepo.__init__ is called
123 46 proto.ssholdcallstream = sshpeer.sshv1peer._callstream
@@ -128,5 +51,6 b' def uisetup(ui):'
128 51 # override some extensions' stuff as well
129 52 for name, module in extensions.extensions():
130 53 if name == 'rebase':
54 # TODO: teach exthelper to handle this
131 55 extensions.wrapfunction(module, 'rebase',
132 56 overrides.overriderebase)
General Comments 0
You need to be logged in to leave comments. Login now