##// END OF EJS Templates
lfs: stabilize error message values for Python 2 and 3...
Augie Fackler -
r37945:fb6226c1 default
parent child Browse files
Show More
@@ -15,6 +15,9 from mercurial import (
15 15 error,
16 16 pycompat,
17 17 )
18 from mercurial.utils import (
19 stringutil,
20 )
18 21
19 22 class InvalidPointer(error.RevlogError):
20 23 pass
@@ -32,7 +35,9 class gitlfspointer(dict):
32 35 try:
33 36 return cls(l.split(' ', 1) for l in text.splitlines()).validate()
34 37 except ValueError: # l.split returns 1 item instead of 2
35 raise InvalidPointer(_('cannot parse git-lfs text: %r') % text)
38 raise InvalidPointer(
39 _('cannot parse git-lfs text: %s') % stringutil.pprint(
40 text, bprefix=False))
36 41
37 42 def serialize(self):
38 43 sortkeyfunc = lambda x: (x[0] != 'version', x)
@@ -61,12 +66,14 class gitlfspointer(dict):
61 66 for k, v in self.iteritems():
62 67 if k in self._requiredre:
63 68 if not self._requiredre[k].match(v):
64 raise InvalidPointer(_('unexpected value: %s=%r') % (k, v))
69 raise InvalidPointer(_('unexpected value: %s=%s') % (
70 k, stringutil.pprint(v, bprefix=False)))
65 71 requiredcount += 1
66 72 elif not self._keyre.match(k):
67 73 raise InvalidPointer(_('unexpected key: %s') % k)
68 74 if not self._valuere.match(v):
69 raise InvalidPointer(_('unexpected value: %s=%r') % (k, v))
75 raise InvalidPointer(_('unexpected value: %s=%s') % (
76 k, stringutil.pprint(v, bprefix=False)))
70 77 if len(self._requiredre) != requiredcount:
71 78 miss = sorted(set(self._requiredre.keys()).difference(self.keys()))
72 79 raise InvalidPointer(_('missed keys: %s') % ', '.join(miss))
General Comments 0
You need to be logged in to leave comments. Login now