Changeset 468ccb8a17b8…
Parent 412262831596…
by
Changes to one file · Browse files at 468ccb8a17b8 Showing diff from parent 412262831596 Diff from another changeset...
@@ -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()
|
Loading...