[PATCH 1 of 3] largefiles: improve error reporting
Greg Ward
greg at gerg.ca
Thu Oct 13 20:48:39 CDT 2011
# HG changeset patch
# User Greg Ward <greg at gerg.ca>
# Date 1318551869 14400
# Node ID f984c9e433a6632c1da83206c709846f306ea10e
# Parent 72400acb2d76b81fd6f0f873054309b95a1a62b8
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
diff --git a/hgext/largefiles/basestore.py b/hgext/largefiles/basestore.py
--- a/hgext/largefiles/basestore.py
+++ b/hgext/largefiles/basestore.py
@@ -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)
diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -345,7 +345,7 @@
total=len(files))
source = lfutil.findfile(rsrc, hash)
if not source:
- raise util.Abort(_('Missing largefile %s needs to be uploaded')
+ raise util.Abort(_('largefile %s missing from store (needs to be uploaded)')
% hash)
# XXX check for errors here
store.put(source, hash)
diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -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):
diff --git a/hgext/largefiles/remotestore.py b/hgext/largefiles/remotestore.py
--- a/hgext/largefiles/remotestore.py
+++ b/hgext/largefiles/remotestore.py
@@ -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)
diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -277,7 +277,9 @@
for file in match.files():
if lfutil.isstandin(file):
raise util.Abort(
- "Don't commit largefile standin. Commit largefile.")
+ _('%s: is a largefile standin; commit the '
+ 'largefile itself instead')
+ % file)
# Case 2: user calls commit with specified patterns: refresh
# any matching big files.
More information about the Mercurial-devel
mailing list