##// END OF EJS Templates
diff: improve ui.write performance when not coloring on Windows...
Joerg Sonnenberger -
r35979:0ff41ced default
parent child Browse files
Show More
@@ -79,17 +79,30 b' def diffordiffstat(ui, repo, diffopts, n'
79 79 width = 80
80 80 if not ui.plain():
81 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 width=width):
87 write(chunk, label=label)
86
87 if fp is not None or ui.canwritewithoutlabels():
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 95 else:
89 for chunk, label in patch.diffui(repo, node1, node2, match,
90 changes, opts=diffopts, prefix=prefix,
91 relroot=relroot,
92 hunksfilterfn=hunksfilterfn):
96 chunks = patch.difflabel(lambda chunks, **kwargs: chunks, chunks,
97 opts=diffopts)
98 if ui.canbatchlabeledwrites():
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 106 write(chunk, label=label)
94 107
95 108 if listsubrepos:
@@ -870,6 +870,17 b' class ui(object):'
870 870
871 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 884 def write(self, *args, **opts):
874 885 '''write args to output
875 886
General Comments 0
You need to be logged in to leave comments. Login now