[PATCH 08 of 21 RFC] cmdutil: abort with localized error when `hg cat` encounters censored data

Matt Mackall mpm at selenic.com
Thu Sep 11 12:54:18 CDT 2014


On Wed, 2014-09-10 at 20:26 -0400, michaeljedgar at gmail.com wrote:
> # HG changeset patch
> # User Mike Edgar <adgar at google.com>
> # Date 1409528434 -7200
> #      Mon Sep 01 01:40:34 2014 +0200
> # Node ID f773537e5d12817f3523d86920c0df62062dd108
> # Parent  96b547c542400ef1d75b7a2ed9a4731e7296a337
> cmdutil: abort with localized error when `hg cat` encounters censored data
> 
> diff -r 96b547c54240 -r f773537e5d12 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py	Wed Sep 10 00:18:15 2014 -0400
> +++ b/mercurial/cmdutil.py	Mon Sep 01 01:40:34 2014 +0200
> @@ -1959,7 +1959,11 @@
>      def write(path):
>          fp = makefileobj(repo, opts.get('output'), ctx.node(),
>                           pathname=os.path.join(prefix, path))
> -        data = ctx[path].data()
> +        try:
> +            data = ctx[path].data()
> +        except revlog.CensoredNodeError, e:
> +            raise util.Abort(
> +                _('node %s in file %s is censored') % (short(e.node), path))

This pattern is too burdensome. There are way too many places we access
file data, we don't want to audit them all and add special handling. We
just need to let the exception pass through and get caught by the
dispatcher.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list