Submitter | michaeljedgar@gmail.com |
---|---|
Date | Sept. 11, 2014, 12:26 a.m. |
Message ID | <f773537e5d12817f3523.1410395169@adgar-macbookpro3.roam.corp.google.com> |
Download | mbox | patch |
Permalink | /patch/5783/ |
State | Changes Requested |
Headers | show |
Comments
On Wed, 2014-09-10 at 20:26 -0400, michaeljedgar@gmail.com wrote: > # HG changeset patch > # User Mike Edgar <adgar@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.
Patch
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)) if opts.get('decode'): data = repo.wwritedata(path, data) fp.write(data)