##// END OF EJS Templates
lfs: show a friendly message when pushing lfs to a server without lfs enabled...
Matt Harbison -
r35522:fa865878 default
parent child Browse files
Show More
@@ -49,6 +49,7 b' from mercurial import ('
49 scmutil,
49 scmutil,
50 upgrade,
50 upgrade,
51 vfs as vfsmod,
51 vfs as vfsmod,
52 wireproto,
52 )
53 )
53
54
54 from . import (
55 from . import (
@@ -169,6 +170,9 b' def extsetup(ui):'
169 'allsupportedversions',
170 'allsupportedversions',
170 wrapper.allsupportedversions)
171 wrapper.allsupportedversions)
171
172
173 wrapfunction(exchange, 'push', wrapper.push)
174 wrapfunction(wireproto, '_capabilities', wrapper._capabilities)
175
172 wrapfunction(context.basefilectx, 'cmp', wrapper.filectxcmp)
176 wrapfunction(context.basefilectx, 'cmp', wrapper.filectxcmp)
173 wrapfunction(context.basefilectx, 'isbinary', wrapper.filectxisbinary)
177 wrapfunction(context.basefilectx, 'isbinary', wrapper.filectxisbinary)
174 context.basefilectx.islfs = wrapper.filectxislfs
178 context.basefilectx.islfs = wrapper.filectxislfs
@@ -39,6 +39,13 b' def allsupportedversions(orig, ui):'
39 versions.add('03')
39 versions.add('03')
40 return versions
40 return versions
41
41
42 def _capabilities(orig, repo, proto):
43 '''Wrap server command to announce lfs server capability'''
44 caps = orig(repo, proto)
45 # XXX: change to 'lfs=serve' when separate git server isn't required?
46 caps.append('lfs')
47 return caps
48
42 def bypasscheckhash(self, text):
49 def bypasscheckhash(self, text):
43 return False
50 return False
44
51
@@ -265,6 +272,20 b' def prepush(pushop):'
265 """
272 """
266 return uploadblobsfromrevs(pushop.repo, pushop.outgoing.missing)
273 return uploadblobsfromrevs(pushop.repo, pushop.outgoing.missing)
267
274
275 def push(orig, repo, remote, *args, **kwargs):
276 """bail on push if the extension isn't enabled on remote when needed"""
277 if 'lfs' in repo.requirements:
278 # If the remote peer is for a local repo, the requirement tests in the
279 # base class method enforce lfs support. Otherwise, some revisions in
280 # this repo use lfs, and the remote repo needs the extension loaded.
281 if not remote.local() and not remote.capable('lfs'):
282 # This is a copy of the message in exchange.push() when requirements
283 # are missing between local repos.
284 m = _("required features are not supported in the destination: %s")
285 raise error.Abort(m % 'lfs',
286 hint=_('enable the lfs extension on the server'))
287 return orig(repo, remote, *args, **kwargs)
288
268 def writenewbundle(orig, ui, repo, source, filename, bundletype, outgoing,
289 def writenewbundle(orig, ui, repo, source, filename, bundletype, outgoing,
269 *args, **kwargs):
290 *args, **kwargs):
270 """upload LFS blobs added by outgoing revisions on 'hg bundle'"""
291 """upload LFS blobs added by outgoing revisions on 'hg bundle'"""
@@ -124,10 +124,14 b" should have an 'lfs' requirement after i"
124 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
124 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
125 .hg/requires:lfs
125 .hg/requires:lfs
126
126
127 TODO: fail more gracefully here
127 #if lfsremote-off
128 $ hg push -q 2>&1 | grep '^[A-Z]' || true
128 $ hg push -q
129 Traceback (most recent call last): (lfsremote-off !)
129 abort: required features are not supported in the destination: lfs
130 ValueError: no common changegroup version (lfsremote-off !)
130 (enable the lfs extension on the server)
131 [255]
132 #else
133 $ hg push -q
134 #endif
131 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
135 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
132 .hg/requires:lfs
136 .hg/requires:lfs
133 $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
137 $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
General Comments 0
You need to be logged in to leave comments. Login now