comparison hgext/largefiles/uisetup.py @ 41062:0a7f582f6f1f

largefiles: port wrapped functions to exthelper Things get interesting in the commit. I hadn't seen issue6033 on Windows, and yet it is now reproducible 100% of the time on Windows 10 with this commit. I didn't test Linux. (For comparison, after seeing this issue, I tested on the parent with --loop, and it failed 5 times out of over 1300 tests.) The strange thing is that largefiles has nothing to do with that test (it's not even mentioned there). It isn't autoloading run amuck- it occurs even if largefiles is explicitly disabled, and also if the entry in afterhgrcload() is commented out. It's also not the import of lfutil- I disabled that by copying the function into lfs and removing the import, and the problem still occurs. Experimenting further, it seems that the problem is isolated to 3 entries: exchange.pushoperation, hg.clone, and cmdutil.revert. If those decorators are all commented out, the test passes when run in a loop for awhile. (Obviously, some largefiles tests will fail.) But if any one is commented back in, the test fails immediately. I left one method related to wrapping the wire protocol, because it seemed more natural with the TODO. Also, exthelper doesn't support wrapping functions from another extension, only commands in another extension. I didn't try to figure out why rebase is both command wrapped and function wrapped.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 23 Dec 2018 22:57:03 -0500
parents 98681293c890
children
comparison
equal deleted inserted replaced
41061:98681293c890 41062:0a7f582f6f1f
7 # GNU General Public License version 2 or any later version. 7 # GNU General Public License version 2 or any later version.
8 8
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.hgweb import (
13 webcommands,
14 )
15
16 from mercurial import ( 12 from mercurial import (
17 archival,
18 cmdutil, 13 cmdutil,
19 copies,
20 exchange,
21 extensions, 14 extensions,
22 filemerge,
23 hg,
24 httppeer, 15 httppeer,
25 merge,
26 scmutil,
27 sshpeer, 16 sshpeer,
28 subrepo,
29 upgrade,
30 url,
31 wireprotov1server, 17 wireprotov1server,
32 ) 18 )
33 19
34 from . import ( 20 from . import (
35 overrides, 21 overrides,
36 proto, 22 proto,
37 ) 23 )
38 24
39 def uisetup(ui): 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 cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook) 27 cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
63 cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook) 28 cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
64
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 29
101 # create the new wireproto commands ... 30 # create the new wireproto commands ...
102 wireprotov1server.wireprotocommand('putlfile', 'sha', permission='push')( 31 wireprotov1server.wireprotocommand('putlfile', 'sha', permission='push')(
103 proto.putlfile) 32 proto.putlfile)
104 wireprotov1server.wireprotocommand('getlfile', 'sha', permission='pull')( 33 wireprotov1server.wireprotocommand('getlfile', 'sha', permission='pull')(
106 wireprotov1server.wireprotocommand('statlfile', 'sha', permission='pull')( 35 wireprotov1server.wireprotocommand('statlfile', 'sha', permission='pull')(
107 proto.statlfile) 36 proto.statlfile)
108 wireprotov1server.wireprotocommand('lheads', '', permission='pull')( 37 wireprotov1server.wireprotocommand('lheads', '', permission='pull')(
109 wireprotov1server.heads) 38 wireprotov1server.heads)
110 39
111 # ... and wrap some existing ones
112 extensions.wrapfunction(wireprotov1server.commands['heads'], 'func', 40 extensions.wrapfunction(wireprotov1server.commands['heads'], 'func',
113 proto.heads) 41 proto.heads)
114 # TODO also wrap wireproto.commandsv2 once heads is implemented there. 42 # TODO also wrap wireproto.commandsv2 once heads is implemented there.
115
116 extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
117
118 extensions.wrapfunction(wireprotov1server, '_capabilities',
119 proto._capabilities)
120 43
121 # can't do this in reposetup because it needs to have happened before 44 # can't do this in reposetup because it needs to have happened before
122 # wirerepo.__init__ is called 45 # wirerepo.__init__ is called
123 proto.ssholdcallstream = sshpeer.sshv1peer._callstream 46 proto.ssholdcallstream = sshpeer.sshv1peer._callstream
124 proto.httpoldcallstream = httppeer.httppeer._callstream 47 proto.httpoldcallstream = httppeer.httppeer._callstream
126 httppeer.httppeer._callstream = proto.httprepocallstream 49 httppeer.httppeer._callstream = proto.httprepocallstream
127 50
128 # override some extensions' stuff as well 51 # override some extensions' stuff as well
129 for name, module in extensions.extensions(): 52 for name, module in extensions.extensions():
130 if name == 'rebase': 53 if name == 'rebase':
54 # TODO: teach exthelper to handle this
131 extensions.wrapfunction(module, 'rebase', 55 extensions.wrapfunction(module, 'rebase',
132 overrides.overriderebase) 56 overrides.overriderebase)