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

grep: add 'report first match' feature

This will not be effective for history search, so (more) intellegence
needs to be added to those radio buttons.

Changeset f77897ae5124

Parent 09f295240942

by Steve Borho

Changes to one file · Browse files at f77897ae5124 Showing diff from parent 09f295240942 Diff from another changeset...

 
59
60
61
 
62
63
64
 
66
67
68
 
69
70
71
 
105
106
107
 
108
109
110
 
151
152
153
154
 
 
155
156
157
 
161
162
163
164
 
 
165
166
167
 
241
242
243
244
 
245
246
247
248
249
250
 
251
252
253
 
273
274
275
 
 
276
277
278
 
59
60
61
62
63
64
65
 
67
68
69
70
71
72
73
 
107
108
109
110
111
112
113
 
154
155
156
 
157
158
159
160
161
 
165
166
167
 
168
169
170
171
172
 
246
247
248
 
249
250
251
252
253
254
255
256
257
258
259
 
279
280
281
282
283
284
285
286
@@ -59,6 +59,7 @@
  working = QRadioButton(_('Working Copy'))   revision = QRadioButton(_('Revision'))   history = QRadioButton(_('All History')) + singlematch = QCheckBox(_('Report only the first match per file'))   revle = QLineEdit()   grid = QGridLayout()   grid.addWidget(working, 0, 0) @@ -66,6 +67,7 @@
  grid.addWidget(revle, 1, 1)   grid.addWidget(history, 2, 0)   working.setChecked(True) + grid.addWidget(singlematch, 0, 3)   ilabel = QLabel(_('Includes:'))   elabel = QLabel(_('Excludes:'))   grid.addWidget(ilabel, 1, 2) @@ -105,6 +107,7 @@
  self.tv, self.le, self.chk = tv, le, chk   self.incle, self.excle, self.revle = incle, excle, revle   self.wctxradio, self.ctxradio, self.aradio = working, revision, history + self.singlematch = singlematch     if not parent:   self.setWindowTitle(_('TortoiseHg Search')) @@ -151,7 +154,8 @@
  self.tv.setColumnHidden(COL_REVISION, True)   self.tv.setColumnHidden(COL_USER, True)   ctx = self.repo[None] - self.thread = CtxSearchThread(self.repo, regexp, ctx, inc, exc) + self.thread = CtxSearchThread(self.repo, regexp, ctx, inc, exc, + once=self.singlematch.isChecked())   elif self.ctxradio.isChecked():   self.tv.setColumnHidden(COL_REVISION, True)   self.tv.setColumnHidden(COL_USER, True) @@ -161,7 +165,8 @@
  msg = _('grep: %s\n') % e   self.emit(SIGNAL('errorMessage'), msg)   return - self.thread = CtxSearchThread(self.repo, regexp, ctx, inc, exc) + self.thread = CtxSearchThread(self.repo, regexp, ctx, inc, exc, + once=self.singlematch.isChecked())   else:   assert self.aradio.isChecked()   self.tv.setColumnHidden(COL_REVISION, False) @@ -241,13 +246,14 @@
   class CtxSearchThread(QThread):   '''Background thread for searching a changectx''' - def __init__(self, repo, regexp, ctx, inc, exc): + def __init__(self, repo, regexp, ctx, inc, exc, once):   super(CtxSearchThread, self).__init__()   self.repo = repo   self.regexp = regexp   self.ctx = ctx   self.inc = inc   self.exc = exc + self.once = once     def run(self):   # this will eventually be: hg grep -c @@ -273,6 +279,8 @@
  hu.write(line[pos:])   row = [wfile, i, rev, None, hu.getdata()[0]]   self.emit(SIGNAL('matchedRow'), row) + if self.once: + break   self.emit(SIGNAL('finished'))