##// 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,18 +79,31 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 chunks = patch.diff(repo, node1, node2, match, changes, opts=diffopts,
82
83 prefix=prefix, relroot=relroot,
83 chunks = patch.diff(repo, node1, node2, match, changes, opts=diffopts,
84 hunksfilterfn=hunksfilterfn)
84 prefix=prefix, relroot=relroot,
85 for chunk, label in patch.diffstatui(util.iterlines(chunks),
85 hunksfilterfn=hunksfilterfn)
86 width=width):
86
87 write(chunk, label=label)
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)
88 else:
92 else:
89 for chunk, label in patch.diffui(repo, node1, node2, match,
93 if stat:
90 changes, opts=diffopts, prefix=prefix,
94 chunks = patch.diffstatui(util.iterlines(chunks), width=width)
91 relroot=relroot,
95 else:
92 hunksfilterfn=hunksfilterfn):
96 chunks = patch.difflabel(lambda chunks, **kwargs: chunks, chunks,
93 write(chunk, label=label)
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:
106 write(chunk, label=label)
94
107
95 if listsubrepos:
108 if listsubrepos:
96 ctx1 = repo[node1]
109 ctx1 = repo[node1]
@@ -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