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 context menus, only half of which can be implemented today

Changeset d70a733d35f5

Parent b2fa3b71bf21

by Steve Borho

Changes to one file · Browse files at d70a733d35f5 Showing diff from parent b2fa3b71bf21 Diff from another changeset...

 
22
23
24
25
26
27
28
29
 
374
375
376
 
 
377
378
 
 
 
 
379
 
 
380
381
382
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
385
386
 
22
23
24
 
 
25
26
27
 
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
 
 
 
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
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
@@ -22,8 +22,6 @@
   # Technical Debt  # tortoisehg.editor with line number -# smart visual diffs (what does this mean?) -# context menu for matches (view file, annotate file)    class SearchWidget(QDockWidget):   '''Working copy and repository search widget @@ -374,13 +372,65 @@
    def customContextMenuRequested(self, point):   selrows = [] + wctxonly = True + allhistory = False   for index in self.selectedRows():   path, line, rev, user, text = self.model().getRow(index) + if rev is not None: + wctxonly = False + if user is not None: + allhistory = True   selrows.append((rev, path, line)) + if not selrows: + return   point = self.mapToGlobal(point) - #action = wctxactions.wctxactions(self, point, self.repo, selrows) - #if action: - # self.emit(SIGNAL('menuAction()')) + menus = [(_('View file'), self.view), (_('Annotate file'), self.ann)] + if not wctxonly: + menus.append((_('View Changeset'), self.ctx)) + if allhistory: + # need to know files were modified at specified revision + menus.append((_('Visual Diff'), self.vdiff)) + menu = QMenu(self) + for name, func in menus: + action = menu.addAction(name) + action.wrapper = lambda f=func: f(selrows) + self.connect(action, SIGNAL('triggered()'), action.wrapper) + menu.exec_(point) + + def ann(self, rows): + raise NotImplementedError() + def ctx(self, rows): + raise NotImplementedError() + + def view(self, rows): + from tortoisehg.hgqt import wctxactions + repo, ui = self.repo, self.repo.ui + for rev, path, line in rows: + path = hglib.fromunicode(path) + # TODO: do something with 'line' + if rev is None: + files = [repo.wjoin(path)] + wctxactions.edit(self, ui, repo, files) + else: + base, _ = visdiff.snapshot(repo, [path], repo[rev]) + files = [os.path.join(base, path)] + wctxactions.edit(self, ui, repo, files) + + def vdiff(self, rows): + repo, ui = self.repo, self.repo.ui + while rows: + defer = [] + crev = rows[0][0] + files = [rows[0][1]] + for rev, path, line in rows[1:]: + if rev == crev: + files.append(path) + else: + defer.append([rev, path, line]) + if crev is not None: + files = [hglib.fromunicode(f) for f in files] + visdiff.visualdiff(ui, repo, files, {'change':crev}) + rows = defer     def selectedRows(self):   return self.selectionModel().selectedRows()