[PATCH 04 of 10] repair: identify repository deficiencies
Augie Fackler
raf at durin42.com
Mon Nov 21 20:45:21 UTC 2016
On Sat, Nov 05, 2016 at 09:40:20PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <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
Mostly happy so far, some string bikeshedding below. Tried to elide
irrelevant bits of the message so they'll be easy to spot.
>
> 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
[...]
> +
> + 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'))
Perhaps word as "pulling from modern servers may be slow" - I'm not
sure that "generaldelta repositories" is really a helpful string to
print to normal humans.
> + 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'))
"changelog is storing deltas; changelog reading is slower than it could be"
(chains are irrelevant here, what matters is that we're trying to
store deltas at all)
> + actions.add('removecldeltachain')
> + break
> +
> + return l, actions
> +
> +def upgraderepo(ui, repo, dryrun=False):
> + """Upgrade a repository in place."""
> + repo = repo.unfiltered()
> + deficiencies, actions = upgradefinddeficiencies(repo)
> +
> + if deficiencies:
> + ui.write(_('the following deficiencies with the existing repository '
> + 'have been identified:\n\n'))
> +
> + for d in deficiencies:
> + ui.write('* %s\n' % d)
> + else:
> + ui.write(_('no obvious deficiencies found in existing repository\n'))
[...]
More information about the Mercurial-devel
mailing list