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

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 15, 2014, 1:47 p.m.
Message ID <b09deed03057ef7ad19a.1408110458@mimosa>
Download mbox | patch
Permalink /patch/5413/
State Accepted
Headers show

Comments

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

Patch

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,