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

michaeljedgar at gmail.com michaeljedgar at gmail.com
Wed Sep 10 19:26:09 CDT 2014


# 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))
         if opts.get('decode'):
             data = repo.wwritedata(path, data)
         fp.write(data)


More information about the Mercurial-devel mailing list