Show More
@@ -374,7 +374,8 b' def debugsparse(ui, repo, *pats, **opts)' | |||||
374 | len, |
|
374 | len, | |
375 | sparse.refreshwdir(repo, repo.status(), sparse.matcher(repo), |
|
375 | sparse.refreshwdir(repo, repo.status(), sparse.matcher(repo), | |
376 | force=force)) |
|
376 | force=force)) | |
377 | _verbose_output(ui, opts, 0, 0, 0, *fcounts) |
|
377 | sparse.printchanges(ui, opts, added=fcounts[0], dropped=fcounts[1], | |
|
378 | conflicting=fcounts[2]) | |||
378 | finally: |
|
379 | finally: | |
379 | wlock.release() |
|
380 | wlock.release() | |
380 |
|
381 | |||
@@ -437,8 +438,8 b' def _config(ui, repo, pats, opts, includ' | |||||
437 | len(oldinclude - newinclude)) |
|
438 | len(oldinclude - newinclude)) | |
438 | excludecount = (len(newexclude - oldexclude) - |
|
439 | excludecount = (len(newexclude - oldexclude) - | |
439 | len(oldexclude - newexclude)) |
|
440 | len(oldexclude - newexclude)) | |
440 | _verbose_output( |
|
441 | sparse.printchanges(ui, opts, profilecount, includecount, | |
441 |
|
|
442 | excludecount, *fcounts) | |
442 | except Exception: |
|
443 | except Exception: | |
443 | sparse.writeconfig(repo, oldinclude, oldexclude, oldprofiles) |
|
444 | sparse.writeconfig(repo, oldinclude, oldexclude, oldprofiles) | |
444 | raise |
|
445 | raise | |
@@ -500,32 +501,5 b' def _import(ui, repo, files, opts, force' | |||||
500 | sparse.writeconfig(repo, oincludes, oexcludes, oprofiles) |
|
501 | sparse.writeconfig(repo, oincludes, oexcludes, oprofiles) | |
501 | raise |
|
502 | raise | |
502 |
|
503 | |||
503 |
|
|
504 | sparse.printchanges(ui, opts, profilecount, includecount, excludecount, | |
504 | *fcounts) |
|
505 | *fcounts) | |
505 |
|
||||
506 | def _verbose_output(ui, opts, profilecount, includecount, excludecount, added, |
|
|||
507 | dropped, lookup): |
|
|||
508 | """Produce --verbose and templatable output |
|
|||
509 |
|
||||
510 | This specifically enables -Tjson, providing machine-readable stats on how |
|
|||
511 | the sparse profile changed. |
|
|||
512 |
|
||||
513 | """ |
|
|||
514 | with ui.formatter('sparse', opts) as fm: |
|
|||
515 | fm.startitem() |
|
|||
516 | fm.condwrite(ui.verbose, 'profiles_added', 'Profile # change: %d\n', |
|
|||
517 | profilecount) |
|
|||
518 | fm.condwrite(ui.verbose, 'include_rules_added', |
|
|||
519 | 'Include rule # change: %d\n', includecount) |
|
|||
520 | fm.condwrite(ui.verbose, 'exclude_rules_added', |
|
|||
521 | 'Exclude rule # change: %d\n', excludecount) |
|
|||
522 | # In 'plain' verbose mode, mergemod.applyupdates already outputs what |
|
|||
523 | # files are added or removed outside of the templating formatter |
|
|||
524 | # framework. No point in repeating ourselves in that case. |
|
|||
525 | if not fm.isplain(): |
|
|||
526 | fm.condwrite(ui.verbose, 'files_added', 'Files added: %d\n', |
|
|||
527 | added) |
|
|||
528 | fm.condwrite(ui.verbose, 'files_dropped', 'Files dropped: %d\n', |
|
|||
529 | dropped) |
|
|||
530 | fm.condwrite(ui.verbose, 'files_conflicting', |
|
|||
531 | 'Files conflicting: %d\n', lookup) |
|
@@ -512,3 +512,26 b' def clearrules(repo, force=False):' | |||||
512 | oldmatch = matcher(repo) |
|
512 | oldmatch = matcher(repo) | |
513 | writeconfig(repo, set(), set(), profiles) |
|
513 | writeconfig(repo, set(), set(), profiles) | |
514 | refreshwdir(repo, oldstatus, oldmatch, force=force) |
|
514 | refreshwdir(repo, oldstatus, oldmatch, force=force) | |
|
515 | ||||
|
516 | def printchanges(ui, opts, profilecount=0, includecount=0, excludecount=0, | |||
|
517 | added=0, dropped=0, conflicting=0): | |||
|
518 | """Print output summarizing sparse config changes.""" | |||
|
519 | with ui.formatter('sparse', opts) as fm: | |||
|
520 | fm.startitem() | |||
|
521 | fm.condwrite(ui.verbose, 'profiles_added', _('Profiles changed: %d\n'), | |||
|
522 | profilecount) | |||
|
523 | fm.condwrite(ui.verbose, 'include_rules_added', | |||
|
524 | _('Include rules changed: %d\n'), includecount) | |||
|
525 | fm.condwrite(ui.verbose, 'exclude_rules_added', | |||
|
526 | _('Exclude rules changed: %d\n'), excludecount) | |||
|
527 | ||||
|
528 | # In 'plain' verbose mode, mergemod.applyupdates already outputs what | |||
|
529 | # files are added or removed outside of the templating formatter | |||
|
530 | # framework. No point in repeating ourselves in that case. | |||
|
531 | if not fm.isplain(): | |||
|
532 | fm.condwrite(ui.verbose, 'files_added', _('Files added: %d\n'), | |||
|
533 | added) | |||
|
534 | fm.condwrite(ui.verbose, 'files_dropped', _('Files dropped: %d\n'), | |||
|
535 | dropped) | |||
|
536 | fm.condwrite(ui.verbose, 'files_conflicting', | |||
|
537 | _('Files conflicting: %d\n'), conflicting) |
@@ -35,9 +35,9 b' Verify basic --include and --reset' | |||||
35 | $ hg debugsparse --clear-rules |
|
35 | $ hg debugsparse --clear-rules | |
36 | $ hg debugsparse --include 'hide' --verbose |
|
36 | $ hg debugsparse --include 'hide' --verbose | |
37 | removing show |
|
37 | removing show | |
38 |
Profile |
|
38 | Profiles changed: 0 | |
39 |
Include rule |
|
39 | Include rules changed: 1 | |
40 |
Exclude rule |
|
40 | Exclude rules changed: 0 | |
41 |
|
41 | |||
42 | $ hg debugsparse --reset -Tjson |
|
42 | $ hg debugsparse --reset -Tjson | |
43 | [ |
|
43 | [ | |
@@ -53,9 +53,9 b' Verify basic --include and --reset' | |||||
53 | $ hg debugsparse --include 'hide' |
|
53 | $ hg debugsparse --include 'hide' | |
54 | $ hg debugsparse --reset --verbose |
|
54 | $ hg debugsparse --reset --verbose | |
55 | getting show |
|
55 | getting show | |
56 |
Profile |
|
56 | Profiles changed: 0 | |
57 |
Include rule |
|
57 | Include rules changed: -1 | |
58 |
Exclude rule |
|
58 | Exclude rules changed: 0 | |
59 |
|
59 | |||
60 | Verifying that problematic files still allow us to see the deltas when forcing: |
|
60 | Verifying that problematic files still allow us to see the deltas when forcing: | |
61 |
|
61 | |||
@@ -77,6 +77,6 b' Verifying that problematic files still a' | |||||
77 | pending changes to 'hide' |
|
77 | pending changes to 'hide' | |
78 | $ hg debugsparse --delete 'show*' --force --verbose |
|
78 | $ hg debugsparse --delete 'show*' --force --verbose | |
79 | pending changes to 'hide' |
|
79 | pending changes to 'hide' | |
80 |
Profile |
|
80 | Profiles changed: 0 | |
81 |
Include rule |
|
81 | Include rules changed: -1 | |
82 |
Exclude rule |
|
82 | Exclude rules changed: 0 |
General Comments 0
You need to be logged in to leave comments.
Login now