##// END OF EJS Templates
largefiles: wrap heads command handler more directly...
Gregory Szorc -
r37502:c22fd3c4 default
parent child Browse files
Show More
@@ -1,192 +1,193 b''
1 # Copyright 2011 Fog Creek Software
1 # Copyright 2011 Fog Creek Software
2 #
2 #
3 # This software may be used and distributed according to the terms of the
3 # This software may be used and distributed according to the terms of the
4 # GNU General Public License version 2 or any later version.
4 # GNU General Public License version 2 or any later version.
5 from __future__ import absolute_import
5 from __future__ import absolute_import
6
6
7 import os
7 import os
8 import re
8 import re
9
9
10 from mercurial.i18n import _
10 from mercurial.i18n import _
11
11
12 from mercurial import (
12 from mercurial import (
13 error,
13 error,
14 httppeer,
14 httppeer,
15 util,
15 util,
16 wireproto,
16 wireproto,
17 wireprototypes,
17 wireprototypes,
18 )
18 )
19
19
20 from . import (
20 from . import (
21 lfutil,
21 lfutil,
22 )
22 )
23
23
24 urlerr = util.urlerr
24 urlerr = util.urlerr
25 urlreq = util.urlreq
25 urlreq = util.urlreq
26
26
27 LARGEFILES_REQUIRED_MSG = ('\nThis repository uses the largefiles extension.'
27 LARGEFILES_REQUIRED_MSG = ('\nThis repository uses the largefiles extension.'
28 '\n\nPlease enable it in your Mercurial config '
28 '\n\nPlease enable it in your Mercurial config '
29 'file.\n')
29 'file.\n')
30
30
31 # these will all be replaced by largefiles.uisetup
31 # these will all be replaced by largefiles.uisetup
32 ssholdcallstream = None
32 ssholdcallstream = None
33 httpoldcallstream = None
33 httpoldcallstream = None
34
34
35 def putlfile(repo, proto, sha):
35 def putlfile(repo, proto, sha):
36 '''Server command for putting a largefile into a repository's local store
36 '''Server command for putting a largefile into a repository's local store
37 and into the user cache.'''
37 and into the user cache.'''
38 with proto.mayberedirectstdio() as output:
38 with proto.mayberedirectstdio() as output:
39 path = lfutil.storepath(repo, sha)
39 path = lfutil.storepath(repo, sha)
40 util.makedirs(os.path.dirname(path))
40 util.makedirs(os.path.dirname(path))
41 tmpfp = util.atomictempfile(path, createmode=repo.store.createmode)
41 tmpfp = util.atomictempfile(path, createmode=repo.store.createmode)
42
42
43 try:
43 try:
44 for p in proto.getpayload():
44 for p in proto.getpayload():
45 tmpfp.write(p)
45 tmpfp.write(p)
46 tmpfp._fp.seek(0)
46 tmpfp._fp.seek(0)
47 if sha != lfutil.hexsha1(tmpfp._fp):
47 if sha != lfutil.hexsha1(tmpfp._fp):
48 raise IOError(0, _('largefile contents do not match hash'))
48 raise IOError(0, _('largefile contents do not match hash'))
49 tmpfp.close()
49 tmpfp.close()
50 lfutil.linktousercache(repo, sha)
50 lfutil.linktousercache(repo, sha)
51 except IOError as e:
51 except IOError as e:
52 repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') %
52 repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') %
53 (sha, e.strerror))
53 (sha, e.strerror))
54 return wireprototypes.pushres(
54 return wireprototypes.pushres(
55 1, output.getvalue() if output else '')
55 1, output.getvalue() if output else '')
56 finally:
56 finally:
57 tmpfp.discard()
57 tmpfp.discard()
58
58
59 return wireprototypes.pushres(0, output.getvalue() if output else '')
59 return wireprototypes.pushres(0, output.getvalue() if output else '')
60
60
61 def getlfile(repo, proto, sha):
61 def getlfile(repo, proto, sha):
62 '''Server command for retrieving a largefile from the repository-local
62 '''Server command for retrieving a largefile from the repository-local
63 cache or user cache.'''
63 cache or user cache.'''
64 filename = lfutil.findfile(repo, sha)
64 filename = lfutil.findfile(repo, sha)
65 if not filename:
65 if not filename:
66 raise error.Abort(_('requested largefile %s not present in cache')
66 raise error.Abort(_('requested largefile %s not present in cache')
67 % sha)
67 % sha)
68 f = open(filename, 'rb')
68 f = open(filename, 'rb')
69 length = os.fstat(f.fileno())[6]
69 length = os.fstat(f.fileno())[6]
70
70
71 # Since we can't set an HTTP content-length header here, and
71 # Since we can't set an HTTP content-length header here, and
72 # Mercurial core provides no way to give the length of a streamres
72 # Mercurial core provides no way to give the length of a streamres
73 # (and reading the entire file into RAM would be ill-advised), we
73 # (and reading the entire file into RAM would be ill-advised), we
74 # just send the length on the first line of the response, like the
74 # just send the length on the first line of the response, like the
75 # ssh proto does for string responses.
75 # ssh proto does for string responses.
76 def generator():
76 def generator():
77 yield '%d\n' % length
77 yield '%d\n' % length
78 for chunk in util.filechunkiter(f):
78 for chunk in util.filechunkiter(f):
79 yield chunk
79 yield chunk
80 return wireprototypes.streamreslegacy(gen=generator())
80 return wireprototypes.streamreslegacy(gen=generator())
81
81
82 def statlfile(repo, proto, sha):
82 def statlfile(repo, proto, sha):
83 '''Server command for checking if a largefile is present - returns '2\n' if
83 '''Server command for checking if a largefile is present - returns '2\n' if
84 the largefile is missing, '0\n' if it seems to be in good condition.
84 the largefile is missing, '0\n' if it seems to be in good condition.
85
85
86 The value 1 is reserved for mismatched checksum, but that is too expensive
86 The value 1 is reserved for mismatched checksum, but that is too expensive
87 to be verified on every stat and must be caught be running 'hg verify'
87 to be verified on every stat and must be caught be running 'hg verify'
88 server side.'''
88 server side.'''
89 filename = lfutil.findfile(repo, sha)
89 filename = lfutil.findfile(repo, sha)
90 if not filename:
90 if not filename:
91 return wireprototypes.bytesresponse('2\n')
91 return wireprototypes.bytesresponse('2\n')
92 return wireprototypes.bytesresponse('0\n')
92 return wireprototypes.bytesresponse('0\n')
93
93
94 def wirereposetup(ui, repo):
94 def wirereposetup(ui, repo):
95 class lfileswirerepository(repo.__class__):
95 class lfileswirerepository(repo.__class__):
96 def putlfile(self, sha, fd):
96 def putlfile(self, sha, fd):
97 # unfortunately, httprepository._callpush tries to convert its
97 # unfortunately, httprepository._callpush tries to convert its
98 # input file-like into a bundle before sending it, so we can't use
98 # input file-like into a bundle before sending it, so we can't use
99 # it ...
99 # it ...
100 if issubclass(self.__class__, httppeer.httppeer):
100 if issubclass(self.__class__, httppeer.httppeer):
101 res = self._call('putlfile', data=fd, sha=sha,
101 res = self._call('putlfile', data=fd, sha=sha,
102 headers={r'content-type': r'application/mercurial-0.1'})
102 headers={r'content-type': r'application/mercurial-0.1'})
103 try:
103 try:
104 d, output = res.split('\n', 1)
104 d, output = res.split('\n', 1)
105 for l in output.splitlines(True):
105 for l in output.splitlines(True):
106 self.ui.warn(_('remote: '), l) # assume l ends with \n
106 self.ui.warn(_('remote: '), l) # assume l ends with \n
107 return int(d)
107 return int(d)
108 except ValueError:
108 except ValueError:
109 self.ui.warn(_('unexpected putlfile response: %r\n') % res)
109 self.ui.warn(_('unexpected putlfile response: %r\n') % res)
110 return 1
110 return 1
111 # ... but we can't use sshrepository._call because the data=
111 # ... but we can't use sshrepository._call because the data=
112 # argument won't get sent, and _callpush does exactly what we want
112 # argument won't get sent, and _callpush does exactly what we want
113 # in this case: send the data straight through
113 # in this case: send the data straight through
114 else:
114 else:
115 try:
115 try:
116 ret, output = self._callpush("putlfile", fd, sha=sha)
116 ret, output = self._callpush("putlfile", fd, sha=sha)
117 if ret == "":
117 if ret == "":
118 raise error.ResponseError(_('putlfile failed:'),
118 raise error.ResponseError(_('putlfile failed:'),
119 output)
119 output)
120 return int(ret)
120 return int(ret)
121 except IOError:
121 except IOError:
122 return 1
122 return 1
123 except ValueError:
123 except ValueError:
124 raise error.ResponseError(
124 raise error.ResponseError(
125 _('putlfile failed (unexpected response):'), ret)
125 _('putlfile failed (unexpected response):'), ret)
126
126
127 def getlfile(self, sha):
127 def getlfile(self, sha):
128 """returns an iterable with the chunks of the file with sha sha"""
128 """returns an iterable with the chunks of the file with sha sha"""
129 stream = self._callstream("getlfile", sha=sha)
129 stream = self._callstream("getlfile", sha=sha)
130 length = stream.readline()
130 length = stream.readline()
131 try:
131 try:
132 length = int(length)
132 length = int(length)
133 except ValueError:
133 except ValueError:
134 self._abort(error.ResponseError(_("unexpected response:"),
134 self._abort(error.ResponseError(_("unexpected response:"),
135 length))
135 length))
136
136
137 # SSH streams will block if reading more than length
137 # SSH streams will block if reading more than length
138 for chunk in util.filechunkiter(stream, limit=length):
138 for chunk in util.filechunkiter(stream, limit=length):
139 yield chunk
139 yield chunk
140 # HTTP streams must hit the end to process the last empty
140 # HTTP streams must hit the end to process the last empty
141 # chunk of Chunked-Encoding so the connection can be reused.
141 # chunk of Chunked-Encoding so the connection can be reused.
142 if issubclass(self.__class__, httppeer.httppeer):
142 if issubclass(self.__class__, httppeer.httppeer):
143 chunk = stream.read(1)
143 chunk = stream.read(1)
144 if chunk:
144 if chunk:
145 self._abort(error.ResponseError(_("unexpected response:"),
145 self._abort(error.ResponseError(_("unexpected response:"),
146 chunk))
146 chunk))
147
147
148 @wireproto.batchable
148 @wireproto.batchable
149 def statlfile(self, sha):
149 def statlfile(self, sha):
150 f = wireproto.future()
150 f = wireproto.future()
151 result = {'sha': sha}
151 result = {'sha': sha}
152 yield result, f
152 yield result, f
153 try:
153 try:
154 yield int(f.value)
154 yield int(f.value)
155 except (ValueError, urlerr.httperror):
155 except (ValueError, urlerr.httperror):
156 # If the server returns anything but an integer followed by a
156 # If the server returns anything but an integer followed by a
157 # newline, newline, it's not speaking our language; if we get
157 # newline, newline, it's not speaking our language; if we get
158 # an HTTP error, we can't be sure the largefile is present;
158 # an HTTP error, we can't be sure the largefile is present;
159 # either way, consider it missing.
159 # either way, consider it missing.
160 yield 2
160 yield 2
161
161
162 repo.__class__ = lfileswirerepository
162 repo.__class__ = lfileswirerepository
163
163
164 # advertise the largefiles=serve capability
164 # advertise the largefiles=serve capability
165 def _capabilities(orig, repo, proto):
165 def _capabilities(orig, repo, proto):
166 '''announce largefile server capability'''
166 '''announce largefile server capability'''
167 caps = orig(repo, proto)
167 caps = orig(repo, proto)
168 caps.append('largefiles=serve')
168 caps.append('largefiles=serve')
169 return caps
169 return caps
170
170
171 def heads(repo, proto):
171 def heads(orig, repo, proto):
172 '''Wrap server command - largefile capable clients will know to call
172 '''Wrap server command - largefile capable clients will know to call
173 lheads instead'''
173 lheads instead'''
174 if lfutil.islfilesrepo(repo):
174 if lfutil.islfilesrepo(repo):
175 return wireprototypes.ooberror(LARGEFILES_REQUIRED_MSG)
175 return wireprototypes.ooberror(LARGEFILES_REQUIRED_MSG)
176 return wireproto.heads(repo, proto)
176
177 return orig(repo, proto)
177
178
178 def sshrepocallstream(self, cmd, **args):
179 def sshrepocallstream(self, cmd, **args):
179 if cmd == 'heads' and self.capable('largefiles'):
180 if cmd == 'heads' and self.capable('largefiles'):
180 cmd = 'lheads'
181 cmd = 'lheads'
181 if cmd == 'batch' and self.capable('largefiles'):
182 if cmd == 'batch' and self.capable('largefiles'):
182 args[r'cmds'] = args[r'cmds'].replace('heads ', 'lheads ')
183 args[r'cmds'] = args[r'cmds'].replace('heads ', 'lheads ')
183 return ssholdcallstream(self, cmd, **args)
184 return ssholdcallstream(self, cmd, **args)
184
185
185 headsre = re.compile(br'(^|;)heads\b')
186 headsre = re.compile(br'(^|;)heads\b')
186
187
187 def httprepocallstream(self, cmd, **args):
188 def httprepocallstream(self, cmd, **args):
188 if cmd == 'heads' and self.capable('largefiles'):
189 if cmd == 'heads' and self.capable('largefiles'):
189 cmd = 'lheads'
190 cmd = 'lheads'
190 if cmd == 'batch' and self.capable('largefiles'):
191 if cmd == 'batch' and self.capable('largefiles'):
191 args[r'cmds'] = headsre.sub('lheads', args[r'cmds'])
192 args[r'cmds'] = headsre.sub('lheads', args[r'cmds'])
192 return httpoldcallstream(self, cmd, **args)
193 return httpoldcallstream(self, cmd, **args)
@@ -1,203 +1,203 b''
1 # Copyright 2009-2010 Gregory P. Ward
1 # Copyright 2009-2010 Gregory P. Ward
2 # Copyright 2009-2010 Intelerad Medical Systems Incorporated
2 # Copyright 2009-2010 Intelerad Medical Systems Incorporated
3 # Copyright 2010-2011 Fog Creek Software
3 # Copyright 2010-2011 Fog Creek Software
4 # Copyright 2010-2011 Unity Technologies
4 # Copyright 2010-2011 Unity Technologies
5 #
5 #
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
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.i18n import _
12 from mercurial.i18n import _
13
13
14 from mercurial.hgweb import (
14 from mercurial.hgweb import (
15 webcommands,
15 webcommands,
16 )
16 )
17
17
18 from mercurial import (
18 from mercurial import (
19 archival,
19 archival,
20 cmdutil,
20 cmdutil,
21 commands,
21 commands,
22 copies,
22 copies,
23 exchange,
23 exchange,
24 extensions,
24 extensions,
25 filemerge,
25 filemerge,
26 hg,
26 hg,
27 httppeer,
27 httppeer,
28 merge,
28 merge,
29 scmutil,
29 scmutil,
30 sshpeer,
30 sshpeer,
31 subrepo,
31 subrepo,
32 upgrade,
32 upgrade,
33 url,
33 url,
34 wireproto,
34 wireproto,
35 )
35 )
36
36
37 from . import (
37 from . import (
38 overrides,
38 overrides,
39 proto,
39 proto,
40 )
40 )
41
41
42 def uisetup(ui):
42 def uisetup(ui):
43 # Disable auto-status for some commands which assume that all
43 # Disable auto-status for some commands which assume that all
44 # files in the result are under Mercurial's control
44 # files in the result are under Mercurial's control
45
45
46 entry = extensions.wrapcommand(commands.table, 'add',
46 entry = extensions.wrapcommand(commands.table, 'add',
47 overrides.overrideadd)
47 overrides.overrideadd)
48 addopt = [('', 'large', None, _('add as largefile')),
48 addopt = [('', 'large', None, _('add as largefile')),
49 ('', 'normal', None, _('add as normal file')),
49 ('', 'normal', None, _('add as normal file')),
50 ('', 'lfsize', '', _('add all files above this size '
50 ('', 'lfsize', '', _('add all files above this size '
51 '(in megabytes) as largefiles '
51 '(in megabytes) as largefiles '
52 '(default: 10)'))]
52 '(default: 10)'))]
53 entry[1].extend(addopt)
53 entry[1].extend(addopt)
54
54
55 # The scmutil function is called both by the (trivial) addremove command,
55 # The scmutil function is called both by the (trivial) addremove command,
56 # and in the process of handling commit -A (issue3542)
56 # and in the process of handling commit -A (issue3542)
57 extensions.wrapfunction(scmutil, 'addremove', overrides.scmutiladdremove)
57 extensions.wrapfunction(scmutil, 'addremove', overrides.scmutiladdremove)
58 extensions.wrapfunction(cmdutil, 'add', overrides.cmdutiladd)
58 extensions.wrapfunction(cmdutil, 'add', overrides.cmdutiladd)
59 extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove)
59 extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove)
60 extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget)
60 extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget)
61
61
62 extensions.wrapfunction(copies, 'pathcopies', overrides.copiespathcopies)
62 extensions.wrapfunction(copies, 'pathcopies', overrides.copiespathcopies)
63
63
64 extensions.wrapfunction(upgrade, 'preservedrequirements',
64 extensions.wrapfunction(upgrade, 'preservedrequirements',
65 overrides.upgraderequirements)
65 overrides.upgraderequirements)
66
66
67 extensions.wrapfunction(upgrade, 'supporteddestrequirements',
67 extensions.wrapfunction(upgrade, 'supporteddestrequirements',
68 overrides.upgraderequirements)
68 overrides.upgraderequirements)
69
69
70 # Subrepos call status function
70 # Subrepos call status function
71 entry = extensions.wrapcommand(commands.table, 'status',
71 entry = extensions.wrapcommand(commands.table, 'status',
72 overrides.overridestatus)
72 overrides.overridestatus)
73 extensions.wrapfunction(subrepo.hgsubrepo, 'status',
73 extensions.wrapfunction(subrepo.hgsubrepo, 'status',
74 overrides.overridestatusfn)
74 overrides.overridestatusfn)
75
75
76 entry = extensions.wrapcommand(commands.table, 'log',
76 entry = extensions.wrapcommand(commands.table, 'log',
77 overrides.overridelog)
77 overrides.overridelog)
78 entry = extensions.wrapcommand(commands.table, 'rollback',
78 entry = extensions.wrapcommand(commands.table, 'rollback',
79 overrides.overriderollback)
79 overrides.overriderollback)
80 entry = extensions.wrapcommand(commands.table, 'verify',
80 entry = extensions.wrapcommand(commands.table, 'verify',
81 overrides.overrideverify)
81 overrides.overrideverify)
82
82
83 verifyopt = [('', 'large', None,
83 verifyopt = [('', 'large', None,
84 _('verify that all largefiles in current revision exists')),
84 _('verify that all largefiles in current revision exists')),
85 ('', 'lfa', None,
85 ('', 'lfa', None,
86 _('verify largefiles in all revisions, not just current')),
86 _('verify largefiles in all revisions, not just current')),
87 ('', 'lfc', None,
87 ('', 'lfc', None,
88 _('verify local largefile contents, not just existence'))]
88 _('verify local largefile contents, not just existence'))]
89 entry[1].extend(verifyopt)
89 entry[1].extend(verifyopt)
90
90
91 entry = extensions.wrapcommand(commands.table, 'debugstate',
91 entry = extensions.wrapcommand(commands.table, 'debugstate',
92 overrides.overridedebugstate)
92 overrides.overridedebugstate)
93 debugstateopt = [('', 'large', None, _('display largefiles dirstate'))]
93 debugstateopt = [('', 'large', None, _('display largefiles dirstate'))]
94 entry[1].extend(debugstateopt)
94 entry[1].extend(debugstateopt)
95
95
96 outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs)
96 outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs)
97 entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
97 entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
98 outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
98 outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
99 entry[1].extend(outgoingopt)
99 entry[1].extend(outgoingopt)
100 cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
100 cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
101 entry = extensions.wrapcommand(commands.table, 'summary',
101 entry = extensions.wrapcommand(commands.table, 'summary',
102 overrides.overridesummary)
102 overrides.overridesummary)
103 summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
103 summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
104 entry[1].extend(summaryopt)
104 entry[1].extend(summaryopt)
105 cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
105 cmdutil.summaryremotehooks.add('largefiles', overrides.summaryremotehook)
106
106
107 entry = extensions.wrapcommand(commands.table, 'pull',
107 entry = extensions.wrapcommand(commands.table, 'pull',
108 overrides.overridepull)
108 overrides.overridepull)
109 pullopt = [('', 'all-largefiles', None,
109 pullopt = [('', 'all-largefiles', None,
110 _('download all pulled versions of largefiles (DEPRECATED)')),
110 _('download all pulled versions of largefiles (DEPRECATED)')),
111 ('', 'lfrev', [],
111 ('', 'lfrev', [],
112 _('download largefiles for these revisions'), _('REV'))]
112 _('download largefiles for these revisions'), _('REV'))]
113 entry[1].extend(pullopt)
113 entry[1].extend(pullopt)
114
114
115 entry = extensions.wrapcommand(commands.table, 'push',
115 entry = extensions.wrapcommand(commands.table, 'push',
116 overrides.overridepush)
116 overrides.overridepush)
117 pushopt = [('', 'lfrev', [],
117 pushopt = [('', 'lfrev', [],
118 _('upload largefiles for these revisions'), _('REV'))]
118 _('upload largefiles for these revisions'), _('REV'))]
119 entry[1].extend(pushopt)
119 entry[1].extend(pushopt)
120 extensions.wrapfunction(exchange, 'pushoperation',
120 extensions.wrapfunction(exchange, 'pushoperation',
121 overrides.exchangepushoperation)
121 overrides.exchangepushoperation)
122
122
123 entry = extensions.wrapcommand(commands.table, 'clone',
123 entry = extensions.wrapcommand(commands.table, 'clone',
124 overrides.overrideclone)
124 overrides.overrideclone)
125 cloneopt = [('', 'all-largefiles', None,
125 cloneopt = [('', 'all-largefiles', None,
126 _('download all versions of all largefiles'))]
126 _('download all versions of all largefiles'))]
127 entry[1].extend(cloneopt)
127 entry[1].extend(cloneopt)
128 extensions.wrapfunction(hg, 'clone', overrides.hgclone)
128 extensions.wrapfunction(hg, 'clone', overrides.hgclone)
129 extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare)
129 extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare)
130
130
131 entry = extensions.wrapcommand(commands.table, 'cat',
131 entry = extensions.wrapcommand(commands.table, 'cat',
132 overrides.overridecat)
132 overrides.overridecat)
133 extensions.wrapfunction(merge, '_checkunknownfile',
133 extensions.wrapfunction(merge, '_checkunknownfile',
134 overrides.overridecheckunknownfile)
134 overrides.overridecheckunknownfile)
135 extensions.wrapfunction(merge, 'calculateupdates',
135 extensions.wrapfunction(merge, 'calculateupdates',
136 overrides.overridecalculateupdates)
136 overrides.overridecalculateupdates)
137 extensions.wrapfunction(merge, 'recordupdates',
137 extensions.wrapfunction(merge, 'recordupdates',
138 overrides.mergerecordupdates)
138 overrides.mergerecordupdates)
139 extensions.wrapfunction(merge, 'update', overrides.mergeupdate)
139 extensions.wrapfunction(merge, 'update', overrides.mergeupdate)
140 extensions.wrapfunction(filemerge, '_filemerge',
140 extensions.wrapfunction(filemerge, '_filemerge',
141 overrides.overridefilemerge)
141 overrides.overridefilemerge)
142 extensions.wrapfunction(cmdutil, 'copy', overrides.overridecopy)
142 extensions.wrapfunction(cmdutil, 'copy', overrides.overridecopy)
143
143
144 # Summary calls dirty on the subrepos
144 # Summary calls dirty on the subrepos
145 extensions.wrapfunction(subrepo.hgsubrepo, 'dirty', overrides.overridedirty)
145 extensions.wrapfunction(subrepo.hgsubrepo, 'dirty', overrides.overridedirty)
146
146
147 extensions.wrapfunction(cmdutil, 'revert', overrides.overriderevert)
147 extensions.wrapfunction(cmdutil, 'revert', overrides.overriderevert)
148
148
149 extensions.wrapcommand(commands.table, 'archive',
149 extensions.wrapcommand(commands.table, 'archive',
150 overrides.overridearchivecmd)
150 overrides.overridearchivecmd)
151 extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
151 extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
152 extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
152 extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
153 overrides.hgsubrepoarchive)
153 overrides.hgsubrepoarchive)
154 extensions.wrapfunction(webcommands, 'archive', overrides.hgwebarchive)
154 extensions.wrapfunction(webcommands, 'archive', overrides.hgwebarchive)
155 extensions.wrapfunction(cmdutil, 'bailifchanged',
155 extensions.wrapfunction(cmdutil, 'bailifchanged',
156 overrides.overridebailifchanged)
156 overrides.overridebailifchanged)
157
157
158 extensions.wrapfunction(cmdutil, 'postcommitstatus',
158 extensions.wrapfunction(cmdutil, 'postcommitstatus',
159 overrides.postcommitstatus)
159 overrides.postcommitstatus)
160 extensions.wrapfunction(scmutil, 'marktouched',
160 extensions.wrapfunction(scmutil, 'marktouched',
161 overrides.scmutilmarktouched)
161 overrides.scmutilmarktouched)
162
162
163 extensions.wrapfunction(url, 'open',
163 extensions.wrapfunction(url, 'open',
164 overrides.openlargefile)
164 overrides.openlargefile)
165
165
166 # create the new wireproto commands ...
166 # create the new wireproto commands ...
167 wireproto.wireprotocommand('putlfile', 'sha', permission='push')(
167 wireproto.wireprotocommand('putlfile', 'sha', permission='push')(
168 proto.putlfile)
168 proto.putlfile)
169 wireproto.wireprotocommand('getlfile', 'sha', permission='pull')(
169 wireproto.wireprotocommand('getlfile', 'sha', permission='pull')(
170 proto.getlfile)
170 proto.getlfile)
171 wireproto.wireprotocommand('statlfile', 'sha', permission='pull')(
171 wireproto.wireprotocommand('statlfile', 'sha', permission='pull')(
172 proto.statlfile)
172 proto.statlfile)
173 wireproto.wireprotocommand('lheads', '', permission='pull')(
173 wireproto.wireprotocommand('lheads', '', permission='pull')(
174 wireproto.heads)
174 wireproto.heads)
175
175
176 # ... and wrap some existing ones
176 # ... and wrap some existing ones
177 wireproto.commands['heads'].func = proto.heads
177 extensions.wrapfunction(wireproto.commands['heads'], 'func', proto.heads)
178 # TODO also wrap wireproto.commandsv2 once heads is implemented there.
178 # TODO also wrap wireproto.commandsv2 once heads is implemented there.
179
179
180 extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
180 extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath)
181
181
182 extensions.wrapfunction(wireproto, '_capabilities', proto._capabilities)
182 extensions.wrapfunction(wireproto, '_capabilities', proto._capabilities)
183
183
184 # can't do this in reposetup because it needs to have happened before
184 # can't do this in reposetup because it needs to have happened before
185 # wirerepo.__init__ is called
185 # wirerepo.__init__ is called
186 proto.ssholdcallstream = sshpeer.sshv1peer._callstream
186 proto.ssholdcallstream = sshpeer.sshv1peer._callstream
187 proto.httpoldcallstream = httppeer.httppeer._callstream
187 proto.httpoldcallstream = httppeer.httppeer._callstream
188 sshpeer.sshv1peer._callstream = proto.sshrepocallstream
188 sshpeer.sshv1peer._callstream = proto.sshrepocallstream
189 httppeer.httppeer._callstream = proto.httprepocallstream
189 httppeer.httppeer._callstream = proto.httprepocallstream
190
190
191 # override some extensions' stuff as well
191 # override some extensions' stuff as well
192 for name, module in extensions.extensions():
192 for name, module in extensions.extensions():
193 if name == 'purge':
193 if name == 'purge':
194 extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
194 extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
195 overrides.overridepurge)
195 overrides.overridepurge)
196 if name == 'rebase':
196 if name == 'rebase':
197 extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
197 extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
198 overrides.overriderebase)
198 overrides.overriderebase)
199 extensions.wrapfunction(module, 'rebase',
199 extensions.wrapfunction(module, 'rebase',
200 overrides.overriderebase)
200 overrides.overriderebase)
201 if name == 'transplant':
201 if name == 'transplant':
202 extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant',
202 extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant',
203 overrides.overridetransplant)
203 overrides.overridetransplant)
General Comments 0
You need to be logged in to leave comments. Login now