Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

commit: highlight (in red) message lines that violate the format

Changeset 896e596e5843

Parent 73b5d51800e7

by Steve Borho

Changes to one file · Browse files at 896e596e5843 Showing diff from parent 73b5d51800e7 Diff from another changeset...

 
144
145
146
147
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
150
151
 
144
145
146
 
 
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
@@ -144,8 +144,42 @@
  self.msgcombo = msgcombo     def msgChanged(self): - self.commitButton.setEnabled( - not self.msgte.toPlainText().isEmpty()) + text = self.msgte.toPlainText() + self.commitButton.setEnabled(not text.isEmpty()) + sumlen, maxlen = self.getLengths() + if not sumlen and not maxlen: + self.msgte.setExtraSelections([]) + return + pos, nextpos = 0, 0 + sels = [] + for i, line in enumerate(text.split('\n')): + pos = nextpos + length = len(line) + nextpos += length + 1 # include \n + if i == 0 and (length < sumlen or not sumlen): + continue + elif i == 1 and (length == 0 or not sumlen): + continue + elif i > 1 and (length < maxlen or not maxlen): + continue + sel = QTextEdit.ExtraSelection() + sel.bgcolor = QColor('red') + sel.format.setBackground(sel.bgcolor) + sel.format.setProperty(QTextFormat.FullWidthSelection, True) + sel.cursor = QTextCursor(self.msgte.document()) + sel.cursor.setPosition(pos) + sel.cursor.clearSelection() + sels.append(sel) + self.msgte.setExtraSelections(sels) + + def getLengths(self): + repo = self.stwidget.repo + try: + sumlen = int(repo.ui.config('tortoisehg', 'summarylen', 0)) + maxlen = int(repo.ui.config('tortoisehg', 'messagewrap', 0)) + except (TypeError, ValueError): + sumlen, maxlen = 0, 0 + return sumlen, maxlen     def restoreState(self, data):   return self.stwidget.restoreState(data)