Show More
@@ -79,17 +79,30 b' def diffordiffstat(ui, repo, diffopts, n' | |||||
79 | width = 80 |
|
79 | width = 80 | |
80 | if not ui.plain(): |
|
80 | if not ui.plain(): | |
81 | width = ui.termwidth() |
|
81 | width = ui.termwidth() | |
|
82 | ||||
82 |
|
|
83 | chunks = patch.diff(repo, node1, node2, match, changes, opts=diffopts, | |
83 |
|
|
84 | prefix=prefix, relroot=relroot, | |
84 |
|
|
85 | hunksfilterfn=hunksfilterfn) | |
85 | for chunk, label in patch.diffstatui(util.iterlines(chunks), |
|
86 | ||
86 | width=width): |
|
87 | if fp is not None or ui.canwritewithoutlabels(): | |
87 | write(chunk, label=label) |
|
88 | if stat: | |
|
89 | chunks = patch.diffstat(util.iterlines(chunks), width=width) | |||
|
90 | for chunk in util.filechunkiter(util.chunkbuffer(chunks)): | |||
|
91 | write(chunk) | |||
|
92 | else: | |||
|
93 | if stat: | |||
|
94 | chunks = patch.diffstatui(util.iterlines(chunks), width=width) | |||
88 | else: |
|
95 | else: | |
89 | for chunk, label in patch.diffui(repo, node1, node2, match, |
|
96 | chunks = patch.difflabel(lambda chunks, **kwargs: chunks, chunks, | |
90 |
|
|
97 | opts=diffopts) | |
91 | relroot=relroot, |
|
98 | if ui.canbatchlabeledwrites(): | |
92 | hunksfilterfn=hunksfilterfn): |
|
99 | def gen(): | |
|
100 | for chunk, label in chunks: | |||
|
101 | yield ui.label(chunk, label=label) | |||
|
102 | for chunk in util.filechunkiter(util.chunkbuffer(gen())): | |||
|
103 | write(chunk) | |||
|
104 | else: | |||
|
105 | for chunk, label in chunks: | |||
93 | write(chunk, label=label) |
|
106 | write(chunk, label=label) | |
94 |
|
107 | |||
95 | if listsubrepos: |
|
108 | if listsubrepos: |
@@ -870,6 +870,17 b' class ui(object):' | |||||
870 |
|
870 | |||
871 | return "".join(self._buffers.pop()) |
|
871 | return "".join(self._buffers.pop()) | |
872 |
|
872 | |||
|
873 | def canwritewithoutlabels(self): | |||
|
874 | '''check if write skips the label''' | |||
|
875 | if self._buffers and not self._bufferapplylabels: | |||
|
876 | return True | |||
|
877 | return self._colormode is None | |||
|
878 | ||||
|
879 | def canbatchlabeledwrites(self): | |||
|
880 | '''check if write calls with labels are batchable''' | |||
|
881 | # Windows color printing is special, see ``write``. | |||
|
882 | return self._colormode != 'win32' | |||
|
883 | ||||
873 | def write(self, *args, **opts): |
|
884 | def write(self, *args, **opts): | |
874 | '''write args to output |
|
885 | '''write args to output | |
875 |
|
886 |
General Comments 0
You need to be logged in to leave comments.
Login now