src/eric7/Plugins/VcsPlugins/vcsGit/ProjectHelper.py

branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9412:45e7bb09c120 9413:80c06d472826
10 import os 10 import os
11 import pathlib 11 import pathlib
12 12
13 from PyQt6.QtWidgets import QMenu, QInputDialog, QToolBar 13 from PyQt6.QtWidgets import QMenu, QInputDialog, QToolBar
14 14
15 from EricWidgets import EricMessageBox 15 from eric7.EricWidgets import EricMessageBox
16 from EricWidgets.EricApplication import ericApp 16 from eric7.EricWidgets.EricApplication import ericApp
17 17
18 from VCS.ProjectHelper import VcsProjectHelper 18 from eric7.VCS.ProjectHelper import VcsProjectHelper
19 19
20 from EricGui.EricAction import EricAction 20 from eric7.EricGui.EricAction import EricAction
21 21
22 import UI.PixmapCache 22 from eric7.EricGui import EricPixmapCache
23 from eric7.UI import Config
23 24
24 25
25 class GitProjectHelper(VcsProjectHelper): 26 class GitProjectHelper(VcsProjectHelper):
26 """ 27 """
27 Class implementing the VCS project helper for Git. 28 Class implementing the VCS project helper for Git.
69 """ 70 """
70 Public method to generate the action objects. 71 Public method to generate the action objects.
71 """ 72 """
72 self.vcsNewAct = EricAction( 73 self.vcsNewAct = EricAction(
73 self.tr("New from repository"), 74 self.tr("New from repository"),
74 UI.PixmapCache.getIcon("vcsCheckout"), 75 EricPixmapCache.getIcon("vcsCheckout"),
75 self.tr("&New from repository..."), 76 self.tr("&New from repository..."),
76 0, 77 0,
77 0, 78 0,
78 self, 79 self,
79 "git_new", 80 "git_new",
91 self.vcsNewAct.triggered.connect(self._vcsCheckout) 92 self.vcsNewAct.triggered.connect(self._vcsCheckout)
92 self.actions.append(self.vcsNewAct) 93 self.actions.append(self.vcsNewAct)
93 94
94 self.gitFetchAct = EricAction( 95 self.gitFetchAct = EricAction(
95 self.tr("Fetch changes"), 96 self.tr("Fetch changes"),
96 UI.PixmapCache.getIcon("vcsUpdate"), 97 EricPixmapCache.getIcon("vcsUpdate"),
97 self.tr("Fetch changes"), 98 self.tr("Fetch changes"),
98 0, 99 0,
99 0, 100 0,
100 self, 101 self,
101 "git_fetch", 102 "git_fetch",
111 self.gitFetchAct.triggered.connect(self.__gitFetch) 112 self.gitFetchAct.triggered.connect(self.__gitFetch)
112 self.actions.append(self.gitFetchAct) 113 self.actions.append(self.gitFetchAct)
113 114
114 self.gitPullAct = EricAction( 115 self.gitPullAct = EricAction(
115 self.tr("Pull changes"), 116 self.tr("Pull changes"),
116 UI.PixmapCache.getIcon("vcsUpdate"), 117 EricPixmapCache.getIcon("vcsUpdate"),
117 self.tr("Pull changes"), 118 self.tr("Pull changes"),
118 0, 119 0,
119 0, 120 0,
120 self, 121 self,
121 "git_pull", 122 "git_pull",
133 self.gitPullAct.triggered.connect(self.__gitPull) 134 self.gitPullAct.triggered.connect(self.__gitPull)
134 self.actions.append(self.gitPullAct) 135 self.actions.append(self.gitPullAct)
135 136
136 self.vcsCommitAct = EricAction( 137 self.vcsCommitAct = EricAction(
137 self.tr("Commit changes to repository"), 138 self.tr("Commit changes to repository"),
138 UI.PixmapCache.getIcon("vcsCommit"), 139 EricPixmapCache.getIcon("vcsCommit"),
139 self.tr("Commit changes to repository..."), 140 self.tr("Commit changes to repository..."),
140 0, 141 0,
141 0, 142 0,
142 self, 143 self,
143 "git_commit", 144 "git_commit",
155 self.vcsCommitAct.triggered.connect(self._vcsCommit) 156 self.vcsCommitAct.triggered.connect(self._vcsCommit)
156 self.actions.append(self.vcsCommitAct) 157 self.actions.append(self.vcsCommitAct)
157 158
158 self.gitPushAct = EricAction( 159 self.gitPushAct = EricAction(
159 self.tr("Push changes"), 160 self.tr("Push changes"),
160 UI.PixmapCache.getIcon("vcsCommit"), 161 EricPixmapCache.getIcon("vcsCommit"),
161 self.tr("Push changes"), 162 self.tr("Push changes"),
162 0, 163 0,
163 0, 164 0,
164 self, 165 self,
165 "git_push", 166 "git_push",
175 self.gitPushAct.triggered.connect(self.__gitPush) 176 self.gitPushAct.triggered.connect(self.__gitPush)
176 self.actions.append(self.gitPushAct) 177 self.actions.append(self.gitPushAct)
177 178
178 self.vcsExportAct = EricAction( 179 self.vcsExportAct = EricAction(
179 self.tr("Export from repository"), 180 self.tr("Export from repository"),
180 UI.PixmapCache.getIcon("vcsExport"), 181 EricPixmapCache.getIcon("vcsExport"),
181 self.tr("&Export from repository..."), 182 self.tr("&Export from repository..."),
182 0, 183 0,
183 0, 184 0,
184 self, 185 self,
185 "git_export_repo", 186 "git_export_repo",
194 self.vcsExportAct.triggered.connect(self._vcsExport) 195 self.vcsExportAct.triggered.connect(self._vcsExport)
195 self.actions.append(self.vcsExportAct) 196 self.actions.append(self.vcsExportAct)
196 197
197 self.gitLogBrowserAct = EricAction( 198 self.gitLogBrowserAct = EricAction(
198 self.tr("Show log browser"), 199 self.tr("Show log browser"),
199 UI.PixmapCache.getIcon("vcsLog"), 200 EricPixmapCache.getIcon("vcsLog"),
200 self.tr("Show log browser"), 201 self.tr("Show log browser"),
201 0, 202 0,
202 0, 203 0,
203 self, 204 self,
204 "git_log_browser", 205 "git_log_browser",
217 self.gitLogBrowserAct.triggered.connect(self._vcsLogBrowser) 218 self.gitLogBrowserAct.triggered.connect(self._vcsLogBrowser)
218 self.actions.append(self.gitLogBrowserAct) 219 self.actions.append(self.gitLogBrowserAct)
219 220
220 self.gitReflogBrowserAct = EricAction( 221 self.gitReflogBrowserAct = EricAction(
221 self.tr("Show reflog browser"), 222 self.tr("Show reflog browser"),
222 UI.PixmapCache.getIcon("vcsLog"), 223 EricPixmapCache.getIcon("vcsLog"),
223 self.tr("Show reflog browser"), 224 self.tr("Show reflog browser"),
224 0, 225 0,
225 0, 226 0,
226 self, 227 self,
227 "git_reflog_browser", 228 "git_reflog_browser",
240 self.gitReflogBrowserAct.triggered.connect(self.__gitReflogBrowser) 241 self.gitReflogBrowserAct.triggered.connect(self.__gitReflogBrowser)
241 self.actions.append(self.gitReflogBrowserAct) 242 self.actions.append(self.gitReflogBrowserAct)
242 243
243 self.vcsDiffAct = EricAction( 244 self.vcsDiffAct = EricAction(
244 self.tr("Show differences"), 245 self.tr("Show differences"),
245 UI.PixmapCache.getIcon("vcsDiff"), 246 EricPixmapCache.getIcon("vcsDiff"),
246 self.tr("Show &differences..."), 247 self.tr("Show &differences..."),
247 0, 248 0,
248 0, 249 0,
249 self, 250 self,
250 "git_diff", 251 "git_diff",
262 self.vcsDiffAct.triggered.connect(self._vcsDiff) 263 self.vcsDiffAct.triggered.connect(self._vcsDiff)
263 self.actions.append(self.vcsDiffAct) 264 self.actions.append(self.vcsDiffAct)
264 265
265 self.gitExtDiffAct = EricAction( 266 self.gitExtDiffAct = EricAction(
266 self.tr("Show differences (extended)"), 267 self.tr("Show differences (extended)"),
267 UI.PixmapCache.getIcon("vcsDiff"), 268 EricPixmapCache.getIcon("vcsDiff"),
268 self.tr("Show differences (extended) ..."), 269 self.tr("Show differences (extended) ..."),
269 0, 270 0,
270 0, 271 0,
271 self, 272 self,
272 "git_extendeddiff", 273 "git_extendeddiff",
284 self.gitExtDiffAct.triggered.connect(self.__gitExtendedDiff) 285 self.gitExtDiffAct.triggered.connect(self.__gitExtendedDiff)
285 self.actions.append(self.gitExtDiffAct) 286 self.actions.append(self.gitExtDiffAct)
286 287
287 self.vcsStatusAct = EricAction( 288 self.vcsStatusAct = EricAction(
288 self.tr("Show status"), 289 self.tr("Show status"),
289 UI.PixmapCache.getIcon("vcsStatus"), 290 EricPixmapCache.getIcon("vcsStatus"),
290 self.tr("Show &status..."), 291 self.tr("Show &status..."),
291 0, 292 0,
292 0, 293 0,
293 self, 294 self,
294 "git_status", 295 "git_status",
303 self.vcsStatusAct.triggered.connect(self._vcsStatus) 304 self.vcsStatusAct.triggered.connect(self._vcsStatus)
304 self.actions.append(self.vcsStatusAct) 305 self.actions.append(self.vcsStatusAct)
305 306
306 self.vcsSwitchAct = EricAction( 307 self.vcsSwitchAct = EricAction(
307 self.tr("Switch"), 308 self.tr("Switch"),
308 UI.PixmapCache.getIcon("vcsSwitch"), 309 EricPixmapCache.getIcon("vcsSwitch"),
309 self.tr("S&witch..."), 310 self.tr("S&witch..."),
310 0, 311 0,
311 0, 312 0,
312 self, 313 self,
313 "git_switch", 314 "git_switch",
325 self.vcsSwitchAct.triggered.connect(self._vcsSwitch) 326 self.vcsSwitchAct.triggered.connect(self._vcsSwitch)
326 self.actions.append(self.vcsSwitchAct) 327 self.actions.append(self.vcsSwitchAct)
327 328
328 self.vcsTagAct = EricAction( 329 self.vcsTagAct = EricAction(
329 self.tr("Tag in repository"), 330 self.tr("Tag in repository"),
330 UI.PixmapCache.getIcon("vcsTag"), 331 EricPixmapCache.getIcon("vcsTag"),
331 self.tr("&Tag in repository..."), 332 self.tr("&Tag in repository..."),
332 0, 333 0,
333 0, 334 0,
334 self, 335 self,
335 "git_tag", 336 "git_tag",
438 self.gitNotMergedBranchListAct.triggered.connect(self.__gitNotMergedBranchList) 439 self.gitNotMergedBranchListAct.triggered.connect(self.__gitNotMergedBranchList)
439 self.actions.append(self.gitNotMergedBranchListAct) 440 self.actions.append(self.gitNotMergedBranchListAct)
440 441
441 self.gitBranchAct = EricAction( 442 self.gitBranchAct = EricAction(
442 self.tr("Branch in repository"), 443 self.tr("Branch in repository"),
443 UI.PixmapCache.getIcon("vcsBranch"), 444 EricPixmapCache.getIcon("vcsBranch"),
444 self.tr("&Branch in repository..."), 445 self.tr("&Branch in repository..."),
445 0, 446 0,
446 0, 447 0,
447 self, 448 self,
448 "git_branch", 449 "git_branch",
500 self.gitShowBranchAct.triggered.connect(self.__gitShowBranch) 501 self.gitShowBranchAct.triggered.connect(self.__gitShowBranch)
501 self.actions.append(self.gitShowBranchAct) 502 self.actions.append(self.gitShowBranchAct)
502 503
503 self.vcsRevertAct = EricAction( 504 self.vcsRevertAct = EricAction(
504 self.tr("Revert changes"), 505 self.tr("Revert changes"),
505 UI.PixmapCache.getIcon("vcsRevert"), 506 EricPixmapCache.getIcon("vcsRevert"),
506 self.tr("Re&vert changes"), 507 self.tr("Re&vert changes"),
507 0, 508 0,
508 0, 509 0,
509 self, 510 self,
510 "git_revert", 511 "git_revert",
521 self.vcsRevertAct.triggered.connect(self.__gitRevert) 522 self.vcsRevertAct.triggered.connect(self.__gitRevert)
522 self.actions.append(self.vcsRevertAct) 523 self.actions.append(self.vcsRevertAct)
523 524
524 self.gitUnstageAct = EricAction( 525 self.gitUnstageAct = EricAction(
525 self.tr("Unstage changes"), 526 self.tr("Unstage changes"),
526 UI.PixmapCache.getIcon("vcsRevert"), 527 EricPixmapCache.getIcon("vcsRevert"),
527 self.tr("&Unstage changes"), 528 self.tr("&Unstage changes"),
528 0, 529 0,
529 0, 530 0,
530 self, 531 self,
531 "git_revert", 532 "git_revert",
542 self.gitUnstageAct.triggered.connect(self.__gitUnstage) 543 self.gitUnstageAct.triggered.connect(self.__gitUnstage)
543 self.actions.append(self.gitUnstageAct) 544 self.actions.append(self.gitUnstageAct)
544 545
545 self.vcsMergeAct = EricAction( 546 self.vcsMergeAct = EricAction(
546 self.tr("Merge"), 547 self.tr("Merge"),
547 UI.PixmapCache.getIcon("vcsMerge"), 548 EricPixmapCache.getIcon("vcsMerge"),
548 self.tr("Mer&ge changes..."), 549 self.tr("Mer&ge changes..."),
549 0, 550 0,
550 0, 551 0,
551 self, 552 self,
552 "git_merge", 553 "git_merge",
780 self.gitRemoteCredentialsAct.triggered.connect(self.__gitRemoteCredentials) 781 self.gitRemoteCredentialsAct.triggered.connect(self.__gitRemoteCredentials)
781 self.actions.append(self.gitRemoteCredentialsAct) 782 self.actions.append(self.gitRemoteCredentialsAct)
782 783
783 self.gitCherryPickAct = EricAction( 784 self.gitCherryPickAct = EricAction(
784 self.tr("Copy Commits"), 785 self.tr("Copy Commits"),
785 UI.PixmapCache.getIcon("vcsGraft"), 786 EricPixmapCache.getIcon("vcsGraft"),
786 self.tr("Copy Commits"), 787 self.tr("Copy Commits"),
787 0, 788 0,
788 0, 789 0,
789 self, 790 self,
790 "git_cherrypick", 791 "git_cherrypick",
1365 self.gitBisectResetAct.triggered.connect(self.__gitBisectReset) 1366 self.gitBisectResetAct.triggered.connect(self.__gitBisectReset)
1366 self.actions.append(self.gitBisectResetAct) 1367 self.actions.append(self.gitBisectResetAct)
1367 1368
1368 self.gitBisectLogBrowserAct = EricAction( 1369 self.gitBisectLogBrowserAct = EricAction(
1369 self.tr("Show bisect log browser"), 1370 self.tr("Show bisect log browser"),
1370 UI.PixmapCache.getIcon("vcsLog"), 1371 EricPixmapCache.getIcon("vcsLog"),
1371 self.tr("Show bisect log browser"), 1372 self.tr("Show bisect log browser"),
1372 0, 1373 0,
1373 0, 1374 0,
1374 self, 1375 self,
1375 "git_bisect_log_browser", 1376 "git_bisect_log_browser",
1788 bisectMenu.addAction(self.gitBisectEditReplayAct) 1789 bisectMenu.addAction(self.gitBisectEditReplayAct)
1789 bisectMenu.addAction(self.gitBisectReplayAct) 1790 bisectMenu.addAction(self.gitBisectReplayAct)
1790 self.subMenus.append(bisectMenu) 1791 self.subMenus.append(bisectMenu)
1791 1792
1792 tagsMenu = QMenu(self.tr("Tags"), menu) 1793 tagsMenu = QMenu(self.tr("Tags"), menu)
1793 tagsMenu.setIcon(UI.PixmapCache.getIcon("vcsTag")) 1794 tagsMenu.setIcon(EricPixmapCache.getIcon("vcsTag"))
1794 tagsMenu.setTearOffEnabled(True) 1795 tagsMenu.setTearOffEnabled(True)
1795 tagsMenu.addAction(self.vcsTagAct) 1796 tagsMenu.addAction(self.vcsTagAct)
1796 tagsMenu.addAction(self.gitTagListAct) 1797 tagsMenu.addAction(self.gitTagListAct)
1797 tagsMenu.addAction(self.gitDescribeTagAct) 1798 tagsMenu.addAction(self.gitDescribeTagAct)
1798 self.subMenus.append(tagsMenu) 1799 self.subMenus.append(tagsMenu)
1799 1800
1800 branchesMenu = QMenu(self.tr("Branches"), menu) 1801 branchesMenu = QMenu(self.tr("Branches"), menu)
1801 branchesMenu.setIcon(UI.PixmapCache.getIcon("vcsBranch")) 1802 branchesMenu.setIcon(EricPixmapCache.getIcon("vcsBranch"))
1802 branchesMenu.setTearOffEnabled(True) 1803 branchesMenu.setTearOffEnabled(True)
1803 branchesMenu.addAction(self.gitBranchAct) 1804 branchesMenu.addAction(self.gitBranchAct)
1804 branchesMenu.addSeparator() 1805 branchesMenu.addSeparator()
1805 branchesMenu.addAction(self.gitBranchListAct) 1806 branchesMenu.addAction(self.gitBranchListAct)
1806 branchesMenu.addAction(self.gitMergedBranchListAct) 1807 branchesMenu.addAction(self.gitMergedBranchListAct)
1829 remotesMenu.addAction(self.gitRemoteCredentialsAct) 1830 remotesMenu.addAction(self.gitRemoteCredentialsAct)
1830 remotesMenu.addAction(self.gitRemoteRemoveAct) 1831 remotesMenu.addAction(self.gitRemoteRemoveAct)
1831 remotesMenu.addAction(self.gitRemotePruneAct) 1832 remotesMenu.addAction(self.gitRemotePruneAct)
1832 1833
1833 cherrypickMenu = QMenu(self.tr("Cherry-pick"), menu) 1834 cherrypickMenu = QMenu(self.tr("Cherry-pick"), menu)
1834 cherrypickMenu.setIcon(UI.PixmapCache.getIcon("vcsGraft")) 1835 cherrypickMenu.setIcon(EricPixmapCache.getIcon("vcsGraft"))
1835 cherrypickMenu.setTearOffEnabled(True) 1836 cherrypickMenu.setTearOffEnabled(True)
1836 cherrypickMenu.addAction(self.gitCherryPickAct) 1837 cherrypickMenu.addAction(self.gitCherryPickAct)
1837 cherrypickMenu.addAction(self.gitCherryPickContinueAct) 1838 cherrypickMenu.addAction(self.gitCherryPickContinueAct)
1838 cherrypickMenu.addAction(self.gitCherryPickQuitAct) 1839 cherrypickMenu.addAction(self.gitCherryPickQuitAct)
1839 cherrypickMenu.addAction(self.gitCherryPickAbortAct) 1840 cherrypickMenu.addAction(self.gitCherryPickAbortAct)
1871 submodulesMenu.addSeparator() 1872 submodulesMenu.addSeparator()
1872 submodulesMenu.addAction(self.gitSubmodulesStatusAct) 1873 submodulesMenu.addAction(self.gitSubmodulesStatusAct)
1873 submodulesMenu.addAction(self.gitSubmodulesSummaryAct) 1874 submodulesMenu.addAction(self.gitSubmodulesSummaryAct)
1874 1875
1875 act = menu.addAction( 1876 act = menu.addAction(
1876 UI.PixmapCache.getIcon( 1877 EricPixmapCache.getIcon(
1877 os.path.join("VcsPlugins", "vcsGit", "icons", "git.svg") 1878 os.path.join("VcsPlugins", "vcsGit", "icons", "git.svg")
1878 ), 1879 ),
1879 self.vcs.vcsName(), 1880 self.vcs.vcsName(),
1880 self._vcsInfoDisplay, 1881 self._vcsInfoDisplay,
1881 ) 1882 )
1934 @param ui reference to the main window (UserInterface) 1935 @param ui reference to the main window (UserInterface)
1935 @param toolbarManager reference to a toolbar manager object 1936 @param toolbarManager reference to a toolbar manager object
1936 (EricToolBarManager) 1937 (EricToolBarManager)
1937 """ 1938 """
1938 self.__toolbar = QToolBar(self.tr("Git"), ui) 1939 self.__toolbar = QToolBar(self.tr("Git"), ui)
1939 self.__toolbar.setIconSize(UI.Config.ToolBarIconSize) 1940 self.__toolbar.setIconSize(Config.ToolBarIconSize)
1940 self.__toolbar.setObjectName("GitToolbar") 1941 self.__toolbar.setObjectName("GitToolbar")
1941 self.__toolbar.setToolTip(self.tr("Git")) 1942 self.__toolbar.setToolTip(self.tr("Git"))
1942 1943
1943 self.__toolbar.addAction(self.gitLogBrowserAct) 1944 self.__toolbar.addAction(self.gitLogBrowserAct)
1944 self.__toolbar.addAction(self.vcsStatusAct) 1945 self.__toolbar.addAction(self.vcsStatusAct)

eric ide

mercurial