# HG changeset patch # User Denis Laxalde # Date 2016-07-11 12:44:19 # Node ID 576ff900fcc7c7b1b9993e541a86cbcc904e9af1 # Parent 9d02bed8477bec7f679d6aeb5b1dd8bcdb80f64d context: eliminate handling of linenumber being None in annotate I could not find any use of this parameter value. And it arguably makes understanding of the function more difficult. Setting the parameter default value to False. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -918,27 +918,20 @@ class basefilectx(object): return p[1] return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) - def annotate(self, follow=False, linenumber=None, diffopts=None): - '''returns a list of tuples of (ctx, line) for each line + def annotate(self, follow=False, linenumber=False, diffopts=None): + '''returns a list of tuples of ((ctx, number), line) for each line in the file, where ctx is the filectx of the node where - that line was last changed. - This returns tuples of ((ctx, linenumber), line) for each line, - if "linenumber" parameter is NOT "None". - In such tuples, linenumber means one at the first appearance - in the managed file. - To reduce annotation cost, - this returns fixed value(False is used) as linenumber, - if "linenumber" parameter is "False".''' + that line was last changed; if linenumber parameter is true, number is + the line number at the first appearance in the managed file, otherwise, + number has a fixed value of False. + ''' def lines(text): if text.endswith("\n"): return text.count("\n") return text.count("\n") + 1 - if linenumber is None: - def decorate(text, rev): - return ([rev] * lines(text), text) - elif linenumber: + if linenumber: def decorate(text, rev): return ([(rev, i) for i in xrange(1, lines(text) + 1)], text) else: