Show More
@@ -2353,11 +2353,19 def remove(ui, repo, m, prefix, uipathfn | |||
|
2353 | 2353 | |
|
2354 | 2354 | return ret |
|
2355 | 2355 | |
|
2356 | def _catfmtneedsdata(fm): | |
|
2357 | return not fm.datahint() or 'data' in fm.datahint() | |
|
2358 | ||
|
2356 | 2359 | def _updatecatformatter(fm, ctx, matcher, path, decode): |
|
2357 | 2360 | """Hook for adding data to the formatter used by ``hg cat``. |
|
2358 | 2361 | |
|
2359 | 2362 | Extensions (e.g., lfs) can wrap this to inject keywords/data, but must call |
|
2360 | 2363 | this method first.""" |
|
2364 | ||
|
2365 | # data() can be expensive to fetch (e.g. lfs), so don't fetch it if it | |
|
2366 | # wasn't requested. | |
|
2367 | data = b'' | |
|
2368 | if _catfmtneedsdata(fm): | |
|
2361 | 2369 | data = ctx[path].data() |
|
2362 | 2370 | if decode: |
|
2363 | 2371 | data = ctx.repo().wwritedata(path, data) |
@@ -2391,12 +2399,14 def cat(ui, repo, ctx, matcher, basefm, | |||
|
2391 | 2399 | mfnode = ctx.manifestnode() |
|
2392 | 2400 | try: |
|
2393 | 2401 | if mfnode and mfl[mfnode].find(file)[0]: |
|
2402 | if _catfmtneedsdata(basefm): | |
|
2394 | 2403 | scmutil.prefetchfiles(repo, [ctx.rev()], matcher) |
|
2395 | 2404 | write(file) |
|
2396 | 2405 | return 0 |
|
2397 | 2406 | except KeyError: |
|
2398 | 2407 | pass |
|
2399 | 2408 | |
|
2409 | if _catfmtneedsdata(basefm): | |
|
2400 | 2410 | scmutil.prefetchfiles(repo, [ctx.rev()], matcher) |
|
2401 | 2411 | |
|
2402 | 2412 | for abs in ctx.walk(matcher): |
@@ -537,8 +537,55 Misc: process dies early if a requiremen | |||
|
537 | 537 | |
|
538 | 538 | $ hg clone -qU http://localhost:$HGPORT $TESTTMP/bulkfetch |
|
539 | 539 | |
|
540 | Cat doesn't prefetch unless data is needed (e.g. '-T {rawdata}' doesn't need it) | |
|
541 | ||
|
542 | $ hg --cwd $TESTTMP/bulkfetch cat -vr tip lfspair1.bin -T '{rawdata}\n{path}\n' | |
|
543 | lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs | |
|
544 | version https://git-lfs.github.com/spec/v1 | |
|
545 | oid sha256:cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782 | |
|
546 | size 20 | |
|
547 | x-is-binary 0 | |
|
548 | ||
|
549 | lfspair1.bin | |
|
550 | ||
|
551 | $ hg --cwd $TESTTMP/bulkfetch cat -vr tip lfspair1.bin -T json | |
|
552 | lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs | |
|
553 | [lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs | |
|
554 | lfs: downloading cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782 (20 bytes) | |
|
555 | lfs: processed: cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782 | |
|
556 | lfs: downloaded 1 files (20 bytes) | |
|
557 | lfs: found cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782 in the local lfs store | |
|
558 | ||
|
559 | { | |
|
560 | "data": "this is an lfs file\n", | |
|
561 | "path": "lfspair1.bin", | |
|
562 | "rawdata": "version https://git-lfs.github.com/spec/v1\noid sha256:cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782\nsize 20\nx-is-binary 0\n" | |
|
563 | } | |
|
564 | ] | |
|
565 | ||
|
566 | $ rm -r $TESTTMP/bulkfetch/.hg/store/lfs | |
|
567 | ||
|
568 | $ hg --cwd $TESTTMP/bulkfetch cat -vr tip lfspair1.bin -T '{data}\n' | |
|
569 | lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs | |
|
570 | lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs | |
|
571 | lfs: downloading cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782 (20 bytes) | |
|
572 | lfs: processed: cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782 | |
|
573 | lfs: downloaded 1 files (20 bytes) | |
|
574 | lfs: found cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782 in the local lfs store | |
|
575 | this is an lfs file | |
|
576 | ||
|
577 | $ hg --cwd $TESTTMP/bulkfetch cat -vr tip lfspair2.bin | |
|
578 | lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs | |
|
579 | lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs | |
|
580 | lfs: downloading d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e (24 bytes) | |
|
581 | lfs: processed: d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e | |
|
582 | lfs: downloaded 1 files (24 bytes) | |
|
583 | lfs: found d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e in the local lfs store | |
|
584 | this is an lfs file too | |
|
585 | ||
|
540 | 586 | Export will prefetch all needed files across all needed revisions |
|
541 | 587 | |
|
588 | $ rm -r $TESTTMP/bulkfetch/.hg/store/lfs | |
|
542 | 589 | $ hg -R $TESTTMP/bulkfetch -v export -r 0:tip -o all.export |
|
543 | 590 | lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs |
|
544 | 591 | exporting patches: |
General Comments 0
You need to be logged in to leave comments.
Login now