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

grep, annotate: open single grep dialog from annotate dialog

Changeset 05429fe6e5ce

Parent 7c133b10b9a8

by Steve Borho

Changes to 2 files · Browse files at 05429fe6e5ce Showing diff from parent 7c133b10b9a8 Diff from another changeset...

 
13
14
15
 
16
17
18
 
114
115
116
117
 
118
119
120
 
366
367
368
 
369
370
371
 
410
411
412
413
414
415
 
 
 
 
 
416
417
418
419
420
 
 
 
 
 
421
422
423
424
425
 
 
 
 
 
426
427
428
 
13
14
15
16
17
18
19
 
115
116
117
 
118
119
120
121
 
367
368
369
370
371
372
373
 
412
413
414
 
 
 
415
416
417
418
419
420
421
 
 
 
422
423
424
425
426
427
428
 
 
 
429
430
431
432
433
434
435
436
@@ -13,6 +13,7 @@
 from tortoisehg.hgqt import visdiff, qtlib, wctxactions  from tortoisehg.util import paths, hglib, colormap  from tortoisehg.hgqt.i18n import _ +from tortoisehg.hgqt.grep import SearchWidget    from PyQt4.QtCore import *  from PyQt4.QtGui import * @@ -114,7 +115,7 @@
  cursor.position() <= c.selectionEnd():   selection = c.selection().toPlainText()   def sorig(): - sdata = [selection, fctx.linkrev()] + sdata = [selection, str(fctx.linkrev())]   self.emit(SIGNAL('searchAtRev'), sdata)   def sctx():   self.emit(SIGNAL('searchAtParent'), selection) @@ -366,6 +367,7 @@
  self.connect(av, SIGNAL('searchAnnotation'), self.searchAnnotation)     self.status = status + self.searchwidget = None     self.opts = opts   line = opts.get('line') @@ -410,19 +412,25 @@
  wctxactions.edit(self, repo.ui, repo, files, line, pattern)     def searchAtRev(self, args): - # grep widget needs to support argument passing via **opts - # search repo[args[1]] - raise NotImplementedError() + if self.searchwidget is None: + self.searchwidget = SearchWidget([args[0]], rev=args[1]) + else: + self.searchwidget.setSearch(args[0], rev=args[1]) + self.searchwidget.show()     def searchAtParent(self, pattern): - # grep widget needs to support argument passing via **opts - # search repo['.'] - raise NotImplementedError() + if self.searchwidget is None: + self.searchwidget = SearchWidget([pattern], rev='.') + else: + self.searchwidget.setSearch(pattern, rev='.') + self.searchwidget.show()     def searchAll(self, pattern): - # grep widget needs to support argument passing via **opts - # search all history - raise NotImplementedError() + if self.searchwidget is None: + self.searchwidget = SearchWidget([pattern], all=True) + else: + self.searchwidget.setSearch(pattern, all=True) + self.searchwidget.show()     def searchAnnotation(self, pattern):   self.le.setText(QRegExp.escape(pattern))
 
27
28
29
30
 
31
32
33
 
56
57
58
59
60
61
62
63
 
67
68
69
70
71
72
73
74
 
131
132
133
 
134
135
136
137
138
 
139
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
142
143
 
514
515
516
517
 
 
 
27
28
29
 
30
31
32
33
 
56
57
58
 
 
59
60
61
 
65
66
67
 
 
68
69
70
 
127
128
129
130
131
132
133
134
 
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
 
528
529
530
 
531
532
@@ -27,7 +27,7 @@
  loadComplete() - for progress bar   errorMessage(QString) - for status bar   ''' - def __init__(self, pats, root=None, parent=None): + def __init__(self, upats, root=None, parent=None, **opts):   QDockWidget.__init__(self, parent)     if parent is None: @@ -56,8 +56,6 @@
  le = QLineEdit()   lbl.setBuddy(le)   lbl.setToolTip(_('Regular expression search pattern')) - if len(pats) >= 1: - le.setText(hglib.tounicode(pats[0]))   bt = QPushButton(_('Search'))   bt.setDefault(True)   chk = QCheckBox(_('Ignore case')) @@ -67,8 +65,6 @@
  hbox.addWidget(bt)     incle = QLineEdit() - if len(pats) > 1: - incle.setText(','.join(pats[1:]))   excle = QLineEdit()   working = QRadioButton(_('Working Copy'))   revision = QRadioButton(_('Revision')) @@ -131,13 +127,31 @@
  tv.setColumnHidden(COL_USER, True)   mainvbox.addWidget(tv)   le.returnPressed.connect(self.searchActivated) +   self.repo = repo   self.tv, self.regexple, 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 + self.singlematch, self.expand, self.eframe = singlematch, expand, frame   self.regexple.setFocus()   + if 'rev' in opts or 'all' in opts: + self.setSearch(upats[0], **opts) + elif len(upats) >= 1: + le.setText(upats[0]) + if len(upats) > 1: + incle.setText(','.join(upats[1:])) + + def setSearch(self, upattern, **opts): + self.regexple.setText(upattern) + if opts.get('all'): + self.aradio.setChecked(True) + elif opts.get('rev'): + self.ctxradio.setChecked(True) + self.revle.setText(opts['rev']) + if not self.eframe.isVisible(): + self.expand.clicked.emit(True) +   def keyPressEvent(self, event):   if event.key() == Qt.Key_Escape:   if self.thread and self.thread.isRunning(): @@ -514,4 +528,5 @@
  return self.rows[index.row()]    def run(ui, *pats, **opts): - return SearchWidget(pats) + upats = [hglib.tounicode(p) for p in pats] + return SearchWidget(upats, **opts)