[PATCH 04 of 10] repair: identify repository deficiencies

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Nov 23 11:00:26 EST 2016



On 11/22/2016 07:02 AM, Gregory Szorc wrote:
> On Mon, Nov 21, 2016 at 6:14 PM, Pierre-Yves David
> <pierre-yves.david at ens-lyon.org <mailto:pierre-yves.david at ens-lyon.org>>
> wrote:
>
>     On 11/06/2016 05:40 AM, Gregory Szorc wrote:
>
>         # HG changeset patch
>         # User Gregory Szorc <gregory.szorc at gmail.com
>         <mailto:gregory.szorc at gmail.com>>
>         # Date 1478382332 25200
>         #      Sat Nov 05 14:45:32 2016 -0700
>         # Node ID 7518e68e2f8276e85fb68174b3055a9dd16c665d
>         # Parent  9daec9c7adabe8c84cf2c01fc938e010ee4884d6
>         repair: identify repository deficiencies
>
>         A command that upgrades repositories but doesn't say what it is
>         doing
>         or why it is doing it is less helpful than a command that does. So,
>         we start the implementation of repository upgrades by introducing
>         detection of sub-optimal repository state. Deficiencies with the
>         existing repository are now printed at the beginning of command
>         execution.
>
>         The added function returns a set of planned upgrade actions. This
>         variable will be used by subsequent patches.
>
>         diff --git a/mercurial/commands.py b/mercurial/commands.py
>         --- a/mercurial/commands.py
>         +++ b/mercurial/commands.py
>         @@ -3756,7 +3756,7 @@ def debugupgraderepo(ui, repo, **opts):
>
>              At times during the upgrade, the repository may not be
>         readable.
>              """
>         -    raise error.Abort(_('not yet implemented'))
>         +    return repair.upgraderepo(ui, repo, dryrun=opts.get('dry_run'))
>
>          @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'),
>         inferrepo=True)
>          def debugwalk(ui, repo, *pats, **opts):
>         diff --git a/mercurial/repair.py b/mercurial/repair.py
>         --- a/mercurial/repair.py
>         +++ b/mercurial/repair.py
>         @@ -360,3 +360,57 @@ def deleteobsmarkers(obsstore, indices):
>                  newobsstorefile.write(bytes)
>              newobsstorefile.close()
>              return n
>         +
>         +def upgradefinddeficiencies(repo):
>         +    """Obtain deficiencies with the existing repo and planned
>         actions to fix.
>         +
>         +    Returns a list of strings that will be printed to the user
>         and a set
>         +    of machine-readable actions that will be acted on later.
>         +    """
>         +    l = []
>         +    actions = set()
>         +
>         +    # We could detect lack of revlogv1 and store here, but they
>         were added
>         +    # in 0.9.2 and we don't support upgrading repos without these
>         +    # requirements, so let's not bother.
>         +
>         +    if 'fncache' not in repo.requirements:
>         +        l.append(_('not using fncache; long and reserved
>         filenames '
>         +                   'may not work correctly'))
>
>
>
>     notes: I like the idea of explaining the benefit of each upgrade.
>
>         +        actions.add('fncache')
>         +
>         +    if 'dotencode' not in repo.requirements:
>         +        l.append(_('not using dotencode; filenames beginning with '
>         +                   'a period or space may not work correctly'))
>         +        actions.add('dotencode')
>         +
>         +    if 'generaldelta' not in repo.requirements:
>         +        l.append(_('not using generaldelta storage; repository
>         is larger '
>         +                   'and slower than it could be, pulling from '
>         +                   'generaldelta repositories will be slow'))
>         +        actions.add('generaldelta')
>         +
>         +    cl = repo.changelog
>         +    for rev in cl:
>         +        chainbase = cl.chainbase(rev)
>         +        if chainbase != rev:
>         +            l.append(_('changelog using delta chains; changelog
>         reading '
>         +                       'is slower than it could be'))
>         +            actions.add('removecldeltachain')
>         +            break
>         +
>         +    return l, actions
>
>
>     At some point we probably needs this to be extensible for extension
>     to be able to extend the list of format variant detection. But this
>     can come later.
>
>
> I kinda bent over backwards in this series to isolate each step to its
> own function explicitly so extensions could inject code at the
> appropriate point. I'm not too worried about this not being extensible :)

My experience is that extensions writter always end up having baroque 
needs like inserting themself between two steps or collaborating with 
others wrapper. This led to the current paranoid setup seen in 
exchange.py. This is probably less critical for format upgrade as less 
people will touch it but I would encourage you to consider it anyway.

>     This version if performing unconditional upgrade of all features.
>     Will be quite unhandy in some case (eg: cohabitation with older
>     versions, experimental format, etc). The approach have been using on
>     my side was to use three points of data for each variants:
>
>      * current format, default format, configured format.
>
>     Then, 'hg debugformat' would highlight case were 'current' ≠
>     'config' and 'config' ≠ 'default'. A `hg debugformat --upgrade`
>     would always move a variant from 'current' to 'config'.
>
>
> I *really* like being able to distinguish between these states. I'll try
> to find a way to work this into v2.

(I'm happy that you like it :-))

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list