Patchwork D3513: lfs: stabilize error message values for Python 2 and 3

login
register
mail settings
Submitter phabricator
Date May 8, 2018, 8:46 p.m.
Message ID <differential-rev-PHID-DREV-tgpbby2bzd3ci4wprvi6-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31419/
State Superseded
Headers show

Comments

phabricator - May 8, 2018, 8:46 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3513

AFFECTED FILES
  hgext/lfs/pointer.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/lfs/pointer.py b/hgext/lfs/pointer.py
--- a/hgext/lfs/pointer.py
+++ b/hgext/lfs/pointer.py
@@ -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,12 +66,14 @@ 
         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):
-                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))