Show More
@@ -124,6 +124,8 b' Configs::' | |||||
124 |
|
124 | |||
125 | from __future__ import absolute_import |
|
125 | from __future__ import absolute_import | |
126 |
|
126 | |||
|
127 | import sys | |||
|
128 | ||||
127 | from mercurial.i18n import _ |
|
129 | from mercurial.i18n import _ | |
128 |
|
130 | |||
129 | from mercurial import ( |
|
131 | from mercurial import ( | |
@@ -204,6 +206,12 b' command = registrar.command(cmdtable)' | |||||
204 | templatekeyword = registrar.templatekeyword() |
|
206 | templatekeyword = registrar.templatekeyword() | |
205 | filesetpredicate = registrar.filesetpredicate() |
|
207 | filesetpredicate = registrar.filesetpredicate() | |
206 |
|
208 | |||
|
209 | lfsprocessor = ( | |||
|
210 | wrapper.readfromstore, | |||
|
211 | wrapper.writetostore, | |||
|
212 | wrapper.bypasscheckhash, | |||
|
213 | ) | |||
|
214 | ||||
207 | def featuresetup(ui, supported): |
|
215 | def featuresetup(ui, supported): | |
208 | # don't die on seeing a repo with the lfs requirement |
|
216 | # don't die on seeing a repo with the lfs requirement | |
209 | supported |= {'lfs'} |
|
217 | supported |= {'lfs'} | |
@@ -302,12 +310,28 b' def wrapfilelog(filelog):' | |||||
302 | wrapfunction(filelog, 'renamed', wrapper.filelogrenamed) |
|
310 | wrapfunction(filelog, 'renamed', wrapper.filelogrenamed) | |
303 | wrapfunction(filelog, 'size', wrapper.filelogsize) |
|
311 | wrapfunction(filelog, 'size', wrapper.filelogsize) | |
304 |
|
312 | |||
|
313 | def _resolverevlogstorevfsoptions(orig, ui, requirements, features): | |||
|
314 | opts = orig(ui, requirements, features) | |||
|
315 | for name, module in extensions.extensions(ui): | |||
|
316 | if module is sys.modules[__name__]: | |||
|
317 | if revlog.REVIDX_EXTSTORED in opts[b'flagprocessors']: | |||
|
318 | msg = (_(b"cannot register multiple processors on flag '%#x'.") | |||
|
319 | % revlog.REVIDX_EXTSTORED) | |||
|
320 | raise error.Abort(msg) | |||
|
321 | ||||
|
322 | opts[b'flagprocessors'][revlog.REVIDX_EXTSTORED] = lfsprocessor | |||
|
323 | break | |||
|
324 | ||||
|
325 | return opts | |||
|
326 | ||||
305 | def extsetup(ui): |
|
327 | def extsetup(ui): | |
306 | wrapfilelog(filelog.filelog) |
|
328 | wrapfilelog(filelog.filelog) | |
307 |
|
329 | |||
308 | wrapfunction = extensions.wrapfunction |
|
330 | wrapfunction = extensions.wrapfunction | |
309 |
|
331 | |||
310 | wrapfunction(localrepo, 'makefilestorage', wrapper.localrepomakefilestorage) |
|
332 | wrapfunction(localrepo, 'makefilestorage', wrapper.localrepomakefilestorage) | |
|
333 | wrapfunction(localrepo, 'resolverevlogstorevfsoptions', | |||
|
334 | _resolverevlogstorevfsoptions) | |||
311 |
|
335 | |||
312 | wrapfunction(cmdutil, '_updatecatformatter', wrapper._updatecatformatter) |
|
336 | wrapfunction(cmdutil, '_updatecatformatter', wrapper._updatecatformatter) | |
313 | wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink) |
|
337 | wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink) | |
@@ -334,15 +358,6 b' def extsetup(ui):' | |||||
334 | wrapfunction(context.basefilectx, 'isbinary', wrapper.filectxisbinary) |
|
358 | wrapfunction(context.basefilectx, 'isbinary', wrapper.filectxisbinary) | |
335 | context.basefilectx.islfs = wrapper.filectxislfs |
|
359 | context.basefilectx.islfs = wrapper.filectxislfs | |
336 |
|
360 | |||
337 | revlog.addflagprocessor( |
|
|||
338 | revlog.REVIDX_EXTSTORED, |
|
|||
339 | ( |
|
|||
340 | wrapper.readfromstore, |
|
|||
341 | wrapper.writetostore, |
|
|||
342 | wrapper.bypasscheckhash, |
|
|||
343 | ), |
|
|||
344 | ) |
|
|||
345 |
|
||||
346 | scmutil.fileprefetchhooks.add('lfs', wrapper._prefetchfiles) |
|
361 | scmutil.fileprefetchhooks.add('lfs', wrapper._prefetchfiles) | |
347 |
|
362 | |||
348 | # Make bundle choose changegroup3 instead of changegroup2. This affects |
|
363 | # Make bundle choose changegroup3 instead of changegroup2. This affects |
@@ -35,6 +35,26 b' make command server magic visible' | |||||
35 | $ hg init server |
|
35 | $ hg init server | |
36 | $ SERVER_REQUIRES="$TESTTMP/server/.hg/requires" |
|
36 | $ SERVER_REQUIRES="$TESTTMP/server/.hg/requires" | |
37 |
|
37 | |||
|
38 | $ cat > $TESTTMP/debugprocessors.py <<EOF | |||
|
39 | > from mercurial import ( | |||
|
40 | > cmdutil, | |||
|
41 | > commands, | |||
|
42 | > pycompat, | |||
|
43 | > registrar, | |||
|
44 | > ) | |||
|
45 | > cmdtable = {} | |||
|
46 | > command = registrar.command(cmdtable) | |||
|
47 | > @command(b'debugprocessors', [], b'FILE') | |||
|
48 | > def debugprocessors(ui, repo, file_=None, **opts): | |||
|
49 | > opts = pycompat.byteskwargs(opts) | |||
|
50 | > opts[b'changelog'] = False | |||
|
51 | > opts[b'manifest'] = False | |||
|
52 | > opts[b'dir'] = False | |||
|
53 | > rl = cmdutil.openrevlog(repo, b'debugprocessors', file_, opts) | |||
|
54 | > for flag, proc in rl._flagprocessors.iteritems(): | |||
|
55 | > ui.status(b"registered processor '%#x'\n" % (flag)) | |||
|
56 | > EOF | |||
|
57 | ||||
38 | Skip the experimental.changegroup3=True config. Failure to agree on this comes |
|
58 | Skip the experimental.changegroup3=True config. Failure to agree on this comes | |
39 | first, and causes a "ValueError: no common changegroup version" or "abort: |
|
59 | first, and causes a "ValueError: no common changegroup version" or "abort: | |
40 | HTTP Error 500: Internal Server Error", if the extension is only loaded on one |
|
60 | HTTP Error 500: Internal Server Error", if the extension is only loaded on one | |
@@ -42,6 +62,8 b' side. If that *is* enabled, the subsequ' | |||||
42 | for flag '0x2000'!" if the extension is only loaded on one side (possibly also |
|
62 | for flag '0x2000'!" if the extension is only loaded on one side (possibly also | |
43 | masked by the Internal Server Error message). |
|
63 | masked by the Internal Server Error message). | |
44 | $ cat >> $HGRCPATH <<EOF |
|
64 | $ cat >> $HGRCPATH <<EOF | |
|
65 | > [extensions] | |||
|
66 | > debugprocessors = $TESTTMP/debugprocessors.py | |||
45 | > [experimental] |
|
67 | > [experimental] | |
46 | > lfs.disableusercache = True |
|
68 | > lfs.disableusercache = True | |
47 | > [lfs] |
|
69 | > [lfs] | |
@@ -51,6 +73,8 b' masked by the Internal Server Error mess' | |||||
51 | > push_ssl=False |
|
73 | > push_ssl=False | |
52 | > EOF |
|
74 | > EOF | |
53 |
|
75 | |||
|
76 | $ cp $HGRCPATH $HGRCPATH.orig | |||
|
77 | ||||
54 | #if lfsremote-on |
|
78 | #if lfsremote-on | |
55 | $ hg --config extensions.lfs= -R server \ |
|
79 | $ hg --config extensions.lfs= -R server \ | |
56 | > serve -p $HGPORT -d --pid-file=hg.pid --errorlog=$TESTTMP/errors.log |
|
80 | > serve -p $HGPORT -d --pid-file=hg.pid --errorlog=$TESTTMP/errors.log | |
@@ -307,6 +331,103 b' lfs content, and the extension enabled.' | |||||
307 | $ hg identify http://localhost:$HGPORT |
|
331 | $ hg identify http://localhost:$HGPORT | |
308 | c729025cc5e3 |
|
332 | c729025cc5e3 | |
309 |
|
333 | |||
|
334 | $ mv $HGRCPATH $HGRCPATH.tmp | |||
|
335 | $ cp $HGRCPATH.orig $HGRCPATH | |||
|
336 | ||||
|
337 | >>> from __future__ import absolute_import | |||
|
338 | >>> from hgclient import check, readchannel, runcommand | |||
|
339 | >>> @check | |||
|
340 | ... def checkflags(server): | |||
|
341 | ... readchannel(server) | |||
|
342 | ... print('') | |||
|
343 | ... print('# LFS required- both lfs and non-lfs revlogs have 0x2000 flag') | |||
|
344 | ... runcommand(server, ['debugprocessors', 'lfs.bin', '-R', | |||
|
345 | ... '../server']) | |||
|
346 | ... runcommand(server, ['debugprocessors', 'nonlfs2.txt', '-R', | |||
|
347 | ... '../server']) | |||
|
348 | ... runcommand(server, ['config', 'extensions', '--cwd', | |||
|
349 | ... '../server']) | |||
|
350 | ... | |||
|
351 | ... print("\n# LFS not enabled- revlogs don't have 0x2000 flag") | |||
|
352 | ... runcommand(server, ['debugprocessors', 'nonlfs3.txt']) | |||
|
353 | ... runcommand(server, ['config', 'extensions']) | |||
|
354 | ||||
|
355 | # LFS required- both lfs and non-lfs revlogs have 0x2000 flag | |||
|
356 | *** runcommand debugprocessors lfs.bin -R ../server | |||
|
357 | registered processor '0x8000' | |||
|
358 | registered processor '0x2000' | |||
|
359 | *** runcommand debugprocessors nonlfs2.txt -R ../server | |||
|
360 | registered processor '0x8000' | |||
|
361 | registered processor '0x2000' | |||
|
362 | *** runcommand config extensions --cwd ../server | |||
|
363 | extensions.debugprocessors=$TESTTMP/debugprocessors.py | |||
|
364 | extensions.lfs= | |||
|
365 | ||||
|
366 | # LFS not enabled- revlogs don't have 0x2000 flag | |||
|
367 | *** runcommand debugprocessors nonlfs3.txt | |||
|
368 | registered processor '0x8000' | |||
|
369 | *** runcommand config extensions | |||
|
370 | extensions.debugprocessors=$TESTTMP/debugprocessors.py | |||
|
371 | ||||
|
372 | $ rm $HGRCPATH | |||
|
373 | $ mv $HGRCPATH.tmp $HGRCPATH | |||
|
374 | ||||
|
375 | $ hg clone $TESTTMP/client $TESTTMP/nonlfs -qr 0 --config extensions.lfs= | |||
|
376 | $ cat >> $TESTTMP/nonlfs/.hg/hgrc <<EOF | |||
|
377 | > [extensions] | |||
|
378 | > lfs = ! | |||
|
379 | > EOF | |||
|
380 | ||||
|
381 | >>> from __future__ import absolute_import, print_function | |||
|
382 | >>> from hgclient import check, readchannel, runcommand | |||
|
383 | >>> @check | |||
|
384 | ... def checkflags2(server): | |||
|
385 | ... readchannel(server) | |||
|
386 | ... print('') | |||
|
387 | ... print('# LFS enabled- both lfs and non-lfs revlogs have 0x2000 flag') | |||
|
388 | ... runcommand(server, ['debugprocessors', 'lfs.bin', '-R', | |||
|
389 | ... '../server']) | |||
|
390 | ... runcommand(server, ['debugprocessors', 'nonlfs2.txt', '-R', | |||
|
391 | ... '../server']) | |||
|
392 | ... runcommand(server, ['config', 'extensions', '--cwd', | |||
|
393 | ... '../server']) | |||
|
394 | ... | |||
|
395 | ... print('\n# LFS enabled without requirement- revlogs have 0x2000 flag') | |||
|
396 | ... runcommand(server, ['debugprocessors', 'nonlfs3.txt']) | |||
|
397 | ... runcommand(server, ['config', 'extensions']) | |||
|
398 | ... | |||
|
399 | ... print("\n# LFS disabled locally- revlogs don't have 0x2000 flag") | |||
|
400 | ... runcommand(server, ['debugprocessors', 'nonlfs.txt', '-R', | |||
|
401 | ... '../nonlfs']) | |||
|
402 | ... runcommand(server, ['config', 'extensions', '--cwd', | |||
|
403 | ... '../nonlfs']) | |||
|
404 | ||||
|
405 | # LFS enabled- both lfs and non-lfs revlogs have 0x2000 flag | |||
|
406 | *** runcommand debugprocessors lfs.bin -R ../server | |||
|
407 | registered processor '0x8000' | |||
|
408 | registered processor '0x2000' | |||
|
409 | *** runcommand debugprocessors nonlfs2.txt -R ../server | |||
|
410 | registered processor '0x8000' | |||
|
411 | registered processor '0x2000' | |||
|
412 | *** runcommand config extensions --cwd ../server | |||
|
413 | extensions.debugprocessors=$TESTTMP/debugprocessors.py | |||
|
414 | extensions.lfs= | |||
|
415 | ||||
|
416 | # LFS enabled without requirement- revlogs have 0x2000 flag | |||
|
417 | *** runcommand debugprocessors nonlfs3.txt | |||
|
418 | registered processor '0x8000' | |||
|
419 | registered processor '0x2000' | |||
|
420 | *** runcommand config extensions | |||
|
421 | extensions.debugprocessors=$TESTTMP/debugprocessors.py | |||
|
422 | extensions.lfs= | |||
|
423 | ||||
|
424 | # LFS disabled locally- revlogs don't have 0x2000 flag | |||
|
425 | *** runcommand debugprocessors nonlfs.txt -R ../nonlfs | |||
|
426 | registered processor '0x8000' | |||
|
427 | *** runcommand config extensions --cwd ../nonlfs | |||
|
428 | extensions.debugprocessors=$TESTTMP/debugprocessors.py | |||
|
429 | extensions.lfs=! | |||
|
430 | ||||
310 | -------------------------------------------------------------------------------- |
|
431 | -------------------------------------------------------------------------------- | |
311 | Case #6: client with lfs content and the extension enabled; server with |
|
432 | Case #6: client with lfs content and the extension enabled; server with | |
312 | lfs content, and the extension enabled. |
|
433 | lfs content, and the extension enabled. |
General Comments 0
You need to be logged in to leave comments.
Login now