##// 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 b' from mercurial import ('
15 error,
15 error,
16 pycompat,
16 pycompat,
17 )
17 )
18 from mercurial.utils import (
19 stringutil,
20 )
18
21
19 class InvalidPointer(error.RevlogError):
22 class InvalidPointer(error.RevlogError):
20 pass
23 pass
@@ -32,7 +35,9 b' class gitlfspointer(dict):'
32 try:
35 try:
33 return cls(l.split(' ', 1) for l in text.splitlines()).validate()
36 return cls(l.split(' ', 1) for l in text.splitlines()).validate()
34 except ValueError: # l.split returns 1 item instead of 2
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 def serialize(self):
42 def serialize(self):
38 sortkeyfunc = lambda x: (x[0] != 'version', x)
43 sortkeyfunc = lambda x: (x[0] != 'version', x)
@@ -61,12 +66,14 b' class gitlfspointer(dict):'
61 for k, v in self.iteritems():
66 for k, v in self.iteritems():
62 if k in self._requiredre:
67 if k in self._requiredre:
63 if not self._requiredre[k].match(v):
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 requiredcount += 1
71 requiredcount += 1
66 elif not self._keyre.match(k):
72 elif not self._keyre.match(k):
67 raise InvalidPointer(_('unexpected key: %s') % k)
73 raise InvalidPointer(_('unexpected key: %s') % k)
68 if not self._valuere.match(v):
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 if len(self._requiredre) != requiredcount:
77 if len(self._requiredre) != requiredcount:
71 miss = sorted(set(self._requiredre.keys()).difference(self.keys()))
78 miss = sorted(set(self._requiredre.keys()).difference(self.keys()))
72 raise InvalidPointer(_('missed keys: %s') % ', '.join(miss))
79 raise InvalidPointer(_('missed keys: %s') % ', '.join(miss))
General Comments 0
You need to be logged in to leave comments. Login now