src/eric7/Plugins/VcsPlugins/vcsMercurial/ProjectBrowserHelper.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
22 22
23 class HgProjectBrowserHelper(VcsProjectBrowserHelper): 23 class HgProjectBrowserHelper(VcsProjectBrowserHelper):
24 """ 24 """
25 Class implementing the VCS project browser helper for Mercurial. 25 Class implementing the VCS project browser helper for Mercurial.
26 """ 26 """
27 def __init__(self, vcsObject, browserObject, projectObject, 27
28 isTranslationsBrowser, parent=None, name=None): 28 def __init__(
29 self,
30 vcsObject,
31 browserObject,
32 projectObject,
33 isTranslationsBrowser,
34 parent=None,
35 name=None,
36 ):
29 """ 37 """
30 Constructor 38 Constructor
31 39
32 @param vcsObject reference to the vcs object 40 @param vcsObject reference to the vcs object
33 @param browserObject reference to the project browser object 41 @param browserObject reference to the project browser object
34 @param projectObject reference to the project object 42 @param projectObject reference to the project object
35 @param isTranslationsBrowser flag indicating, the helper is requested 43 @param isTranslationsBrowser flag indicating, the helper is requested
36 for the translations browser (this needs some special treatment) 44 for the translations browser (this needs some special treatment)
37 @param parent parent widget (QWidget) 45 @param parent parent widget (QWidget)
38 @param name name of this object (string) 46 @param name name of this object (string)
39 """ 47 """
40 VcsProjectBrowserHelper.__init__(self, vcsObject, browserObject, 48 VcsProjectBrowserHelper.__init__(
41 projectObject, isTranslationsBrowser, 49 self,
42 parent, name) 50 vcsObject,
43 51 browserObject,
52 projectObject,
53 isTranslationsBrowser,
54 parent,
55 name,
56 )
57
44 # instantiate the extensions 58 # instantiate the extensions
45 from .ShelveExtension.ProjectBrowserHelper import ( 59 from .ShelveExtension.ProjectBrowserHelper import ShelveProjectBrowserHelper
46 ShelveProjectBrowserHelper
47 )
48 from .LargefilesExtension.ProjectBrowserHelper import ( 60 from .LargefilesExtension.ProjectBrowserHelper import (
49 LargefilesProjectBrowserHelper 61 LargefilesProjectBrowserHelper,
50 ) 62 )
63
51 self.__extensions = { 64 self.__extensions = {
52 "shelve": ShelveProjectBrowserHelper( 65 "shelve": ShelveProjectBrowserHelper(
53 vcsObject, browserObject, projectObject), 66 vcsObject, browserObject, projectObject
67 ),
54 "largefiles": LargefilesProjectBrowserHelper( 68 "largefiles": LargefilesProjectBrowserHelper(
55 vcsObject, browserObject, projectObject), 69 vcsObject, browserObject, projectObject
70 ),
56 } 71 }
57 72
58 self.__extensionMenuTitles = {} 73 self.__extensionMenuTitles = {}
59 for extension in self.__extensions: 74 for extension in self.__extensions:
60 self.__extensionMenuTitles[ 75 self.__extensionMenuTitles[
61 self.__extensions[extension].menuTitle()] = extension 76 self.__extensions[extension].menuTitle()
77 ] = extension
62 self.__extensionMenus = {} 78 self.__extensionMenus = {}
63 for extension in self.__extensions: 79 for extension in self.__extensions:
64 self.__extensionMenus[extension] = ( 80 self.__extensionMenus[extension] = self.__extensions[extension].initMenus()
65 self.__extensions[extension].initMenus() 81
66 )
67
68 def __showExtensionMenu(self, key, controlled): 82 def __showExtensionMenu(self, key, controlled):
69 """ 83 """
70 Private slot showing the extensions menu. 84 Private slot showing the extensions menu.
71 85
72 @param key menu key (string, one of 'mainMenu', 'multiMenu', 86 @param key menu key (string, one of 'mainMenu', 'multiMenu',
73 'backMenu', 'dirMenu' or 'dirMultiMenu') 87 'backMenu', 'dirMenu' or 'dirMultiMenu')
74 @param controlled flag indicating to show the menu for a 88 @param controlled flag indicating to show the menu for a
75 version controlled entry or a non-version controlled entry 89 version controlled entry or a non-version controlled entry
76 (boolean) 90 (boolean)
77 """ 91 """
78 for extensionName in self.__extensionMenus: 92 for extensionName in self.__extensionMenus:
79 if key in self.__extensionMenus[extensionName]: 93 if key in self.__extensionMenus[extensionName]:
80 self.__extensionMenus[extensionName][key].setEnabled( 94 self.__extensionMenus[extensionName][key].setEnabled(
81 self.vcs.isExtensionActive(extensionName)) 95 self.vcs.isExtensionActive(extensionName)
96 )
82 if self.__extensionMenus[extensionName][key].isEnabled(): 97 if self.__extensionMenus[extensionName][key].isEnabled():
83 # adjust individual extension menu entries 98 # adjust individual extension menu entries
84 self.__extensions[extensionName].showExtensionMenu( 99 self.__extensions[extensionName].showExtensionMenu(key, controlled)
85 key, controlled) 100 if (
86 if (not self.__extensionMenus[extensionName][key] 101 not self.__extensionMenus[extensionName][key].isEnabled()
87 .isEnabled() and self.__extensionMenus[extensionName][key] 102 and self.__extensionMenus[extensionName][key].isTearOffMenuVisible()
88 .isTearOffMenuVisible()): 103 ):
89 self.__extensionMenus[extensionName][key].hideTearOffMenu() 104 self.__extensionMenus[extensionName][key].hideTearOffMenu()
90 105
91 def showContextMenu(self, menu, standardItems): 106 def showContextMenu(self, menu, standardItems):
92 """ 107 """
93 Public slot called before the context menu is shown. 108 Public slot called before the context menu is shown.
94 109
95 It enables/disables the VCS menu entries depending on the overall 110 It enables/disables the VCS menu entries depending on the overall
96 VCS status and the file status. 111 VCS status and the file status.
97 112
98 @param menu reference to the menu to be shown 113 @param menu reference to the menu to be shown
99 @param standardItems array of standard items that need 114 @param standardItems array of standard items that need
100 activation/deactivation depending on the overall VCS status 115 activation/deactivation depending on the overall VCS status
101 """ 116 """
102 if self.browser.currentItem().data(1) == self.vcs.vcsName(): 117 if self.browser.currentItem().data(1) == self.vcs.vcsName():
105 act.setEnabled(True) 120 act.setEnabled(True)
106 for act in self.vcsAddMenuActions: 121 for act in self.vcsAddMenuActions:
107 act.setEnabled(False) 122 act.setEnabled(False)
108 for act in standardItems: 123 for act in standardItems:
109 act.setEnabled(False) 124 act.setEnabled(False)
110 if not hasattr(self.browser.currentItem(), 'fileName'): 125 if not hasattr(self.browser.currentItem(), "fileName"):
111 self.annotateAct.setEnabled(False) 126 self.annotateAct.setEnabled(False)
112 else: 127 else:
113 controlled = False 128 controlled = False
114 for act in self.vcsMenuActions: 129 for act in self.vcsMenuActions:
115 act.setEnabled(False) 130 act.setEnabled(False)
116 for act in self.vcsAddMenuActions: 131 for act in self.vcsAddMenuActions:
117 act.setEnabled(True) 132 act.setEnabled(True)
118 for act in standardItems: 133 for act in standardItems:
119 act.setEnabled(True) 134 act.setEnabled(True)
120 self.__showExtensionMenu("mainMenu", controlled) 135 self.__showExtensionMenu("mainMenu", controlled)
121 136
122 def showContextMenuMulti(self, menu, standardItems): 137 def showContextMenuMulti(self, menu, standardItems):
123 """ 138 """
124 Public slot called before the context menu (multiple selections) is 139 Public slot called before the context menu (multiple selections) is
125 shown. 140 shown.
126 141
127 It enables/disables the VCS menu entries depending on the overall 142 It enables/disables the VCS menu entries depending on the overall
128 VCS status and the files status. 143 VCS status and the files status.
129 144
130 @param menu reference to the menu to be shown 145 @param menu reference to the menu to be shown
131 @param standardItems array of standard items that need 146 @param standardItems array of standard items that need
132 activation/deactivation depending on the overall VCS status 147 activation/deactivation depending on the overall VCS status
133 """ 148 """
134 vcsName = self.vcs.vcsName() 149 vcsName = self.vcs.vcsName()
136 vcsItems = 0 151 vcsItems = 0
137 # determine number of selected items under VCS control 152 # determine number of selected items under VCS control
138 for itm in items: 153 for itm in items:
139 if itm.data(1) == vcsName: 154 if itm.data(1) == vcsName:
140 vcsItems += 1 155 vcsItems += 1
141 156
142 if vcsItems > 0: 157 if vcsItems > 0:
143 controlled = True 158 controlled = True
144 if vcsItems != len(items): 159 if vcsItems != len(items):
145 for act in self.vcsMultiMenuActions: 160 for act in self.vcsMultiMenuActions:
146 act.setEnabled(False) 161 act.setEnabled(False)
158 for act in self.vcsAddMultiMenuActions: 173 for act in self.vcsAddMultiMenuActions:
159 act.setEnabled(True) 174 act.setEnabled(True)
160 for act in standardItems: 175 for act in standardItems:
161 act.setEnabled(True) 176 act.setEnabled(True)
162 self.__showExtensionMenu("multiMenu", controlled) 177 self.__showExtensionMenu("multiMenu", controlled)
163 178
164 def showContextMenuDir(self, menu, standardItems): 179 def showContextMenuDir(self, menu, standardItems):
165 """ 180 """
166 Public slot called before the context menu is shown. 181 Public slot called before the context menu is shown.
167 182
168 It enables/disables the VCS menu entries depending on the overall 183 It enables/disables the VCS menu entries depending on the overall
169 VCS status and the directory status. 184 VCS status and the directory status.
170 185
171 @param menu reference to the menu to be shown 186 @param menu reference to the menu to be shown
172 @param standardItems array of standard items that need 187 @param standardItems array of standard items that need
173 activation/deactivation depending on the overall VCS status 188 activation/deactivation depending on the overall VCS status
174 """ 189 """
175 if self.browser.currentItem().data(1) == self.vcs.vcsName(): 190 if self.browser.currentItem().data(1) == self.vcs.vcsName():
187 for act in self.vcsAddDirMenuActions: 202 for act in self.vcsAddDirMenuActions:
188 act.setEnabled(True) 203 act.setEnabled(True)
189 for act in standardItems: 204 for act in standardItems:
190 act.setEnabled(True) 205 act.setEnabled(True)
191 self.__showExtensionMenu("dirMenu", controlled) 206 self.__showExtensionMenu("dirMenu", controlled)
192 207
193 def showContextMenuDirMulti(self, menu, standardItems): 208 def showContextMenuDirMulti(self, menu, standardItems):
194 """ 209 """
195 Public slot called before the context menu is shown. 210 Public slot called before the context menu is shown.
196 211
197 It enables/disables the VCS menu entries depending on the overall 212 It enables/disables the VCS menu entries depending on the overall
198 VCS status and the directory status. 213 VCS status and the directory status.
199 214
200 @param menu reference to the menu to be shown 215 @param menu reference to the menu to be shown
201 @param standardItems array of standard items that need 216 @param standardItems array of standard items that need
202 activation/deactivation depending on the overall VCS status 217 activation/deactivation depending on the overall VCS status
203 """ 218 """
204 vcsName = self.vcs.vcsName() 219 vcsName = self.vcs.vcsName()
206 vcsItems = 0 221 vcsItems = 0
207 # determine number of selected items under VCS control 222 # determine number of selected items under VCS control
208 for itm in items: 223 for itm in items:
209 if itm.data(1) == vcsName: 224 if itm.data(1) == vcsName:
210 vcsItems += 1 225 vcsItems += 1
211 226
212 if vcsItems > 0: 227 if vcsItems > 0:
213 controlled = True 228 controlled = True
214 if vcsItems != len(items): 229 if vcsItems != len(items):
215 for act in self.vcsDirMultiMenuActions: 230 for act in self.vcsDirMultiMenuActions:
216 act.setEnabled(False) 231 act.setEnabled(False)
228 for act in self.vcsAddDirMultiMenuActions: 243 for act in self.vcsAddDirMultiMenuActions:
229 act.setEnabled(True) 244 act.setEnabled(True)
230 for act in standardItems: 245 for act in standardItems:
231 act.setEnabled(True) 246 act.setEnabled(True)
232 self.__showExtensionMenu("dirMultiMenu", controlled) 247 self.__showExtensionMenu("dirMultiMenu", controlled)
233 248
234 ########################################################################### 249 ###########################################################################
235 ## Private menu generation methods below 250 ## Private menu generation methods below
236 ########################################################################### 251 ###########################################################################
237 252
238 def __addExtensionsMenu(self, menu, key): 253 def __addExtensionsMenu(self, menu, key):
239 """ 254 """
240 Private method to add an extension menu entry. 255 Private method to add an extension menu entry.
241 256
242 @param menu menu to add it to (QMenu) 257 @param menu menu to add it to (QMenu)
243 @param key menu key (string, one of 'mainMenu', 'multiMenu', 258 @param key menu key (string, one of 'mainMenu', 'multiMenu',
244 'backMenu', 'dirMenu' or 'dirMultiMenu') 259 'backMenu', 'dirMenu' or 'dirMultiMenu')
245 @return reference to the menu action (QAction) 260 @return reference to the menu action (QAction)
246 """ 261 """
247 act = None 262 act = None
248 if key in ['mainMenu', 'multiMenu', 'backMenu', 'dirMenu', 263 if key in ["mainMenu", "multiMenu", "backMenu", "dirMenu", "dirMultiMenu"]:
249 'dirMultiMenu']:
250 extensionsMenu = QMenu(self.tr("Extensions"), menu) 264 extensionsMenu = QMenu(self.tr("Extensions"), menu)
251 extensionsMenu.setTearOffEnabled(True) 265 extensionsMenu.setTearOffEnabled(True)
252 for extensionMenuTitle in sorted(self.__extensionMenuTitles): 266 for extensionMenuTitle in sorted(self.__extensionMenuTitles):
253 extensionName = self.__extensionMenuTitles[extensionMenuTitle] 267 extensionName = self.__extensionMenuTitles[extensionMenuTitle]
254 if key in self.__extensionMenus[extensionName]: 268 if key in self.__extensionMenus[extensionName]:
255 extensionsMenu.addMenu( 269 extensionsMenu.addMenu(self.__extensionMenus[extensionName][key])
256 self.__extensionMenus[extensionName][key])
257 if not extensionsMenu.isEmpty(): 270 if not extensionsMenu.isEmpty():
258 if not menu.isEmpty(): 271 if not menu.isEmpty():
259 menu.addSeparator() 272 menu.addSeparator()
260 act = menu.addMenu(extensionsMenu) 273 act = menu.addMenu(extensionsMenu)
261 return act 274 return act
262 275
263 ########################################################################### 276 ###########################################################################
264 ## Protected menu generation methods below 277 ## Protected menu generation methods below
265 ########################################################################### 278 ###########################################################################
266 279
267 def _addVCSMenu(self, mainMenu): 280 def _addVCSMenu(self, mainMenu):
268 """ 281 """
269 Protected method used to add the VCS menu to all project browsers. 282 Protected method used to add the VCS menu to all project browsers.
270 283
271 @param mainMenu reference to the menu to be amended 284 @param mainMenu reference to the menu to be amended
272 """ 285 """
273 self.vcsMenuActions = [] 286 self.vcsMenuActions = []
274 self.vcsAddMenuActions = [] 287 self.vcsAddMenuActions = []
275 288
276 menu = QMenu(self.tr("Version Control")) 289 menu = QMenu(self.tr("Version Control"))
277 290
278 act = menu.addAction( 291 act = menu.addAction(
279 UI.PixmapCache.getIcon( 292 UI.PixmapCache.getIcon(
280 os.path.join("VcsPlugins", "vcsMercurial", "icons", 293 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg")
281 "mercurial.svg")), 294 ),
282 self.vcs.vcsName(), self._VCSInfoDisplay) 295 self.vcs.vcsName(),
296 self._VCSInfoDisplay,
297 )
283 font = act.font() 298 font = act.font()
284 font.setBold(True) 299 font.setBold(True)
285 act.setFont(font) 300 act.setFont(font)
286 menu.addSeparator() 301 menu.addSeparator()
287 302
288 act = menu.addAction( 303 act = menu.addAction(
289 UI.PixmapCache.getIcon("vcsCommit"), 304 UI.PixmapCache.getIcon("vcsCommit"),
290 self.tr('Commit changes to repository...'), 305 self.tr("Commit changes to repository..."),
291 self._VCSCommit) 306 self._VCSCommit,
292 self.vcsMenuActions.append(act) 307 )
293 self.__addExtensionsMenu(menu, 'mainMenu') 308 self.vcsMenuActions.append(act)
294 menu.addSeparator() 309 self.__addExtensionsMenu(menu, "mainMenu")
295 act = menu.addAction( 310 menu.addSeparator()
296 UI.PixmapCache.getIcon("vcsAdd"), 311 act = menu.addAction(
297 self.tr('Add to repository'), 312 UI.PixmapCache.getIcon("vcsAdd"), self.tr("Add to repository"), self._VCSAdd
298 self._VCSAdd) 313 )
299 self.vcsAddMenuActions.append(act) 314 self.vcsAddMenuActions.append(act)
300 act = menu.addAction( 315 act = menu.addAction(
301 UI.PixmapCache.getIcon("vcsRemove"), 316 UI.PixmapCache.getIcon("vcsRemove"),
302 self.tr('Remove from repository (and disk)'), 317 self.tr("Remove from repository (and disk)"),
303 self._VCSRemove) 318 self._VCSRemove,
319 )
304 self.vcsMenuActions.append(act) 320 self.vcsMenuActions.append(act)
305 act = menu.addAction( 321 act = menu.addAction(
306 UI.PixmapCache.getIcon("vcsRemove"), 322 UI.PixmapCache.getIcon("vcsRemove"),
307 self.tr('Remove from repository only'), 323 self.tr("Remove from repository only"),
308 self.__HgForget) 324 self.__HgForget,
309 self.vcsMenuActions.append(act) 325 )
310 menu.addSeparator() 326 self.vcsMenuActions.append(act)
311 act = menu.addAction(self.tr('Copy'), self.__HgCopy) 327 menu.addSeparator()
312 self.vcsMenuActions.append(act) 328 act = menu.addAction(self.tr("Copy"), self.__HgCopy)
313 act = menu.addAction(self.tr('Move'), self.__HgMove) 329 self.vcsMenuActions.append(act)
330 act = menu.addAction(self.tr("Move"), self.__HgMove)
314 self.vcsMenuActions.append(act) 331 self.vcsMenuActions.append(act)
315 menu.addSeparator() 332 menu.addSeparator()
316 act = menu.addAction( 333 act = menu.addAction(
317 UI.PixmapCache.getIcon("vcsLog"), 334 UI.PixmapCache.getIcon("vcsLog"),
318 self.tr('Show log browser'), self._VCSLogBrowser) 335 self.tr("Show log browser"),
319 self.vcsMenuActions.append(act) 336 self._VCSLogBrowser,
320 menu.addSeparator() 337 )
321 act = menu.addAction( 338 self.vcsMenuActions.append(act)
322 UI.PixmapCache.getIcon("vcsStatus"), 339 menu.addSeparator()
323 self.tr('Show status'), self._VCSStatus) 340 act = menu.addAction(
341 UI.PixmapCache.getIcon("vcsStatus"), self.tr("Show status"), self._VCSStatus
342 )
324 self.vcsMenuActions.append(act) 343 self.vcsMenuActions.append(act)
325 menu.addSeparator() 344 menu.addSeparator()
326 act = menu.addAction( 345 act = menu.addAction(
327 UI.PixmapCache.getIcon("vcsDiff"), 346 UI.PixmapCache.getIcon("vcsDiff"),
328 self.tr('Show differences'), self._VCSDiff) 347 self.tr("Show differences"),
348 self._VCSDiff,
349 )
329 self.vcsMenuActions.append(act) 350 self.vcsMenuActions.append(act)
330 act = menu.addAction( 351 act = menu.addAction(
331 UI.PixmapCache.getIcon("vcsSbsDiff"), 352 UI.PixmapCache.getIcon("vcsSbsDiff"),
332 self.tr('Show differences side-by-side'), self.__HgSbsDiff) 353 self.tr("Show differences side-by-side"),
354 self.__HgSbsDiff,
355 )
333 self.vcsMenuActions.append(act) 356 self.vcsMenuActions.append(act)
334 act = menu.addAction( 357 act = menu.addAction(
335 UI.PixmapCache.getIcon("vcsDiff"), 358 UI.PixmapCache.getIcon("vcsDiff"),
336 self.tr('Show differences (extended)'), 359 self.tr("Show differences (extended)"),
337 self.__HgExtendedDiff) 360 self.__HgExtendedDiff,
361 )
338 self.vcsMenuActions.append(act) 362 self.vcsMenuActions.append(act)
339 act = menu.addAction( 363 act = menu.addAction(
340 UI.PixmapCache.getIcon("vcsSbsDiff"), 364 UI.PixmapCache.getIcon("vcsSbsDiff"),
341 self.tr('Show differences side-by-side (extended)'), 365 self.tr("Show differences side-by-side (extended)"),
342 self.__HgSbsExtendedDiff) 366 self.__HgSbsExtendedDiff,
367 )
343 self.vcsMenuActions.append(act) 368 self.vcsMenuActions.append(act)
344 self.annotateAct = menu.addAction( 369 self.annotateAct = menu.addAction(
345 self.tr('Show annotated file'), 370 self.tr("Show annotated file"), self.__HgAnnotate
346 self.__HgAnnotate) 371 )
347 self.vcsMenuActions.append(self.annotateAct) 372 self.vcsMenuActions.append(self.annotateAct)
348 menu.addSeparator() 373 menu.addSeparator()
349 act = menu.addAction( 374 act = menu.addAction(
350 UI.PixmapCache.getIcon("vcsRevert"), 375 UI.PixmapCache.getIcon("vcsRevert"),
351 self.tr('Revert changes'), self.__HgRevert) 376 self.tr("Revert changes"),
352 self.vcsMenuActions.append(act) 377 self.__HgRevert,
353 act = menu.addAction( 378 )
354 self.tr('Conflicts resolved'), self.__HgResolved) 379 self.vcsMenuActions.append(act)
355 self.vcsMenuActions.append(act) 380 act = menu.addAction(self.tr("Conflicts resolved"), self.__HgResolved)
356 act = menu.addAction( 381 self.vcsMenuActions.append(act)
357 self.tr('Conflicts unresolved'), self.__HgUnresolved) 382 act = menu.addAction(self.tr("Conflicts unresolved"), self.__HgUnresolved)
358 self.vcsMenuActions.append(act) 383 self.vcsMenuActions.append(act)
359 act = menu.addAction( 384 act = menu.addAction(self.tr("Re-Merge"), self.__HgReMerge)
360 self.tr('Re-Merge'), self.__HgReMerge) 385 self.vcsMenuActions.append(act)
361 self.vcsMenuActions.append(act) 386 menu.addSeparator()
362 menu.addSeparator() 387 menu.addAction(
363 menu.addAction(self.tr('Select all local file entries'), 388 self.tr("Select all local file entries"), self.browser.selectLocalEntries
364 self.browser.selectLocalEntries) 389 )
365 menu.addAction(self.tr('Select all versioned file entries'), 390 menu.addAction(
366 self.browser.selectVCSEntries) 391 self.tr("Select all versioned file entries"), self.browser.selectVCSEntries
367 menu.addAction(self.tr('Select all local directory entries'), 392 )
368 self.browser.selectLocalDirEntries) 393 menu.addAction(
369 menu.addAction(self.tr('Select all versioned directory entries'), 394 self.tr("Select all local directory entries"),
370 self.browser.selectVCSDirEntries) 395 self.browser.selectLocalDirEntries,
396 )
397 menu.addAction(
398 self.tr("Select all versioned directory entries"),
399 self.browser.selectVCSDirEntries,
400 )
371 menu.addSeparator() 401 menu.addSeparator()
372 menu.addAction(self.tr("Configure..."), self.__HgConfigure) 402 menu.addAction(self.tr("Configure..."), self.__HgConfigure)
373 403
374 mainMenu.addSeparator() 404 mainMenu.addSeparator()
375 mainMenu.addMenu(menu) 405 mainMenu.addMenu(menu)
376 self.menu = menu 406 self.menu = menu
377 407
378 def _addVCSMenuMulti(self, mainMenu): 408 def _addVCSMenuMulti(self, mainMenu):
379 """ 409 """
380 Protected method used to add the VCS menu for multi selection to all 410 Protected method used to add the VCS menu for multi selection to all
381 project browsers. 411 project browsers.
382 412
383 @param mainMenu reference to the menu to be amended 413 @param mainMenu reference to the menu to be amended
384 """ 414 """
385 self.vcsMultiMenuActions = [] 415 self.vcsMultiMenuActions = []
386 self.vcsAddMultiMenuActions = [] 416 self.vcsAddMultiMenuActions = []
387 417
388 menu = QMenu(self.tr("Version Control")) 418 menu = QMenu(self.tr("Version Control"))
389 419
390 act = menu.addAction( 420 act = menu.addAction(
391 UI.PixmapCache.getIcon( 421 UI.PixmapCache.getIcon(
392 os.path.join("VcsPlugins", "vcsMercurial", "icons", 422 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg")
393 "mercurial.svg")), 423 ),
394 self.vcs.vcsName(), self._VCSInfoDisplay) 424 self.vcs.vcsName(),
425 self._VCSInfoDisplay,
426 )
395 font = act.font() 427 font = act.font()
396 font.setBold(True) 428 font.setBold(True)
397 act.setFont(font) 429 act.setFont(font)
398 menu.addSeparator() 430 menu.addSeparator()
399 431
400 act = menu.addAction( 432 act = menu.addAction(
401 UI.PixmapCache.getIcon("vcsCommit"), 433 UI.PixmapCache.getIcon("vcsCommit"),
402 self.tr('Commit changes to repository...'), 434 self.tr("Commit changes to repository..."),
403 self._VCSCommit) 435 self._VCSCommit,
436 )
404 self.vcsMultiMenuActions.append(act) 437 self.vcsMultiMenuActions.append(act)
405 self.__addExtensionsMenu(menu, 'multiMenu') 438 self.__addExtensionsMenu(menu, "multiMenu")
406 menu.addSeparator() 439 menu.addSeparator()
407 act = menu.addAction( 440 act = menu.addAction(
408 UI.PixmapCache.getIcon("vcsAdd"), 441 UI.PixmapCache.getIcon("vcsAdd"), self.tr("Add to repository"), self._VCSAdd
409 self.tr('Add to repository'), self._VCSAdd) 442 )
410 self.vcsAddMultiMenuActions.append(act) 443 self.vcsAddMultiMenuActions.append(act)
411 act = menu.addAction( 444 act = menu.addAction(
412 UI.PixmapCache.getIcon("vcsRemove"), 445 UI.PixmapCache.getIcon("vcsRemove"),
413 self.tr('Remove from repository (and disk)'), 446 self.tr("Remove from repository (and disk)"),
414 self._VCSRemove) 447 self._VCSRemove,
448 )
415 self.vcsMultiMenuActions.append(act) 449 self.vcsMultiMenuActions.append(act)
416 act = menu.addAction( 450 act = menu.addAction(
417 UI.PixmapCache.getIcon("vcsRemove"), 451 UI.PixmapCache.getIcon("vcsRemove"),
418 self.tr('Remove from repository only'), 452 self.tr("Remove from repository only"),
419 self.__HgForget) 453 self.__HgForget,
454 )
420 self.vcsMultiMenuActions.append(act) 455 self.vcsMultiMenuActions.append(act)
421 menu.addSeparator() 456 menu.addSeparator()
422 act = menu.addAction( 457 act = menu.addAction(
423 UI.PixmapCache.getIcon("vcsStatus"), 458 UI.PixmapCache.getIcon("vcsStatus"), self.tr("Show status"), self._VCSStatus
424 self.tr('Show status'), self._VCSStatus) 459 )
425 self.vcsMultiMenuActions.append(act) 460 self.vcsMultiMenuActions.append(act)
426 menu.addSeparator() 461 menu.addSeparator()
427 act = menu.addAction( 462 act = menu.addAction(
428 UI.PixmapCache.getIcon("vcsDiff"), 463 UI.PixmapCache.getIcon("vcsDiff"),
429 self.tr('Show differences'), self._VCSDiff) 464 self.tr("Show differences"),
465 self._VCSDiff,
466 )
430 self.vcsMultiMenuActions.append(act) 467 self.vcsMultiMenuActions.append(act)
431 act = menu.addAction( 468 act = menu.addAction(
432 UI.PixmapCache.getIcon("vcsDiff"), 469 UI.PixmapCache.getIcon("vcsDiff"),
433 self.tr('Show differences (extended)'), 470 self.tr("Show differences (extended)"),
434 self.__HgExtendedDiff) 471 self.__HgExtendedDiff,
472 )
435 self.vcsMultiMenuActions.append(act) 473 self.vcsMultiMenuActions.append(act)
436 menu.addSeparator() 474 menu.addSeparator()
437 act = menu.addAction( 475 act = menu.addAction(
438 UI.PixmapCache.getIcon("vcsRevert"), 476 UI.PixmapCache.getIcon("vcsRevert"),
439 self.tr('Revert changes'), self.__HgRevert) 477 self.tr("Revert changes"),
478 self.__HgRevert,
479 )
440 self.vcsMultiMenuActions.append(act) 480 self.vcsMultiMenuActions.append(act)
441 act = menu.addAction( 481 act = menu.addAction(self.tr("Conflicts resolved"), self.__HgResolved)
442 self.tr('Conflicts resolved'), self.__HgResolved)
443 self.vcsMultiMenuActions.append(act) 482 self.vcsMultiMenuActions.append(act)
444 act = menu.addAction( 483 act = menu.addAction(self.tr("Conflicts unresolved"), self.__HgUnresolved)
445 self.tr('Conflicts unresolved'), self.__HgUnresolved)
446 self.vcsMultiMenuActions.append(act) 484 self.vcsMultiMenuActions.append(act)
447 act = menu.addAction( 485 act = menu.addAction(self.tr("Re-Merge"), self.__HgReMerge)
448 self.tr('Re-Merge'), self.__HgReMerge)
449 self.vcsMultiMenuActions.append(act) 486 self.vcsMultiMenuActions.append(act)
450 menu.addSeparator() 487 menu.addSeparator()
451 menu.addAction(self.tr('Select all local file entries'), 488 menu.addAction(
452 self.browser.selectLocalEntries) 489 self.tr("Select all local file entries"), self.browser.selectLocalEntries
453 menu.addAction(self.tr('Select all versioned file entries'), 490 )
454 self.browser.selectVCSEntries) 491 menu.addAction(
455 menu.addAction(self.tr('Select all local directory entries'), 492 self.tr("Select all versioned file entries"), self.browser.selectVCSEntries
456 self.browser.selectLocalDirEntries) 493 )
457 menu.addAction(self.tr('Select all versioned directory entries'), 494 menu.addAction(
458 self.browser.selectVCSDirEntries) 495 self.tr("Select all local directory entries"),
496 self.browser.selectLocalDirEntries,
497 )
498 menu.addAction(
499 self.tr("Select all versioned directory entries"),
500 self.browser.selectVCSDirEntries,
501 )
459 menu.addSeparator() 502 menu.addSeparator()
460 menu.addAction(self.tr("Configure..."), self.__HgConfigure) 503 menu.addAction(self.tr("Configure..."), self.__HgConfigure)
461 504
462 mainMenu.addSeparator() 505 mainMenu.addSeparator()
463 mainMenu.addMenu(menu) 506 mainMenu.addMenu(menu)
464 self.menuMulti = menu 507 self.menuMulti = menu
465 508
466 def _addVCSMenuBack(self, mainMenu): 509 def _addVCSMenuBack(self, mainMenu):
467 """ 510 """
468 Protected method used to add the VCS menu to all project browsers. 511 Protected method used to add the VCS menu to all project browsers.
469 512
470 @param mainMenu reference to the menu to be amended 513 @param mainMenu reference to the menu to be amended
471 """ 514 """
472 menu = QMenu(self.tr("Version Control")) 515 menu = QMenu(self.tr("Version Control"))
473 516
474 act = menu.addAction( 517 act = menu.addAction(
475 UI.PixmapCache.getIcon( 518 UI.PixmapCache.getIcon(
476 os.path.join("VcsPlugins", "vcsMercurial", "icons", 519 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg")
477 "mercurial.svg")), 520 ),
478 self.vcs.vcsName(), self._VCSInfoDisplay) 521 self.vcs.vcsName(),
522 self._VCSInfoDisplay,
523 )
479 font = act.font() 524 font = act.font()
480 font.setBold(True) 525 font.setBold(True)
481 act.setFont(font) 526 act.setFont(font)
482 menu.addSeparator() 527 menu.addSeparator()
483 528
484 menu.addAction(self.tr('Select all local file entries'), 529 menu.addAction(
485 self.browser.selectLocalEntries) 530 self.tr("Select all local file entries"), self.browser.selectLocalEntries
486 menu.addAction(self.tr('Select all versioned file entries'), 531 )
487 self.browser.selectVCSEntries) 532 menu.addAction(
488 menu.addAction(self.tr('Select all local directory entries'), 533 self.tr("Select all versioned file entries"), self.browser.selectVCSEntries
489 self.browser.selectLocalDirEntries) 534 )
490 menu.addAction(self.tr('Select all versioned directory entries'), 535 menu.addAction(
491 self.browser.selectVCSDirEntries) 536 self.tr("Select all local directory entries"),
537 self.browser.selectLocalDirEntries,
538 )
539 menu.addAction(
540 self.tr("Select all versioned directory entries"),
541 self.browser.selectVCSDirEntries,
542 )
492 menu.addSeparator() 543 menu.addSeparator()
493 menu.addAction(self.tr("Configure..."), self.__HgConfigure) 544 menu.addAction(self.tr("Configure..."), self.__HgConfigure)
494 545
495 mainMenu.addSeparator() 546 mainMenu.addSeparator()
496 mainMenu.addMenu(menu) 547 mainMenu.addMenu(menu)
497 self.menuBack = menu 548 self.menuBack = menu
498 549
499 def _addVCSMenuDir(self, mainMenu): 550 def _addVCSMenuDir(self, mainMenu):
500 """ 551 """
501 Protected method used to add the VCS menu to all project browsers. 552 Protected method used to add the VCS menu to all project browsers.
502 553
503 @param mainMenu reference to the menu to be amended 554 @param mainMenu reference to the menu to be amended
504 """ 555 """
505 if mainMenu is None: 556 if mainMenu is None:
506 return 557 return
507 558
508 self.vcsDirMenuActions = [] 559 self.vcsDirMenuActions = []
509 self.vcsAddDirMenuActions = [] 560 self.vcsAddDirMenuActions = []
510 561
511 menu = QMenu(self.tr("Version Control")) 562 menu = QMenu(self.tr("Version Control"))
512 563
513 act = menu.addAction( 564 act = menu.addAction(
514 UI.PixmapCache.getIcon( 565 UI.PixmapCache.getIcon(
515 os.path.join("VcsPlugins", "vcsMercurial", "icons", 566 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg")
516 "mercurial.svg")), 567 ),
517 self.vcs.vcsName(), self._VCSInfoDisplay) 568 self.vcs.vcsName(),
569 self._VCSInfoDisplay,
570 )
518 font = act.font() 571 font = act.font()
519 font.setBold(True) 572 font.setBold(True)
520 act.setFont(font) 573 act.setFont(font)
521 menu.addSeparator() 574 menu.addSeparator()
522 575
523 act = menu.addAction( 576 act = menu.addAction(
524 UI.PixmapCache.getIcon("vcsCommit"), 577 UI.PixmapCache.getIcon("vcsCommit"),
525 self.tr('Commit changes to repository...'), 578 self.tr("Commit changes to repository..."),
526 self._VCSCommit) 579 self._VCSCommit,
527 self.vcsDirMenuActions.append(act) 580 )
528 self.__addExtensionsMenu(menu, 'dirMenu') 581 self.vcsDirMenuActions.append(act)
529 menu.addSeparator() 582 self.__addExtensionsMenu(menu, "dirMenu")
530 act = menu.addAction( 583 menu.addSeparator()
531 UI.PixmapCache.getIcon("vcsAdd"), 584 act = menu.addAction(
532 self.tr('Add to repository'), self._VCSAdd) 585 UI.PixmapCache.getIcon("vcsAdd"), self.tr("Add to repository"), self._VCSAdd
586 )
533 self.vcsAddDirMenuActions.append(act) 587 self.vcsAddDirMenuActions.append(act)
534 act = menu.addAction( 588 act = menu.addAction(
535 UI.PixmapCache.getIcon("vcsRemove"), 589 UI.PixmapCache.getIcon("vcsRemove"),
536 self.tr('Remove from repository (and disk)'), 590 self.tr("Remove from repository (and disk)"),
537 self._VCSRemove) 591 self._VCSRemove,
538 self.vcsDirMenuActions.append(act) 592 )
539 menu.addSeparator() 593 self.vcsDirMenuActions.append(act)
540 act = menu.addAction(self.tr('Copy'), self.__HgCopy) 594 menu.addSeparator()
541 self.vcsDirMenuActions.append(act) 595 act = menu.addAction(self.tr("Copy"), self.__HgCopy)
542 act = menu.addAction(self.tr('Move'), self.__HgMove) 596 self.vcsDirMenuActions.append(act)
597 act = menu.addAction(self.tr("Move"), self.__HgMove)
543 self.vcsDirMenuActions.append(act) 598 self.vcsDirMenuActions.append(act)
544 menu.addSeparator() 599 menu.addSeparator()
545 act = menu.addAction( 600 act = menu.addAction(
546 UI.PixmapCache.getIcon("vcsLog"), 601 UI.PixmapCache.getIcon("vcsLog"),
547 self.tr('Show log browser'), self._VCSLogBrowser) 602 self.tr("Show log browser"),
548 self.vcsDirMenuActions.append(act) 603 self._VCSLogBrowser,
549 menu.addSeparator() 604 )
550 act = menu.addAction( 605 self.vcsDirMenuActions.append(act)
551 UI.PixmapCache.getIcon("vcsStatus"), 606 menu.addSeparator()
552 self.tr('Show status'), self._VCSStatus) 607 act = menu.addAction(
608 UI.PixmapCache.getIcon("vcsStatus"), self.tr("Show status"), self._VCSStatus
609 )
553 self.vcsDirMenuActions.append(act) 610 self.vcsDirMenuActions.append(act)
554 menu.addSeparator() 611 menu.addSeparator()
555 act = menu.addAction( 612 act = menu.addAction(
556 UI.PixmapCache.getIcon("vcsDiff"), 613 UI.PixmapCache.getIcon("vcsDiff"),
557 self.tr('Show differences'), self._VCSDiff) 614 self.tr("Show differences"),
615 self._VCSDiff,
616 )
558 self.vcsDirMenuActions.append(act) 617 self.vcsDirMenuActions.append(act)
559 act = menu.addAction( 618 act = menu.addAction(
560 UI.PixmapCache.getIcon("vcsDiff"), 619 UI.PixmapCache.getIcon("vcsDiff"),
561 self.tr('Show differences (extended)'), 620 self.tr("Show differences (extended)"),
562 self.__HgExtendedDiff) 621 self.__HgExtendedDiff,
622 )
563 self.vcsDirMenuActions.append(act) 623 self.vcsDirMenuActions.append(act)
564 menu.addSeparator() 624 menu.addSeparator()
565 act = menu.addAction( 625 act = menu.addAction(
566 UI.PixmapCache.getIcon("vcsRevert"), 626 UI.PixmapCache.getIcon("vcsRevert"),
567 self.tr('Revert changes'), self.__HgRevert) 627 self.tr("Revert changes"),
568 self.vcsDirMenuActions.append(act) 628 self.__HgRevert,
569 act = menu.addAction( 629 )
570 self.tr('Conflicts resolved'), self.__HgResolved) 630 self.vcsDirMenuActions.append(act)
571 self.vcsDirMenuActions.append(act) 631 act = menu.addAction(self.tr("Conflicts resolved"), self.__HgResolved)
572 act = menu.addAction( 632 self.vcsDirMenuActions.append(act)
573 self.tr('Conflicts unresolved'), self.__HgUnresolved) 633 act = menu.addAction(self.tr("Conflicts unresolved"), self.__HgUnresolved)
574 self.vcsDirMenuActions.append(act) 634 self.vcsDirMenuActions.append(act)
575 act = menu.addAction( 635 act = menu.addAction(self.tr("Re-Merge"), self.__HgReMerge)
576 self.tr('Re-Merge'), self.__HgReMerge) 636 self.vcsDirMenuActions.append(act)
577 self.vcsDirMenuActions.append(act) 637 menu.addSeparator()
578 menu.addSeparator() 638 menu.addAction(
579 menu.addAction(self.tr('Select all local file entries'), 639 self.tr("Select all local file entries"), self.browser.selectLocalEntries
580 self.browser.selectLocalEntries) 640 )
581 menu.addAction(self.tr('Select all versioned file entries'), 641 menu.addAction(
582 self.browser.selectVCSEntries) 642 self.tr("Select all versioned file entries"), self.browser.selectVCSEntries
583 menu.addAction(self.tr('Select all local directory entries'), 643 )
584 self.browser.selectLocalDirEntries) 644 menu.addAction(
585 menu.addAction(self.tr('Select all versioned directory entries'), 645 self.tr("Select all local directory entries"),
586 self.browser.selectVCSDirEntries) 646 self.browser.selectLocalDirEntries,
647 )
648 menu.addAction(
649 self.tr("Select all versioned directory entries"),
650 self.browser.selectVCSDirEntries,
651 )
587 menu.addSeparator() 652 menu.addSeparator()
588 menu.addAction(self.tr("Configure..."), self.__HgConfigure) 653 menu.addAction(self.tr("Configure..."), self.__HgConfigure)
589 654
590 mainMenu.addSeparator() 655 mainMenu.addSeparator()
591 mainMenu.addMenu(menu) 656 mainMenu.addMenu(menu)
592 self.menuDir = menu 657 self.menuDir = menu
593 658
594 def _addVCSMenuDirMulti(self, mainMenu): 659 def _addVCSMenuDirMulti(self, mainMenu):
595 """ 660 """
596 Protected method used to add the VCS menu to all project browsers. 661 Protected method used to add the VCS menu to all project browsers.
597 662
598 @param mainMenu reference to the menu to be amended 663 @param mainMenu reference to the menu to be amended
599 """ 664 """
600 if mainMenu is None: 665 if mainMenu is None:
601 return 666 return
602 667
603 self.vcsDirMultiMenuActions = [] 668 self.vcsDirMultiMenuActions = []
604 self.vcsAddDirMultiMenuActions = [] 669 self.vcsAddDirMultiMenuActions = []
605 670
606 menu = QMenu(self.tr("Version Control")) 671 menu = QMenu(self.tr("Version Control"))
607 672
608 act = menu.addAction( 673 act = menu.addAction(
609 UI.PixmapCache.getIcon( 674 UI.PixmapCache.getIcon(
610 os.path.join("VcsPlugins", "vcsMercurial", "icons", 675 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg")
611 "mercurial.svg")), 676 ),
612 self.vcs.vcsName(), self._VCSInfoDisplay) 677 self.vcs.vcsName(),
678 self._VCSInfoDisplay,
679 )
613 font = act.font() 680 font = act.font()
614 font.setBold(True) 681 font.setBold(True)
615 act.setFont(font) 682 act.setFont(font)
616 menu.addSeparator() 683 menu.addSeparator()
617 684
618 act = menu.addAction( 685 act = menu.addAction(
619 UI.PixmapCache.getIcon("vcsCommit"), 686 UI.PixmapCache.getIcon("vcsCommit"),
620 self.tr('Commit changes to repository...'), 687 self.tr("Commit changes to repository..."),
621 self._VCSCommit) 688 self._VCSCommit,
689 )
622 self.vcsDirMultiMenuActions.append(act) 690 self.vcsDirMultiMenuActions.append(act)
623 self.__addExtensionsMenu(menu, 'dirMultiMenu') 691 self.__addExtensionsMenu(menu, "dirMultiMenu")
624 menu.addSeparator() 692 menu.addSeparator()
625 act = menu.addAction( 693 act = menu.addAction(
626 UI.PixmapCache.getIcon("vcsAdd"), 694 UI.PixmapCache.getIcon("vcsAdd"), self.tr("Add to repository"), self._VCSAdd
627 self.tr('Add to repository'), self._VCSAdd) 695 )
628 self.vcsAddDirMultiMenuActions.append(act) 696 self.vcsAddDirMultiMenuActions.append(act)
629 act = menu.addAction( 697 act = menu.addAction(
630 UI.PixmapCache.getIcon("vcsRemove"), 698 UI.PixmapCache.getIcon("vcsRemove"),
631 self.tr('Remove from repository (and disk)'), 699 self.tr("Remove from repository (and disk)"),
632 self._VCSRemove) 700 self._VCSRemove,
701 )
633 self.vcsDirMultiMenuActions.append(act) 702 self.vcsDirMultiMenuActions.append(act)
634 menu.addSeparator() 703 menu.addSeparator()
635 act = menu.addAction( 704 act = menu.addAction(
636 UI.PixmapCache.getIcon("vcsStatus"), 705 UI.PixmapCache.getIcon("vcsStatus"), self.tr("Show status"), self._VCSStatus
637 self.tr('Show status'), self._VCSStatus) 706 )
638 self.vcsDirMultiMenuActions.append(act) 707 self.vcsDirMultiMenuActions.append(act)
639 menu.addSeparator() 708 menu.addSeparator()
640 act = menu.addAction( 709 act = menu.addAction(
641 UI.PixmapCache.getIcon("vcsDiff"), 710 UI.PixmapCache.getIcon("vcsDiff"),
642 self.tr('Show differences'), self._VCSDiff) 711 self.tr("Show differences"),
712 self._VCSDiff,
713 )
643 self.vcsDirMultiMenuActions.append(act) 714 self.vcsDirMultiMenuActions.append(act)
644 act = menu.addAction( 715 act = menu.addAction(
645 UI.PixmapCache.getIcon("vcsDiff"), 716 UI.PixmapCache.getIcon("vcsDiff"),
646 self.tr('Show differences (extended)'), 717 self.tr("Show differences (extended)"),
647 self.__HgExtendedDiff) 718 self.__HgExtendedDiff,
719 )
648 self.vcsDirMultiMenuActions.append(act) 720 self.vcsDirMultiMenuActions.append(act)
649 menu.addSeparator() 721 menu.addSeparator()
650 act = menu.addAction( 722 act = menu.addAction(
651 UI.PixmapCache.getIcon("vcsRevert"), 723 UI.PixmapCache.getIcon("vcsRevert"),
652 self.tr('Revert changes'), self.__HgRevert) 724 self.tr("Revert changes"),
725 self.__HgRevert,
726 )
653 self.vcsDirMultiMenuActions.append(act) 727 self.vcsDirMultiMenuActions.append(act)
654 act = menu.addAction( 728 act = menu.addAction(self.tr("Conflicts resolved"), self.__HgResolved)
655 self.tr('Conflicts resolved'), self.__HgResolved)
656 self.vcsDirMultiMenuActions.append(act) 729 self.vcsDirMultiMenuActions.append(act)
657 act = menu.addAction( 730 act = menu.addAction(self.tr("Conflicts unresolved"), self.__HgUnresolved)
658 self.tr('Conflicts unresolved'), self.__HgUnresolved)
659 self.vcsDirMultiMenuActions.append(act) 731 self.vcsDirMultiMenuActions.append(act)
660 act = menu.addAction( 732 act = menu.addAction(self.tr("Re-Merge"), self.__HgReMerge)
661 self.tr('Re-Merge'), self.__HgReMerge)
662 self.vcsDirMultiMenuActions.append(act) 733 self.vcsDirMultiMenuActions.append(act)
663 menu.addSeparator() 734 menu.addSeparator()
664 menu.addAction(self.tr('Select all local file entries'), 735 menu.addAction(
665 self.browser.selectLocalEntries) 736 self.tr("Select all local file entries"), self.browser.selectLocalEntries
666 menu.addAction(self.tr('Select all versioned file entries'), 737 )
667 self.browser.selectVCSEntries) 738 menu.addAction(
668 menu.addAction(self.tr('Select all local directory entries'), 739 self.tr("Select all versioned file entries"), self.browser.selectVCSEntries
669 self.browser.selectLocalDirEntries) 740 )
670 menu.addAction(self.tr('Select all versioned directory entries'), 741 menu.addAction(
671 self.browser.selectVCSDirEntries) 742 self.tr("Select all local directory entries"),
743 self.browser.selectLocalDirEntries,
744 )
745 menu.addAction(
746 self.tr("Select all versioned directory entries"),
747 self.browser.selectVCSDirEntries,
748 )
672 menu.addSeparator() 749 menu.addSeparator()
673 menu.addAction(self.tr("Configure..."), self.__HgConfigure) 750 menu.addAction(self.tr("Configure..."), self.__HgConfigure)
674 751
675 mainMenu.addSeparator() 752 mainMenu.addSeparator()
676 mainMenu.addMenu(menu) 753 mainMenu.addMenu(menu)
677 self.menuDirMulti = menu 754 self.menuDirMulti = menu
678 755
679 ########################################################################### 756 ###########################################################################
680 ## Menu handling methods below 757 ## Menu handling methods below
681 ########################################################################### 758 ###########################################################################
682 759
683 def __HgRevert(self): 760 def __HgRevert(self):
684 """ 761 """
685 Private slot called by the context menu to revert changes made. 762 Private slot called by the context menu to revert changes made.
686 """ 763 """
687 names = [] 764 names = []
690 name = itm.fileName() 767 name = itm.fileName()
691 except AttributeError: 768 except AttributeError:
692 name = itm.dirName() 769 name = itm.dirName()
693 names.append(name) 770 names.append(name)
694 self.vcs.vcsRevert(names) 771 self.vcs.vcsRevert(names)
695 772
696 def __HgCopy(self): 773 def __HgCopy(self):
697 """ 774 """
698 Private slot called by the context menu to copy the selected file. 775 Private slot called by the context menu to copy the selected file.
699 """ 776 """
700 itm = self.browser.currentItem() 777 itm = self.browser.currentItem()
701 try: 778 try:
702 fn = itm.fileName() 779 fn = itm.fileName()
703 except AttributeError: 780 except AttributeError:
704 fn = itm.dirName() 781 fn = itm.dirName()
705 self.vcs.hgCopy(fn, self.project) 782 self.vcs.hgCopy(fn, self.project)
706 783
707 def __HgMove(self): 784 def __HgMove(self):
708 """ 785 """
709 Private slot called by the context menu to move the selected file. 786 Private slot called by the context menu to move the selected file.
710 """ 787 """
711 itm = self.browser.currentItem() 788 itm = self.browser.currentItem()
721 self.browser.closeSourceWindow.emit(fn) 798 self.browser.closeSourceWindow.emit(fn)
722 else: 799 else:
723 for mf in movefiles: 800 for mf in movefiles:
724 self.browser.closeSourceWindow.emit(mf) 801 self.browser.closeSourceWindow.emit(mf)
725 self.browser.project.startFileSystemMonitoring() 802 self.browser.project.startFileSystemMonitoring()
726 803
727 def __HgExtendedDiff(self): 804 def __HgExtendedDiff(self):
728 """ 805 """
729 Private slot called by the context menu to show the difference of a 806 Private slot called by the context menu to show the difference of a
730 file to the repository. 807 file to the repository.
731 808
732 This gives the chance to enter the revisions to compare. 809 This gives the chance to enter the revisions to compare.
733 """ 810 """
734 names = [] 811 names = []
735 for itm in self.browser.getSelectedItems(): 812 for itm in self.browser.getSelectedItems():
736 try: 813 try:
737 names.append(itm.fileName()) 814 names.append(itm.fileName())
738 except AttributeError: 815 except AttributeError:
739 names.append(itm.dirName()) 816 names.append(itm.dirName())
740 self.vcs.hgExtendedDiff(names) 817 self.vcs.hgExtendedDiff(names)
741 818
742 def __HgSbsDiff(self): 819 def __HgSbsDiff(self):
743 """ 820 """
744 Private slot called by the context menu to show the difference of a 821 Private slot called by the context menu to show the difference of a
745 file to the repository side-by-side. 822 file to the repository side-by-side.
746 """ 823 """
747 itm = self.browser.currentItem() 824 itm = self.browser.currentItem()
748 fn = itm.fileName() 825 fn = itm.fileName()
749 self.vcs.vcsSbsDiff(fn) 826 self.vcs.vcsSbsDiff(fn)
750 827
751 def __HgSbsExtendedDiff(self): 828 def __HgSbsExtendedDiff(self):
752 """ 829 """
753 Private slot called by the context menu to show the difference of a 830 Private slot called by the context menu to show the difference of a
754 file to the repository side-by-side. 831 file to the repository side-by-side.
755 832
756 It allows the selection of revisions to compare. 833 It allows the selection of revisions to compare.
757 """ 834 """
758 itm = self.browser.currentItem() 835 itm = self.browser.currentItem()
759 fn = itm.fileName() 836 fn = itm.fileName()
760 self.vcs.vcsSbsDiff(fn, extended=True) 837 self.vcs.vcsSbsDiff(fn, extended=True)
761 838
762 def __HgAnnotate(self): 839 def __HgAnnotate(self):
763 """ 840 """
764 Private slot called by the context menu to show the annotations of a 841 Private slot called by the context menu to show the annotations of a
765 file. 842 file.
766 """ 843 """
767 itm = self.browser.currentItem() 844 itm = self.browser.currentItem()
768 fn = itm.fileName() 845 fn = itm.fileName()
769 self.vcs.hgAnnotate(fn) 846 self.vcs.hgAnnotate(fn)
770 847
771 def __HgResolved(self): 848 def __HgResolved(self):
772 """ 849 """
773 Private slot called by the context menu to mark conflicts of a file 850 Private slot called by the context menu to mark conflicts of a file
774 as being resolved. 851 as being resolved.
775 """ 852 """
778 try: 855 try:
779 names.append(itm.fileName()) 856 names.append(itm.fileName())
780 except AttributeError: 857 except AttributeError:
781 names.append(itm.dirName()) 858 names.append(itm.dirName())
782 self.vcs.vcsResolved(names) 859 self.vcs.vcsResolved(names)
783 860
784 def __HgUnresolved(self): 861 def __HgUnresolved(self):
785 """ 862 """
786 Private slot called by the context menu to mark conflicts of a file 863 Private slot called by the context menu to mark conflicts of a file
787 as being unresolved. 864 as being unresolved.
788 """ 865 """
791 try: 868 try:
792 names.append(itm.fileName()) 869 names.append(itm.fileName())
793 except AttributeError: 870 except AttributeError:
794 names.append(itm.dirName()) 871 names.append(itm.dirName())
795 self.vcs.vcsResolved(names, unresolve=True) 872 self.vcs.vcsResolved(names, unresolve=True)
796 873
797 def __HgReMerge(self): 874 def __HgReMerge(self):
798 """ 875 """
799 Private slot called by the context menu to re-merge a file. 876 Private slot called by the context menu to re-merge a file.
800 """ 877 """
801 names = [] 878 names = []
803 try: 880 try:
804 names.append(itm.fileName()) 881 names.append(itm.fileName())
805 except AttributeError: 882 except AttributeError:
806 names.append(itm.dirName()) 883 names.append(itm.dirName())
807 self.vcs.hgReMerge(names) 884 self.vcs.hgReMerge(names)
808 885
809 def __HgForget(self): 886 def __HgForget(self):
810 """ 887 """
811 Private slot called by the context menu to remove the selected file 888 Private slot called by the context menu to remove the selected file
812 from the Mercurial repository leaving a copy in the project directory. 889 from the Mercurial repository leaving a copy in the project directory.
813 """ 890 """
814 from UI.DeleteFilesConfirmationDialog import ( 891 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog
815 DeleteFilesConfirmationDialog 892
816 )
817 if self.isTranslationsBrowser: 893 if self.isTranslationsBrowser:
818 items = self.browser.getSelectedItems([ProjectBrowserFileItem]) 894 items = self.browser.getSelectedItems([ProjectBrowserFileItem])
819 names = [itm.fileName() for itm in items] 895 names = [itm.fileName() for itm in items]
820 896
821 dlg = DeleteFilesConfirmationDialog( 897 dlg = DeleteFilesConfirmationDialog(
822 self.parent(), 898 self.parent(),
823 self.tr("Remove from repository only"), 899 self.tr("Remove from repository only"),
824 self.tr( 900 self.tr(
825 "Do you really want to remove these files" 901 "Do you really want to remove these files" " from the repository?"
826 " from the repository?"), 902 ),
827 names) 903 names,
904 )
828 else: 905 else:
829 items = self.browser.getSelectedItems() 906 items = self.browser.getSelectedItems()
830 names = [itm.fileName() for itm in items] 907 names = [itm.fileName() for itm in items]
831 files = [self.browser.project.getRelativePath(name) 908 files = [self.browser.project.getRelativePath(name) for name in names]
832 for name in names] 909
833
834 dlg = DeleteFilesConfirmationDialog( 910 dlg = DeleteFilesConfirmationDialog(
835 self.parent(), 911 self.parent(),
836 self.tr("Remove from repository only"), 912 self.tr("Remove from repository only"),
837 self.tr( 913 self.tr(
838 "Do you really want to remove these files" 914 "Do you really want to remove these files" " from the repository?"
839 " from the repository?"), 915 ),
840 files) 916 files,
841 917 )
918
842 if dlg.exec() == QDialog.DialogCode.Accepted: 919 if dlg.exec() == QDialog.DialogCode.Accepted:
843 self.vcs.vcsForget(names) 920 self.vcs.vcsForget(names)
844 921
845 for fn in names: 922 for fn in names:
846 self._updateVCSStatus(fn) 923 self._updateVCSStatus(fn)
847 924
848 def __HgConfigure(self): 925 def __HgConfigure(self):
849 """ 926 """
850 Private method to open the configuration dialog. 927 Private method to open the configuration dialog.
851 """ 928 """
852 ericApp().getObject("UserInterface").showPreferences( 929 ericApp().getObject("UserInterface").showPreferences("zzz_mercurialPage")
853 "zzz_mercurialPage")

eric ide

mercurial