[PATCH 2 of 6] check-code: use fixedmap for replacement of space characters

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue May 31 08:15:36 EDT 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1464696150 -32400
#      Tue May 31 21:02:30 2016 +0900
# Node ID 79a11506803fa9d5115c2c6ea71278970ac43911
# Parent  4dd530df474256a7011244132fe376eb5514c1c7
check-code: use fixedmap for replacement of space characters

This can centralize management of fixed replacement into fixedmap.

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -51,13 +51,11 @@ def compilere(pat, multiline=False):
     return re.compile(pat)
 
 def repquote(m):
-    fixedmap = {'.': 'p', ':': 'q'}
+    fixedmap = {' ': ' ', '\n': '\n', '.': 'p', ':': 'q'}
     def encodechr(i):
         if i > 255:
             return 'u'
         c = chr(i)
-        if c in ' \n':
-            return c
         if c in fixedmap:
             return fixedmap[c]
         if c.isalpha():


More information about the Mercurial-devel mailing list