[PATCH 1 of 2] check-code: do not abort on an unreadable file, only report this

Simon Heimberg simohe at besonet.ch
Sat Jul 13 14:10:15 CDT 2013


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1373741217 -7200
# Node ID 089daf84e6c4088633c39290142694000af25f37
# Parent  2fe7dc2afce4ff87e89180828f18a5c849c962fe
check-code: do not abort on an unreadable file, only report this

diff -r 2fe7dc2afce4 -r 089daf84e6c4 contrib/check-code.py
--- a/contrib/check-code.py	Sam Jul 13 20:11:47 2013 +0200
+++ b/contrib/check-code.py	Sam Jul 13 20:46:57 2013 +0200
@@ -462,7 +462,11 @@
                 print "Skipping %s for %s it doesn't match %s" % (
                        name, match, f)
             continue
-        fp = open(f)
+        try:
+            fp = open(f)
+        except IOError, e:
+            print "Skipping %s, %s" % (f, str(e).split(':', 1)[0])
+            continue
         pre = post = fp.read()
         fp.close()
         if "no-" "check-code" in pre:
diff -r 2fe7dc2afce4 -r 089daf84e6c4 tests/test-check-code.t
--- a/tests/test-check-code.t	Sam Jul 13 20:11:47 2013 +0200
+++ b/tests/test-check-code.t	Sam Jul 13 20:46:57 2013 +0200
@@ -177,8 +177,10 @@
   > # this next line is okay
   > raise SomeException(arg1, arg2)
   > EOF
-  $ "$check_code" raise-format.py
+  $ "$check_code" not-existing.py raise-format.py
+  Skipping*not-existing.py* (glob)
   raise-format.py:1:
    > raise SomeException, message
    don't use old-style two-argument raise, use Exception(message)
   [1]
+


More information about the Mercurial-devel mailing list