changeset 15253:67d010779907

largefiles: improve error reporting - tweak wording of some error messages - use consistent capitalization - always say 'largefile', not 'lfile' - fix I18N problems - only raise Abort for errors the user can do something about
author Greg Ward <greg@gerg.ca>
date Thu, 13 Oct 2011 20:24:29 -0400
parents 6e809bb4f969
children dd03d3a9f888
files hgext/largefiles/basestore.py hgext/largefiles/lfcommands.py hgext/largefiles/lfutil.py hgext/largefiles/remotestore.py hgext/largefiles/reposetup.py tests/test-largefiles.t
diffstat 6 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/basestore.py	Wed Oct 12 20:59:27 2011 -0400
+++ b/hgext/largefiles/basestore.py	Thu Oct 13 20:24:29 2011 -0400
@@ -199,4 +199,4 @@
         except lfutil.storeprotonotcapable:
             pass
 
-    raise util.Abort(_('%s does not appear to be a lfile store'), path)
+    raise util.Abort(_('%s does not appear to be a largefile store'), path)
--- a/hgext/largefiles/lfcommands.py	Wed Oct 12 20:59:27 2011 -0400
+++ b/hgext/largefiles/lfcommands.py	Thu Oct 13 20:24:29 2011 -0400
@@ -345,8 +345,8 @@
                     total=len(files))
         source = lfutil.findfile(rsrc, hash)
         if not source:
-            raise util.Abort(_('Missing largefile %s needs to be uploaded')
-                             % hash)
+            raise util.Abort(_('largefile %s missing from store'
+                               ' (needs to be uploaded)') % hash)
         # XXX check for errors here
         store.put(source, hash)
         at += 1
--- a/hgext/largefiles/lfutil.py	Wed Oct 12 20:59:27 2011 -0400
+++ b/hgext/largefiles/lfutil.py	Thu Oct 13 20:24:29 2011 -0400
@@ -91,7 +91,7 @@
         elif os.name == 'posix':
             path = os.path.join(os.getenv('HOME'), '.' + longname, hash)
         else:
-            raise util.Abort(_('Unknown operating system: %s\n') % os.name)
+            raise util.Abort(_('unknown operating system: %s\n') % os.name)
     return path
 
 def insystemcache(ui, hash):
--- a/hgext/largefiles/remotestore.py	Wed Oct 12 20:59:27 2011 -0400
+++ b/hgext/largefiles/remotestore.py	Thu Oct 13 20:24:29 2011 -0400
@@ -50,9 +50,10 @@
     def _getfile(self, tmpfile, filename, hash):
         # quit if the largefile isn't there
         stat = self._stat(hash)
-        if stat:
-            raise util.Abort(_('remotestore: largefile %s is %s') %
-                             (hash, stat == 1 and 'invalid' or 'missing'))
+        if stat == 1:
+            raise util.Abort(_('remotestore: largefile %s is invalid') % hash)
+        elif stat == 2:
+            raise util.Abort(_('remotestore: largefile %s is missing') % hash)
 
         try:
             length, infile = self._get(hash)
@@ -64,7 +65,7 @@
             # This usually indicates a connection problem, so don't
             # keep trying with the other files... they will probably
             # all fail too.
-            raise util.Abort('%s: %s' % (self.url, str(e.reason)))
+            raise util.Abort('%s: %s' % (self.url, e.reason))
         except IOError, e:
             raise basestore.StoreError(filename, hash, self.url, str(e))
 
@@ -101,5 +102,5 @@
                 % (cset, filename))
             return True # failed
         else:
-            raise util.Abort(_('check failed, unexpected response'
-                               'statlfile: %d') % stat)
+            raise RuntimeError('verify failed: unexpected response from '
+                               'statlfile (%r)' % stat)
--- a/hgext/largefiles/reposetup.py	Wed Oct 12 20:59:27 2011 -0400
+++ b/hgext/largefiles/reposetup.py	Thu Oct 13 20:24:29 2011 -0400
@@ -287,10 +287,11 @@
                     return orig(text=text, user=user, date=date, match=match,
                                     force=force, editor=editor, extra=extra)
 
-                for file in match.files():
-                    if lfutil.isstandin(file):
+                for f in match.files():
+                    if lfutil.isstandin(f):
                         raise util.Abort(
-                            "Don't commit largefile standin. Commit largefile.")
+                            _('file "%s" is a largefile standin') % f,
+                            hint=('commit the largefile itself instead'))
 
                 # Case 2: user calls commit with specified patterns: refresh
                 # any matching big files.
--- a/tests/test-largefiles.t	Wed Oct 12 20:59:27 2011 -0400
+++ b/tests/test-largefiles.t	Thu Oct 13 20:24:29 2011 -0400
@@ -172,7 +172,8 @@
   $ cd ..
   $ echo large3 > large3
   $ hg commit .hglf/large3 -m "try to commit standin"
-  abort: Don't commit largefile standin. Commit largefile.
+  abort: file ".hglf/large3" is a largefile standin
+  (commit the largefile itself instead)
   [255]
 
 Test some cornercases for adding largefiles.