[PATCH 1 of 3] largefiles: improve error reporting
Matt Mackall
mpm at selenic.com
Fri Oct 14 14:28:03 CDT 2011
On Thu, 2011-10-13 at 21:48 -0400, Greg Ward wrote:
> # HG changeset patch
> # User Greg Ward <greg at gerg.ca>
> # Date 1318551869 14400
> # Node ID f984c9e433a6632c1da83206c709846f306ea10e
> # Parent 72400acb2d76b81fd6f0f873054309b95a1a62b8
> largefiles: improve error reporting
I've amended your patch thusly:
- fix long line
- avoid shadowing file built-in
- use more canonical format for error message
(and, not in the diff, update the test)
diff -r aa93ed0d6e7a hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py Thu Oct 13 20:24:29 2011 -0400
+++ b/hgext/largefiles/lfcommands.py Fri Oct 14 14:24:44 2011 -0500
@@ -347,8 +347,8 @@
total=len(files))
source = lfutil.findfile(rsrc, hash)
if not source:
- raise util.Abort(_('largefile %s missing from store (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
diff -r aa93ed0d6e7a hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py Thu Oct 13 20:24:29 2011 -0400
+++ b/hgext/largefiles/reposetup.py Fri Oct 14 14:24:44 2011 -0500
@@ -286,12 +286,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(
- _('%s: is a largefile standin; commit the '
- 'largefile itself instead')
- % file)
+ _('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.
You can of course fold the regex checks into the revset expression
> - 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.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list