[PATCH 2 of 2] annotate: inline definition of decorate() functions

Yuya Nishihara yuya at tcha.org
Fri Aug 15 08:47:38 CDT 2014


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1408080799 -32400
#      Fri Aug 15 14:33:19 2014 +0900
# Node ID b09deed03057ef7ad19aa876fa948f0faf16ae0b
# Parent  a5faa142ebeed6a65c504586ef04eafa788d05d7
annotate: inline definition of decorate() functions

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -767,22 +767,16 @@ class basefilectx(object):
         this returns fixed value(False is used) as linenumber,
         if "linenumber" parameter is "False".'''
 
-        def decorate_compat(text, rev):
-            return ([rev] * len(text.splitlines()), text)
-
-        def without_linenumber(text, rev):
-            return ([(rev, False)] * len(text.splitlines()), text)
-
-        def with_linenumber(text, rev):
-            size = len(text.splitlines())
-            return ([(rev, i) for i in xrange(1, size + 1)], text)
-
         if linenumber is None:
-            decorate = decorate_compat
+            def decorate(text, rev):
+                return ([rev] * len(text.splitlines()), text)
         elif linenumber:
-            decorate = with_linenumber
+            def decorate(text, rev):
+                size = len(text.splitlines())
+                return ([(rev, i) for i in xrange(1, size + 1)], text)
         else:
-            decorate = without_linenumber
+            def decorate(text, rev):
+                return ([(rev, False)] * len(text.splitlines()), text)
 
         def pair(parent, child):
             blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts,


More information about the Mercurial-devel mailing list