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

grep: draggable matches from history or wc

Changeset 468ccb8a17b8

Parent 412262831596

by Steve Borho

Changes to one file · Browse files at 468ccb8a17b8 Showing diff from parent 412262831596 Diff from another changeset...

 
22
23
24
25
26
27
 
28
29
30
 
203
204
205
 
206
207
208
 
216
217
218
219
 
220
221
222
 
238
239
240
241
242
243
244
245
246
247
248
249
250
251
 
 
 
 
 
 
 
252
253
254
255
256
257
 
 
 
 
 
 
 
 
 
258
259
260
 
342
343
344
 
 
 
 
345
346
 
22
23
24
 
25
 
26
27
28
29
 
202
203
204
205
206
207
208
 
216
217
218
 
219
220
221
222
 
238
239
240
 
 
 
 
 
 
 
 
 
 
241
242
243
244
245
246
247
248
249
 
 
 
 
 
250
251
252
253
254
255
256
257
258
259
260
261
 
343
344
345
346
347
348
349
350
351
@@ -22,9 +22,8 @@
   # Technical Debt  # add 'optional' entries for -c, -I, -X -# draggable matches from history  # tortoisehg.editor with line number -# smart visual diffs +# smart visual diffs (what does this mean?)  # context menu for matches    class SearchWidget(QWidget): @@ -203,6 +202,7 @@
  def run(self):   # this will eventually be: hg grep -c   hu = htmlui.htmlui() + rev = self.ctx.rev()   # searching len(ctx.manifest()) files   for wfile in self.ctx: # walk manifest   data = self.ctx[wfile].data() # load file data @@ -216,7 +216,7 @@
  pos = m.end()   if pos:   hu.write(line[pos:]) - row = [wfile, i, None, None, hu.getdata()[0]] + row = [wfile, i, rev, None, hu.getdata()[0]]   self.emit(SIGNAL('matchedRow'), row)   self.emit(SIGNAL('finished'))   @@ -238,23 +238,24 @@
  self.connect(self, SIGNAL('customContextMenuRequested(const QPoint &)'),   self.customContextMenuRequested)   - def keyPressEvent(self, event): - if event.key() == Qt.Key_D and event.modifiers() == Qt.ControlModifier: - selfiles = [] - for index in self.selectedRows(): - # TODO: record rev, prune dups - selfiles.append(self.model().getRow(index)[COL_PATH]) - visdiff.visualdiff(self.repo.ui, self.repo, selfiles, {}) - else: - return super(MatchTree, self).keyPressEvent(event) -   def dragObject(self): + snapshots = {} + for index in self.selectedRows(): + path, line, rev, user, text = self.model().getRow(index) + if rev not in snapshots: + snapshots[rev] = [path] + else: + snapshots[rev].append(path)   urls = [] - for index in self.selectedRows(): - path = self.model().getRow(index)[COL_PATH] - u = QUrl() - u.setPath('file://' + os.path.join(self.repo.root, path)) - urls.append(u) + for rev, paths in snapshots.iteritems(): + if rev is not None: + base, _ = visdiff.snapshot(self.repo, paths, self.repo[rev]) + else: + base = self.repo.root + for p in paths: + u = QUrl() + u.setPath('file://' + os.path.join(base, path)) + urls.append(u)   if urls:   d = QDrag(self)   m = QMimeData() @@ -342,5 +343,9 @@
  self.rows = []   self.endRemoveRows()   + def getRow(self, index): + assert index.isValid() + return self.rows[index.row()] +  def run(ui, *pats, **opts):   return SearchWidget()