Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

manifestdialog: Show a different context menu for subrepos and regular files

Currently the context menu for subrepos is empty (i.e. no context menu). The
patch has been tested with a dummy context menu and it works (i.e. it shows
the dummy context menu).

Proper subrepo context menu items will be added in a future patch.
This patch requries accessing ctx.substate each time that the context menu is
triggered. I assume that the cost should be negligible since ctx.substate must
have been populated earlier on when the file list was generated.

Changeset cc206bbbd30f

Parent a9aa45ce0381

by Angel Ezquerra

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

 
108
109
110
111
 
 
112
113
114
 
265
266
267
268
269
270
271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
273
 
274
275
276
 
 
 
 
 
 
 
 
 
277
278
279
 
108
109
110
 
111
112
113
114
115
 
266
267
268
 
 
 
 
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
 
284
285
 
 
286
287
288
289
290
291
292
293
294
295
296
297
@@ -108,7 +108,8 @@
  linkActivated = pyqtSignal(QString)   """Emitted (path) when user clicks on link"""   - contextmenu = None + filecontextmenu = None + subrepocontextmenu = None     def __init__(self, repo, rev=None, parent=None):   super(ManifestWidget, self).__init__(parent) @@ -265,15 +266,32 @@
    def menuRequest(self, point):   point = self.mapToGlobal(point) - if not self.contextmenu: - self.contextmenu = QMenu(self) - for act in ['diff', 'ldiff', 'edit', 'ledit', 'revert', - 'navigate', 'diffnavigate']: + itemissubrepo = self.path in self._repo[self._rev].substate.keys() + + # Subrepos and regular items have different context menus + if itemissubrepo: + contextmenu = self.subrepocontextmenu + actionlist = [] + else: + contextmenu = self.filecontextmenu + actionlist = ['diff', 'ldiff', 'edit', 'ledit', 'revert', + 'navigate', 'diffnavigate'] + + if not contextmenu: + contextmenu = QMenu(self) + for act in actionlist:   if act: - self.contextmenu.addAction(self._actions[act]) + contextmenu.addAction(self._actions[act])   else: - self.contextmenu.addSeparator() - self.contextmenu.exec_(point) + contextmenu.addSeparator() + + if itemissubrepo: + self.subrepocontextmenu = contextmenu + else: + self.filecontextmenu = contextmenu + + if actionlist: + contextmenu.exec_(point)     @property   def toolbar(self):