[PATCH] lfs: clarify pointer validation error messages

Matt Harbison mharbison72 at gmail.com
Fri May 25 23:21:09 EDT 2018

# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1524798019 14400
#      Thu Apr 26 23:00:19 2018 -0400
# Node ID f900dd997ad3118d808891ebd746983255890135
# Parent  2ce1e9bdc7157948fa799888009cc4c20c113d8c
lfs: clarify pointer validation error messages

It wasn't obvious that LFS was involved from the error messages when `hg verify`

diff --git a/hgext/lfs/pointer.py b/hgext/lfs/pointer.py
--- a/hgext/lfs/pointer.py
+++ b/hgext/lfs/pointer.py
@@ -65,17 +65,19 @@ class gitlfspointer(dict):
         for k, v in self.iteritems():
             if k in self._requiredre:
                 if not self._requiredre[k].match(v):
-                    raise InvalidPointer(_('unexpected value: %s=%s')
-                                         % (k, stringutil.pprint(v)))
+                    raise InvalidPointer(
+                        _('unexpected lfs pointer value: %s=%s')
+                          % (k, stringutil.pprint(v)))
                 requiredcount += 1
             elif not self._keyre.match(k):
-                raise InvalidPointer(_('unexpected key: %s') % k)
+                raise InvalidPointer(_('unexpected lfs pointer key: %s') % k)
             if not self._valuere.match(v):
-                raise InvalidPointer(_('unexpected value: %s=%s')
+                raise InvalidPointer(_('unexpected lfs pointer value: %s=%s')
                                      % (k, stringutil.pprint(v)))
         if len(self._requiredre) != requiredcount:
             miss = sorted(set(self._requiredre.keys()).difference(self.keys()))
-            raise InvalidPointer(_('missed keys: %s') % ', '.join(miss))
+            raise InvalidPointer(_('missing lfs pointer keys: %s')
+                                   % ', '.join(miss))
         return self
 deserialize = gitlfspointer.deserialize
diff --git a/tests/test-lfs-pointer.py.out b/tests/test-lfs-pointer.py.out
--- a/tests/test-lfs-pointer.py.out
+++ b/tests/test-lfs-pointer.py.out
@@ -1,12 +1,12 @@
-missed keys: oid, size
+missing lfs pointer keys: oid, size
-unexpected value: version='https://unknown.github.com/spec/v1'
+unexpected lfs pointer value: version='https://unknown.github.com/spec/v1'
 cannot parse git-lfs text: 'version https://git-lfs.github.com/spec/v1\n\noid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393\nsize 12345\nx-foo extra-information\n'
-unexpected value: oid='ahs256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393'
-unexpected value: oid='4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393'
-unexpected value: size='0x12345'
+unexpected lfs pointer value: oid='ahs256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393'
+unexpected lfs pointer value: oid='4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393'
+unexpected lfs pointer value: size='0x12345'
 cannot parse git-lfs text: 'version https://git-lfs.github.com/spec/v1\noid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393\nsize 12345\nx-foo extra\ninformation\n'
-unexpected key: x_foo
-missed keys: oid
-missed keys: oid, size
+unexpected lfs pointer key: x_foo
+missing lfs pointer keys: oid
+missing lfs pointer keys: oid, size

More information about the Mercurial-devel mailing list