# HG changeset patch # User Yuya Nishihara # Date 2018-02-07 14:22:53 # Node ID 006ff7268c5c306a5a8c4a748737ab91d57e57b8 # Parent 29b83c08afe0fbd74a2246f257bb45a17429deed diff: remove fp.write() wrapper which drops label argument It's no longer needed since we've split labeled write() from file-like write(). diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py +++ b/mercurial/logcmdutil.py @@ -54,12 +54,6 @@ def diffordiffstat(ui, repo, diffopts, n changes=None, stat=False, fp=None, prefix='', root='', listsubrepos=False, hunksfilterfn=None): '''show diff or diffstat.''' - if fp is None: - write = ui.write - else: - def write(s, **kw): - fp.write(s) - if root: relroot = pathutil.canonpath(repo.root, repo.getcwd(), root) else: @@ -85,10 +79,11 @@ def diffordiffstat(ui, repo, diffopts, n hunksfilterfn=hunksfilterfn) if fp is not None or ui.canwritewithoutlabels(): + out = fp or ui if stat: chunks = patch.diffstat(util.iterlines(chunks), width=width) for chunk in util.filechunkiter(util.chunkbuffer(chunks)): - write(chunk) + out.write(chunk) else: if stat: chunks = patch.diffstatui(util.iterlines(chunks), width=width) @@ -100,10 +95,10 @@ def diffordiffstat(ui, repo, diffopts, n for chunk, label in chunks: yield ui.label(chunk, label=label) for chunk in util.filechunkiter(util.chunkbuffer(gen())): - write(chunk) + ui.write(chunk) else: for chunk, label in chunks: - write(chunk, label=label) + ui.write(chunk, label=label) if listsubrepos: ctx1 = repo[node1]