Skip to content
Snippets Groups Projects
Commit fb6226c15e54 authored by Augie Fackler's avatar Augie Fackler
Browse files

lfs: stabilize error message values for Python 2 and 3

Differential Revision: https://phab.mercurial-scm.org/D3513
parent b8c2004a8d2b
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,9 @@
error,
pycompat,
)
from mercurial.utils import (
stringutil,
)
class InvalidPointer(error.RevlogError):
pass
......@@ -32,7 +35,9 @@
try:
return cls(l.split(' ', 1) for l in text.splitlines()).validate()
except ValueError: # l.split returns 1 item instead of 2
raise InvalidPointer(_('cannot parse git-lfs text: %r') % text)
raise InvalidPointer(
_('cannot parse git-lfs text: %s') % stringutil.pprint(
text, bprefix=False))
def serialize(self):
sortkeyfunc = lambda x: (x[0] != 'version', x)
......@@ -61,8 +66,9 @@
for k, v in self.iteritems():
if k in self._requiredre:
if not self._requiredre[k].match(v):
raise InvalidPointer(_('unexpected value: %s=%r') % (k, v))
raise InvalidPointer(_('unexpected value: %s=%s') % (
k, stringutil.pprint(v, bprefix=False)))
requiredcount += 1
elif not self._keyre.match(k):
raise InvalidPointer(_('unexpected key: %s') % k)
if not self._valuere.match(v):
......@@ -65,8 +71,9 @@
requiredcount += 1
elif not self._keyre.match(k):
raise InvalidPointer(_('unexpected key: %s') % k)
if not self._valuere.match(v):
raise InvalidPointer(_('unexpected value: %s=%r') % (k, v))
raise InvalidPointer(_('unexpected value: %s=%s') % (
k, stringutil.pprint(v, bprefix=False)))
if len(self._requiredre) != requiredcount:
miss = sorted(set(self._requiredre.keys()).difference(self.keys()))
raise InvalidPointer(_('missed keys: %s') % ', '.join(miss))
......
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