[PATCH 06 of 10] repair: print what upgrade will do

Augie Fackler raf at durin42.com
Mon Nov 21 15:55:26 EST 2016


On Sat, Nov 05, 2016 at 09:40:22PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1478393040 25200
> #      Sat Nov 05 17:44:00 2016 -0700
> # Node ID 82799afa72be5bb540b2b07cd878f307622c4354
> # Parent  b768004ef2db9c2e6dd267997e9e0c011f1b732a
> repair: print what upgrade will do
>
> The final part of pre-upgrade checks is validating what the upgrade
> will do and printing a summary of this to the user. This patch
> implements that.
>
> Again, multiple functions are used to facilitate monkeypatching by
> extensions.
>
> diff --git a/mercurial/repair.py b/mercurial/repair.py
> --- a/mercurial/repair.py
> +++ b/mercurial/repair.py
> @@ -480,6 +480,61 @@ def upgradereporequirements(repo):
>
>      return createreqs
>
> +def upgradevalidateactions(repo, sourcereqs, destreqs, actions):
> +    """Validate (and modify accordingly) the list of actions to perform.
> +
> +    Returns a set of actions that will be performed. The set is advisory
> +    only and is intended to drive presentation of what actions will be
> +    taken.
> +
> +    Extensions can monkeypatch this to mutate the set of actions that
> +    will be performed.
> +    """
> +    newactions = set(actions)
> +
> +    for req in ('dotencode', 'fncache', 'generaldelta'):
> +        if req in actions and req not in destreqs:
> +            newactions.remove(req)
> +
> +    return newactions
> +
> +def upgradesummarizeactions(repo, actions):
> +    """Summarize actions that will be taken as part of upgrade.
> +
> +    Receives a set of action names. Returns a list of strings that will be
> +    presented to user describing these actions and a set of actions processed
> +    by this function.
> +    """
> +    l = []
> +    handled = set()
> +
> +    if 'dotencode' in actions:
> +        l.append(_('dotencode repository layout will be used; the repository '
> +                   'will be able be more resilient to storing paths beginning '
> +                   'with periods or spaces'))
> +        handled.add('dotencode')
> +
> +    if 'fncache' in actions:
> +        l.append(_('fncache repository layout will be used; the repository '
> +                   'will be more resilient storing long paths and special '
> +                   'filenames'))
> +        handled.add('fncache')
> +
> +    if 'generaldelta' in actions:
> +        l.append(_('repository data will be re-encoded as "generaldelta"; '
> +                   'files inside the repository should be smaller, read times '
> +                   'should decrease, and interacting with other generaldelta '
> +                   'repositories should be faster'))

same nit here about "modern servers may be" instead of "generaldelta
repositories should be" as I had earlier in the series.


More information about the Mercurial-devel mailing list