Skip to content
Snippets Groups Projects
Commit e4722357 authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

upgrade: introduce a 'formatvariant' class

The 'deficiency' type has multiple specificities. We create a dedicated class to
host them. More logic will be added incrementally in future changesets.
parent 9e35848f
No related branches found
No related tags found
No related merge requests found
...@@ -120,12 +120,4 @@ ...@@ -120,12 +120,4 @@
upgrademessage upgrademessage
Message intended for humans explaining what an upgrade addressing this Message intended for humans explaining what an upgrade addressing this
issue will do. Should be worded in the future tense. issue will do. Should be worded in the future tense.
fromdefault (``deficiency`` types only)
Boolean indicating whether the current (deficient) state deviates
from Mercurial's default configuration.
fromconfig (``deficiency`` types only)
Boolean indicating whether the current (deficient) state deviates
from the current Mercurial configuration.
""" """
...@@ -131,7 +123,7 @@ ...@@ -131,7 +123,7 @@
""" """
def __init__(self, name, type, description, upgrademessage, **kwargs): def __init__(self, name, type, description, upgrademessage):
self.name = name self.name = name
self.type = type self.type = type
self.description = description self.description = description
self.upgrademessage = upgrademessage self.upgrademessage = upgrademessage
...@@ -133,11 +125,8 @@ ...@@ -133,11 +125,8 @@
self.name = name self.name = name
self.type = type self.type = type
self.description = description self.description = description
self.upgrademessage = upgrademessage self.upgrademessage = upgrademessage
for k, v in kwargs.items():
setattr(self, k, v)
def __eq__(self, other): def __eq__(self, other):
if not isinstance(other, improvement): if not isinstance(other, improvement):
# This is what python tell use to do # This is what python tell use to do
...@@ -150,6 +139,27 @@ ...@@ -150,6 +139,27 @@
def __hash__(self): def __hash__(self):
return hash(self.name) return hash(self.name)
class formatvariant(improvement):
"""an improvement subclass dedicated to repository format
extra attributes:
fromdefault (``deficiency`` types only)
Boolean indicating whether the current (deficient) state deviates
from Mercurial's default configuration.
fromconfig (``deficiency`` types only)
Boolean indicating whether the current (deficient) state deviates
from the current Mercurial configuration.
"""
def __init__(self, name, description, upgrademessage, fromdefault,
fromconfig):
super(formatvariant, self).__init__(name, deficiency, description,
upgrademessage)
self.fromdefault = fromdefault
self.fromconfig = fromconfig
def finddeficiencies(repo): def finddeficiencies(repo):
"""returns a list of deficiencies that the repo suffer from""" """returns a list of deficiencies that the repo suffer from"""
newreporeqs = localrepo.newreporequirements(repo) newreporeqs = localrepo.newreporequirements(repo)
...@@ -161,5 +171,5 @@ ...@@ -161,5 +171,5 @@
# requirements, so let's not bother. # requirements, so let's not bother.
if 'fncache' not in repo.requirements: if 'fncache' not in repo.requirements:
deficiencies.append(improvement( deficiencies.append(formatvariant(
name='fncache', name='fncache',
...@@ -165,5 +175,4 @@ ...@@ -165,5 +175,4 @@
name='fncache', name='fncache',
type=deficiency,
description=_('long and reserved filenames may not work correctly; ' description=_('long and reserved filenames may not work correctly; '
'repository performance is sub-optimal'), 'repository performance is sub-optimal'),
upgrademessage=_('repository will be more resilient to storing ' upgrademessage=_('repository will be more resilient to storing '
...@@ -173,5 +182,5 @@ ...@@ -173,5 +182,5 @@
fromconfig='fncache' in newreporeqs)) fromconfig='fncache' in newreporeqs))
if 'dotencode' not in repo.requirements: if 'dotencode' not in repo.requirements:
deficiencies.append(improvement( deficiencies.append(formatvariant(
name='dotencode', name='dotencode',
...@@ -177,5 +186,4 @@ ...@@ -177,5 +186,4 @@
name='dotencode', name='dotencode',
type=deficiency,
description=_('storage of filenames beginning with a period or ' description=_('storage of filenames beginning with a period or '
'space may not work correctly'), 'space may not work correctly'),
upgrademessage=_('repository will be better able to store files ' upgrademessage=_('repository will be better able to store files '
...@@ -184,5 +192,5 @@ ...@@ -184,5 +192,5 @@
fromconfig='dotencode' in newreporeqs)) fromconfig='dotencode' in newreporeqs))
if 'generaldelta' not in repo.requirements: if 'generaldelta' not in repo.requirements:
deficiencies.append(improvement( deficiencies.append(formatvariant(
name='generaldelta', name='generaldelta',
...@@ -188,5 +196,4 @@ ...@@ -188,5 +196,4 @@
name='generaldelta', name='generaldelta',
type=deficiency,
description=_('deltas within internal storage are unable to ' description=_('deltas within internal storage are unable to '
'choose optimal revisions; repository is larger and ' 'choose optimal revisions; repository is larger and '
'slower than it could be; interaction with other ' 'slower than it could be; interaction with other '
...@@ -208,5 +215,5 @@ ...@@ -208,5 +215,5 @@
for rev in cl: for rev in cl:
chainbase = cl.chainbase(rev) chainbase = cl.chainbase(rev)
if chainbase != rev: if chainbase != rev:
deficiencies.append(improvement( deficiencies.append(formatvariant(
name='removecldeltachain', name='removecldeltachain',
...@@ -212,5 +219,4 @@ ...@@ -212,5 +219,4 @@
name='removecldeltachain', name='removecldeltachain',
type=deficiency,
description=_('changelog storage is using deltas instead of ' description=_('changelog storage is using deltas instead of '
'raw entries; changelog reading and any ' 'raw entries; changelog reading and any '
'operation relying on changelog data are slower ' 'operation relying on changelog data are slower '
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment