Show More
@@ -328,6 +328,8 b' def _widen(ui, repo, remote, commoninc, ' | |||||
328 | @command('tracked', |
|
328 | @command('tracked', | |
329 | [('', 'addinclude', [], _('new paths to include')), |
|
329 | [('', 'addinclude', [], _('new paths to include')), | |
330 | ('', 'removeinclude', [], _('old paths to no longer include')), |
|
330 | ('', 'removeinclude', [], _('old paths to no longer include')), | |
|
331 | ('', 'auto-remove-includes', False, | |||
|
332 | _('automatically choose unused includes to remove')), | |||
331 | ('', 'addexclude', [], _('new paths to exclude')), |
|
333 | ('', 'addexclude', [], _('new paths to exclude')), | |
332 | ('', 'import-rules', '', _('import narrowspecs from a file')), |
|
334 | ('', 'import-rules', '', _('import narrowspecs from a file')), | |
333 | ('', 'removeexclude', [], _('old paths to no longer exclude')), |
|
335 | ('', 'removeexclude', [], _('old paths to no longer exclude')), | |
@@ -363,6 +365,11 b' def trackedcmd(ui, repo, remotepath=None' | |||||
363 | If --clear is specified without any further options, the narrowspec will be |
|
365 | If --clear is specified without any further options, the narrowspec will be | |
364 | empty and will not match any files. |
|
366 | empty and will not match any files. | |
365 |
|
367 | |||
|
368 | If --auto-remove-includes is specified, then those includes that don't match | |||
|
369 | any files modified by currently visible local commits (those not shared by | |||
|
370 | the remote) will be added to the set of explicitly specified includes to | |||
|
371 | remove. | |||
|
372 | ||||
366 | --import-rules accepts a path to a file containing rules, allowing you to |
|
373 | --import-rules accepts a path to a file containing rules, allowing you to | |
367 | add --addinclude, --addexclude rules in bulk. Like the other include and |
|
374 | add --addinclude, --addexclude rules in bulk. Like the other include and | |
368 | exclude switches, the changes are applied immediately. |
|
375 | exclude switches, the changes are applied immediately. | |
@@ -398,10 +405,12 b' def trackedcmd(ui, repo, remotepath=None' | |||||
398 | removedincludes = narrowspec.parsepatterns(opts['removeinclude']) |
|
405 | removedincludes = narrowspec.parsepatterns(opts['removeinclude']) | |
399 | addedexcludes = narrowspec.parsepatterns(opts['addexclude']) |
|
406 | addedexcludes = narrowspec.parsepatterns(opts['addexclude']) | |
400 | removedexcludes = narrowspec.parsepatterns(opts['removeexclude']) |
|
407 | removedexcludes = narrowspec.parsepatterns(opts['removeexclude']) | |
|
408 | autoremoveincludes = opts['auto_remove_includes'] | |||
401 |
|
409 | |||
402 | update_working_copy = opts['update_working_copy'] |
|
410 | update_working_copy = opts['update_working_copy'] | |
403 | only_show = not (addedincludes or removedincludes or addedexcludes or |
|
411 | only_show = not (addedincludes or removedincludes or addedexcludes or | |
404 |
removedexcludes or newrules or |
|
412 | removedexcludes or newrules or autoremoveincludes or | |
|
413 | update_working_copy) | |||
405 |
|
414 | |||
406 | oldincludes, oldexcludes = repo.narrowpats |
|
415 | oldincludes, oldexcludes = repo.narrowpats | |
407 |
|
416 | |||
@@ -436,7 +445,7 b' def trackedcmd(ui, repo, remotepath=None' | |||||
436 | narrowspec.copytoworkingcopy(repo) |
|
445 | narrowspec.copytoworkingcopy(repo) | |
437 | return 0 |
|
446 | return 0 | |
438 |
|
447 | |||
439 |
if not widening |
|
448 | if not (widening or narrowing or autoremoveincludes): | |
440 | ui.status(_("nothing to widen or narrow\n")) |
|
449 | ui.status(_("nothing to widen or narrow\n")) | |
441 | return 0 |
|
450 | return 0 | |
442 |
|
451 | |||
@@ -459,6 +468,28 b' def trackedcmd(ui, repo, remotepath=None' | |||||
459 |
|
468 | |||
460 | commoninc = discovery.findcommonincoming(repo, remote) |
|
469 | commoninc = discovery.findcommonincoming(repo, remote) | |
461 |
|
470 | |||
|
471 | if autoremoveincludes: | |||
|
472 | outgoing = discovery.findcommonoutgoing(repo, remote, | |||
|
473 | commoninc=commoninc) | |||
|
474 | ui.status(_('looking for unused includes to remove\n')) | |||
|
475 | localfiles = set() | |||
|
476 | for n in itertools.chain(outgoing.missing, outgoing.excluded): | |||
|
477 | localfiles.update(repo[n].files()) | |||
|
478 | suggestedremovals = [] | |||
|
479 | for include in sorted(oldincludes): | |||
|
480 | match = narrowspec.match(repo.root, [include], oldexcludes) | |||
|
481 | if not any(match(f) for f in localfiles): | |||
|
482 | suggestedremovals.append(include) | |||
|
483 | if suggestedremovals: | |||
|
484 | for s in suggestedremovals: | |||
|
485 | ui.status('%s\n' % s) | |||
|
486 | if (ui.promptchoice(_('remove these unused includes (yn)?' | |||
|
487 | '$$ &Yes $$ &No')) == 0): | |||
|
488 | removedincludes.update(suggestedremovals) | |||
|
489 | narrowing = True | |||
|
490 | else: | |||
|
491 | ui.status(_('found no unused includes\n')) | |||
|
492 | ||||
462 | if narrowing: |
|
493 | if narrowing: | |
463 | newincludes = oldincludes - removedincludes |
|
494 | newincludes = oldincludes - removedincludes | |
464 | newexcludes = oldexcludes | addedexcludes |
|
495 | newexcludes = oldexcludes | addedexcludes |
@@ -101,6 +101,8 b' Testing the --import-rules flag of `hg t' | |||||
101 |
|
101 | |||
102 | --addinclude VALUE [+] new paths to include |
|
102 | --addinclude VALUE [+] new paths to include | |
103 | --removeinclude VALUE [+] old paths to no longer include |
|
103 | --removeinclude VALUE [+] old paths to no longer include | |
|
104 | --auto-remove-includes automatically choose unused includes to | |||
|
105 | remove | |||
104 | --addexclude VALUE [+] new paths to exclude |
|
106 | --addexclude VALUE [+] new paths to exclude | |
105 | --import-rules VALUE import narrowspecs from a file |
|
107 | --import-rules VALUE import narrowspecs from a file | |
106 | --removeexclude VALUE [+] old paths to no longer exclude |
|
108 | --removeexclude VALUE [+] old paths to no longer exclude |
@@ -447,3 +447,48 b' Now test it *with* verbose.' | |||||
447 | abort: local changes found |
|
447 | abort: local changes found | |
448 | (use --force-delete-local-changes to ignore) |
|
448 | (use --force-delete-local-changes to ignore) | |
449 | [255] |
|
449 | [255] | |
|
450 | $ cd .. | |||
|
451 | ||||
|
452 | Test --auto-remove-includes | |||
|
453 | $ hg clone --narrow ssh://user@dummy/master narrow-auto-remove -q \ | |||
|
454 | > --include d0 --include d1 --include d2 | |||
|
455 | $ cd narrow-auto-remove | |||
|
456 | $ echo a >> d0/f | |||
|
457 | $ hg ci -m 'local change to d0' | |||
|
458 | $ hg co '.^' | |||
|
459 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
460 | $ echo a >> d1/f | |||
|
461 | $ hg ci -m 'local change to d1' | |||
|
462 | created new head | |||
|
463 | $ hg debugobsolete $(hg log -T '{node}' -r 'desc("local change to d0")') | |||
|
464 | 1 new obsolescence markers | |||
|
465 | obsoleted 1 changesets | |||
|
466 | $ echo n | hg tracked --auto-remove-includes --config ui.interactive=yes | |||
|
467 | comparing with ssh://user@dummy/master | |||
|
468 | searching for changes | |||
|
469 | looking for unused includes to remove | |||
|
470 | path:d0 | |||
|
471 | path:d2 | |||
|
472 | remove these unused includes (yn)? n | |||
|
473 | $ hg tracked --auto-remove-includes | |||
|
474 | comparing with ssh://user@dummy/master | |||
|
475 | searching for changes | |||
|
476 | looking for unused includes to remove | |||
|
477 | path:d0 | |||
|
478 | path:d2 | |||
|
479 | remove these unused includes (yn)? y | |||
|
480 | looking for local changes to affected paths | |||
|
481 | saved backup bundle to $TESTTMP/narrow-auto-remove/.hg/strip-backup/*-narrow.hg (glob) | |||
|
482 | deleting data/d0/f.i | |||
|
483 | deleting data/d2/f.i | |||
|
484 | deleting meta/d0/00manifest.i (tree !) | |||
|
485 | deleting meta/d2/00manifest.i (tree !) | |||
|
486 | $ hg tracked | |||
|
487 | I path:d1 | |||
|
488 | $ hg files | |||
|
489 | d1/f | |||
|
490 | $ hg tracked --auto-remove-includes | |||
|
491 | comparing with ssh://user@dummy/master | |||
|
492 | searching for changes | |||
|
493 | looking for unused includes to remove | |||
|
494 | found no unused includes |
General Comments 0
You need to be logged in to leave comments.
Login now