26 |
26 |
27 class VcsProjectHelper(QObject): |
27 class VcsProjectHelper(QObject): |
28 """ |
28 """ |
29 Class implementing the base class of the VCS project helper. |
29 Class implementing the base class of the VCS project helper. |
30 """ |
30 """ |
|
31 |
31 def __init__(self, vcsObject, projectObject, parent=None, name=None): |
32 def __init__(self, vcsObject, projectObject, parent=None, name=None): |
32 """ |
33 """ |
33 Constructor |
34 Constructor |
34 |
35 |
35 @param vcsObject reference to the vcs object |
36 @param vcsObject reference to the vcs object |
36 @param projectObject reference to the project object |
37 @param projectObject reference to the project object |
37 @param parent parent widget (QWidget) |
38 @param parent parent widget (QWidget) |
38 @param name name of this object (string) |
39 @param name name of this object (string) |
39 """ |
40 """ |
40 super().__init__(parent) |
41 super().__init__(parent) |
41 if name: |
42 if name: |
42 self.setObjectName(name) |
43 self.setObjectName(name) |
43 |
44 |
44 self.vcs = vcsObject |
45 self.vcs = vcsObject |
45 self.project = projectObject |
46 self.project = projectObject |
46 |
47 |
47 self.actions = [] |
48 self.actions = [] |
48 |
49 |
49 self.vcsAddAct = None |
50 self.vcsAddAct = None |
50 |
51 |
51 self.initActions() |
52 self.initActions() |
52 |
53 |
53 def setObjects(self, vcsObject, projectObject): |
54 def setObjects(self, vcsObject, projectObject): |
54 """ |
55 """ |
55 Public method to set references to the vcs and project objects. |
56 Public method to set references to the vcs and project objects. |
56 |
57 |
57 @param vcsObject reference to the vcs object |
58 @param vcsObject reference to the vcs object |
58 @param projectObject reference to the project object |
59 @param projectObject reference to the project object |
59 """ |
60 """ |
60 self.vcs = vcsObject |
61 self.vcs = vcsObject |
61 self.project = projectObject |
62 self.project = projectObject |
62 |
63 |
63 def initActions(self): |
64 def initActions(self): |
64 """ |
65 """ |
65 Public method to generate the action objects. |
66 Public method to generate the action objects. |
66 """ |
67 """ |
67 self.vcsNewAct = EricAction( |
68 self.vcsNewAct = EricAction( |
68 QCoreApplication.translate( |
69 QCoreApplication.translate("VcsProjectHelper", "New from repository"), |
69 "VcsProjectHelper", 'New from repository'), |
|
70 UI.PixmapCache.getIcon("vcsCheckout"), |
70 UI.PixmapCache.getIcon("vcsCheckout"), |
71 QCoreApplication.translate( |
71 QCoreApplication.translate("VcsProjectHelper", "&New from repository..."), |
72 "VcsProjectHelper", '&New from repository...'), |
72 0, |
73 0, 0, self, 'vcs_new') |
73 0, |
74 self.vcsNewAct.setStatusTip(QCoreApplication.translate( |
74 self, |
75 "VcsProjectHelper", |
75 "vcs_new", |
76 'Create a new project from the VCS repository' |
76 ) |
77 )) |
77 self.vcsNewAct.setStatusTip( |
78 self.vcsNewAct.setWhatsThis(QCoreApplication.translate( |
78 QCoreApplication.translate( |
79 "VcsProjectHelper", |
79 "VcsProjectHelper", "Create a new project from the VCS repository" |
80 """<b>New from repository</b>""" |
80 ) |
81 """<p>This creates a new local project from the VCS""" |
81 ) |
82 """ repository.</p>""" |
82 self.vcsNewAct.setWhatsThis( |
83 )) |
83 QCoreApplication.translate( |
|
84 "VcsProjectHelper", |
|
85 """<b>New from repository</b>""" |
|
86 """<p>This creates a new local project from the VCS""" |
|
87 """ repository.</p>""", |
|
88 ) |
|
89 ) |
84 self.vcsNewAct.triggered.connect(self._vcsCheckout) |
90 self.vcsNewAct.triggered.connect(self._vcsCheckout) |
85 self.actions.append(self.vcsNewAct) |
91 self.actions.append(self.vcsNewAct) |
86 |
92 |
87 self.vcsExportAct = EricAction( |
93 self.vcsExportAct = EricAction( |
88 QCoreApplication.translate( |
94 QCoreApplication.translate("VcsProjectHelper", "Export from repository"), |
89 "VcsProjectHelper", 'Export from repository'), |
|
90 UI.PixmapCache.getIcon("vcsExport"), |
95 UI.PixmapCache.getIcon("vcsExport"), |
91 QCoreApplication.translate( |
96 QCoreApplication.translate( |
92 "VcsProjectHelper", '&Export from repository...'), |
97 "VcsProjectHelper", "&Export from repository..." |
93 0, 0, self, 'vcs_export') |
98 ), |
94 self.vcsExportAct.setStatusTip(QCoreApplication.translate( |
99 0, |
95 "VcsProjectHelper", |
100 0, |
96 'Export a project from the repository' |
101 self, |
97 )) |
102 "vcs_export", |
98 self.vcsExportAct.setWhatsThis(QCoreApplication.translate( |
103 ) |
99 "VcsProjectHelper", |
104 self.vcsExportAct.setStatusTip( |
100 """<b>Export from repository</b>""" |
105 QCoreApplication.translate( |
101 """<p>This exports a project from the repository.</p>""" |
106 "VcsProjectHelper", "Export a project from the repository" |
102 )) |
107 ) |
|
108 ) |
|
109 self.vcsExportAct.setWhatsThis( |
|
110 QCoreApplication.translate( |
|
111 "VcsProjectHelper", |
|
112 """<b>Export from repository</b>""" |
|
113 """<p>This exports a project from the repository.</p>""", |
|
114 ) |
|
115 ) |
103 self.vcsExportAct.triggered.connect(self._vcsExport) |
116 self.vcsExportAct.triggered.connect(self._vcsExport) |
104 self.actions.append(self.vcsExportAct) |
117 self.actions.append(self.vcsExportAct) |
105 |
118 |
106 self.vcsAddAct = EricAction( |
119 self.vcsAddAct = EricAction( |
107 QCoreApplication.translate( |
120 QCoreApplication.translate("VcsProjectHelper", "Add to repository"), |
108 "VcsProjectHelper", 'Add to repository'), |
|
109 UI.PixmapCache.getIcon("vcsCommit"), |
121 UI.PixmapCache.getIcon("vcsCommit"), |
110 QCoreApplication.translate( |
122 QCoreApplication.translate("VcsProjectHelper", "&Add to repository..."), |
111 "VcsProjectHelper", '&Add to repository...'), |
123 0, |
112 0, 0, self, 'vcs_add') |
124 0, |
113 self.vcsAddAct.setStatusTip(QCoreApplication.translate( |
125 self, |
114 "VcsProjectHelper", |
126 "vcs_add", |
115 'Add the local project to the VCS repository' |
127 ) |
116 )) |
128 self.vcsAddAct.setStatusTip( |
117 self.vcsAddAct.setWhatsThis(QCoreApplication.translate( |
129 QCoreApplication.translate( |
118 "VcsProjectHelper", |
130 "VcsProjectHelper", "Add the local project to the VCS repository" |
119 """<b>Add to repository</b>""" |
131 ) |
120 """<p>This adds (imports) the local project to the VCS""" |
132 ) |
121 """ repository.</p>""" |
133 self.vcsAddAct.setWhatsThis( |
122 )) |
134 QCoreApplication.translate( |
|
135 "VcsProjectHelper", |
|
136 """<b>Add to repository</b>""" |
|
137 """<p>This adds (imports) the local project to the VCS""" |
|
138 """ repository.</p>""", |
|
139 ) |
|
140 ) |
123 self.vcsAddAct.triggered.connect(self._vcsImport) |
141 self.vcsAddAct.triggered.connect(self._vcsImport) |
124 self.actions.append(self.vcsAddAct) |
142 self.actions.append(self.vcsAddAct) |
125 |
143 |
126 def initMenu(self, menu): |
144 def initMenu(self, menu): |
127 """ |
145 """ |
128 Public method to generate the VCS menu. |
146 Public method to generate the VCS menu. |
129 |
147 |
130 @param menu reference to the menu to be populated (QMenu) |
148 @param menu reference to the menu to be populated (QMenu) |
131 """ |
149 """ |
132 menu.clear() |
150 menu.clear() |
133 |
151 |
134 menu.addAction(self.vcsNewAct) |
152 menu.addAction(self.vcsNewAct) |
135 menu.addAction(self.vcsExportAct) |
153 menu.addAction(self.vcsExportAct) |
136 menu.addSeparator() |
154 menu.addSeparator() |
137 menu.addAction(self.vcsAddAct) |
155 menu.addAction(self.vcsAddAct) |
138 menu.addSeparator() |
156 menu.addSeparator() |
139 |
157 |
140 def initToolbar(self, ui, toolbarManager): |
158 def initToolbar(self, ui, toolbarManager): |
141 """ |
159 """ |
142 Public slot to initialize the VCS toolbar. |
160 Public slot to initialize the VCS toolbar. |
143 |
161 |
144 @param ui reference to the main window (UserInterface) |
162 @param ui reference to the main window (UserInterface) |
145 @param toolbarManager reference to a toolbar manager object |
163 @param toolbarManager reference to a toolbar manager object |
146 (EricToolBarManager) |
164 (EricToolBarManager) |
147 @return the toolbar generated (QToolBar) |
165 @return the toolbar generated (QToolBar) |
148 """ |
166 """ |
149 return None # __IGNORE_WARNING_M831__ |
167 return None # __IGNORE_WARNING_M831__ |
150 |
168 |
151 def initBasicToolbar(self, ui, toolbarManager): |
169 def initBasicToolbar(self, ui, toolbarManager): |
152 """ |
170 """ |
153 Public slot to initialize the basic VCS toolbar. |
171 Public slot to initialize the basic VCS toolbar. |
154 |
172 |
155 @param ui reference to the main window (UserInterface) |
173 @param ui reference to the main window (UserInterface) |
156 @param toolbarManager reference to a toolbar manager object |
174 @param toolbarManager reference to a toolbar manager object |
157 (EricToolBarManager) |
175 (EricToolBarManager) |
158 @return the toolbar generated (QToolBar) |
176 @return the toolbar generated (QToolBar) |
159 """ |
177 """ |
160 tb = QToolBar(QCoreApplication.translate("VcsProjectHelper", "VCS"), |
178 tb = QToolBar(QCoreApplication.translate("VcsProjectHelper", "VCS"), ui) |
161 ui) |
|
162 tb.setIconSize(UI.Config.ToolBarIconSize) |
179 tb.setIconSize(UI.Config.ToolBarIconSize) |
163 tb.setObjectName("VersionControlToolbar") |
180 tb.setObjectName("VersionControlToolbar") |
164 tb.setToolTip(QCoreApplication.translate("VcsProjectHelper", 'VCS')) |
181 tb.setToolTip(QCoreApplication.translate("VcsProjectHelper", "VCS")) |
165 |
182 |
166 tb.addAction(self.vcsNewAct) |
183 tb.addAction(self.vcsNewAct) |
167 tb.addAction(self.vcsExportAct) |
184 tb.addAction(self.vcsExportAct) |
168 tb.addSeparator() |
185 tb.addSeparator() |
169 tb.addAction(self.vcsAddAct) |
186 tb.addAction(self.vcsAddAct) |
170 |
187 |
171 toolbarManager.addToolBar(tb, tb.windowTitle()) |
188 toolbarManager.addToolBar(tb, tb.windowTitle()) |
172 |
189 |
173 return tb |
190 return tb |
174 |
191 |
175 def showMenu(self): |
192 def showMenu(self): |
176 """ |
193 """ |
177 Public slot called before the vcs menu is shown. |
194 Public slot called before the vcs menu is shown. |
178 """ |
195 """ |
179 if self.vcsAddAct: |
196 if self.vcsAddAct: |
180 self.vcsAddAct.setEnabled(self.project and self.project.isOpen()) |
197 self.vcsAddAct.setEnabled(self.project and self.project.isOpen()) |
181 |
198 |
182 @pyqtSlot() |
199 @pyqtSlot() |
183 def _vcsCheckout(self, export=False): |
200 def _vcsCheckout(self, export=False): |
184 """ |
201 """ |
185 Protected slot used to create a local project from the repository. |
202 Protected slot used to create a local project from the repository. |
186 |
203 |
187 @param export flag indicating whether an export or a checkout |
204 @param export flag indicating whether an export or a checkout |
188 should be performed |
205 should be performed |
189 """ |
206 """ |
190 if not self.project or not self.project.checkDirty(): |
207 if not self.project or not self.project.checkDirty(): |
191 return |
208 return |
192 |
209 |
193 vcsSystemsDict = ericApp().getObject( |
210 vcsSystemsDict = ( |
194 "PluginManager").getPluginDisplayStrings("version_control") |
211 ericApp() |
|
212 .getObject("PluginManager") |
|
213 .getPluginDisplayStrings("version_control") |
|
214 ) |
195 if not vcsSystemsDict: |
215 if not vcsSystemsDict: |
196 # no version control system found |
216 # no version control system found |
197 return |
217 return |
198 |
218 |
199 vcsSystemsDisplay = [] |
219 vcsSystemsDisplay = [] |
200 keys = sorted(vcsSystemsDict.keys()) |
220 keys = sorted(vcsSystemsDict.keys()) |
201 for key in keys: |
221 for key in keys: |
202 vcsSystemsDisplay.append(vcsSystemsDict[key]) |
222 vcsSystemsDisplay.append(vcsSystemsDict[key]) |
203 vcsSelected, ok = QInputDialog.getItem( |
223 vcsSelected, ok = QInputDialog.getItem( |
204 None, |
224 None, |
205 QCoreApplication.translate("VcsProjectHelper", "New Project"), |
225 QCoreApplication.translate("VcsProjectHelper", "New Project"), |
206 QCoreApplication.translate( |
226 QCoreApplication.translate( |
207 "VcsProjectHelper", |
227 "VcsProjectHelper", "Select version control system for the project" |
208 "Select version control system for the project"), |
228 ), |
209 vcsSystemsDisplay, |
229 vcsSystemsDisplay, |
210 0, False) |
230 0, |
|
231 False, |
|
232 ) |
211 if not ok: |
233 if not ok: |
212 return |
234 return |
213 |
235 |
214 selectedVcsSystem = None |
236 selectedVcsSystem = None |
215 for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()): |
237 for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()): |
216 if vcsSystemDisplay == vcsSelected: |
238 if vcsSystemDisplay == vcsSelected: |
217 selectedVcsSystem = vcsSystem |
239 selectedVcsSystem = vcsSystem |
218 break |
240 break |
219 |
241 |
220 if not self.project.closeProject(): |
242 if not self.project.closeProject(): |
221 return |
243 return |
222 |
244 |
223 vcs = self.project.initVCS(selectedVcsSystem) |
245 vcs = self.project.initVCS(selectedVcsSystem) |
224 if vcs is not None: |
246 if vcs is not None: |
225 vcsdlg = vcs.vcsNewProjectOptionsDialog() |
247 vcsdlg = vcs.vcsNewProjectOptionsDialog() |
226 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
248 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
227 projectdir, vcsDataDict = vcsdlg.getData() |
249 projectdir, vcsDataDict = vcsdlg.getData() |
228 # edit VCS command options |
250 # edit VCS command options |
229 if vcs.vcsSupportCommandOptions(): |
251 if vcs.vcsSupportCommandOptions(): |
230 vcores = EricMessageBox.yesNo( |
252 vcores = EricMessageBox.yesNo( |
231 self.parent(), |
253 self.parent(), |
232 QCoreApplication.translate( |
254 QCoreApplication.translate("VcsProjectHelper", "New Project"), |
233 "VcsProjectHelper", "New Project"), |
|
234 QCoreApplication.translate( |
255 QCoreApplication.translate( |
235 "VcsProjectHelper", |
256 "VcsProjectHelper", |
236 """Would you like to edit the VCS command""" |
257 """Would you like to edit the VCS command""" |
237 """ options?""")) |
258 """ options?""", |
|
259 ), |
|
260 ) |
238 else: |
261 else: |
239 vcores = False |
262 vcores = False |
240 if vcores: |
263 if vcores: |
241 from .CommandOptionsDialog import VcsCommandOptionsDialog |
264 from .CommandOptionsDialog import VcsCommandOptionsDialog |
|
265 |
242 codlg = VcsCommandOptionsDialog(vcs) |
266 codlg = VcsCommandOptionsDialog(vcs) |
243 if codlg.exec() == QDialog.DialogCode.Accepted: |
267 if codlg.exec() == QDialog.DialogCode.Accepted: |
244 vcs.vcsSetOptions(codlg.getOptions()) |
268 vcs.vcsSetOptions(codlg.getOptions()) |
245 |
269 |
246 # create the project directory if it doesn't exist already |
270 # create the project directory if it doesn't exist already |
247 if not os.path.isdir(projectdir): |
271 if not os.path.isdir(projectdir): |
248 try: |
272 try: |
249 os.makedirs(projectdir) |
273 os.makedirs(projectdir) |
250 except OSError: |
274 except OSError: |
251 EricMessageBox.critical( |
275 EricMessageBox.critical( |
252 self.parent(), |
276 self.parent(), |
253 QCoreApplication.translate( |
277 QCoreApplication.translate( |
254 "VcsProjectHelper", |
278 "VcsProjectHelper", "Create project directory" |
255 "Create project directory"), |
279 ), |
256 QCoreApplication.translate( |
280 QCoreApplication.translate( |
257 "VcsProjectHelper", |
281 "VcsProjectHelper", |
258 "<p>The project directory <b>{0}</b> could not" |
282 "<p>The project directory <b>{0}</b> could not" |
259 " be created.</p>").format(projectdir)) |
283 " be created.</p>", |
|
284 ).format(projectdir), |
|
285 ) |
260 self.project.resetVCS() |
286 self.project.resetVCS() |
261 return |
287 return |
262 |
288 |
263 # create the project from the VCS |
289 # create the project from the VCS |
264 vcs.vcsSetDataFromDict(vcsDataDict) |
290 vcs.vcsSetDataFromDict(vcsDataDict) |
265 if export: |
291 if export: |
266 ok = vcs.vcsExport(vcsDataDict, projectdir) |
292 ok = vcs.vcsExport(vcsDataDict, projectdir) |
267 else: |
293 else: |
280 else: |
306 else: |
281 pfilenamelist = [p.name for p in plist] |
307 pfilenamelist = [p.name for p in plist] |
282 pfilename, ok = QInputDialog.getItem( |
308 pfilename, ok = QInputDialog.getItem( |
283 None, |
309 None, |
284 QCoreApplication.translate( |
310 QCoreApplication.translate( |
285 "VcsProjectHelper", |
311 "VcsProjectHelper", "New project from repository" |
286 "New project from repository"), |
312 ), |
287 QCoreApplication.translate( |
313 QCoreApplication.translate( |
288 "VcsProjectHelper", |
314 "VcsProjectHelper", "Select a project file to open." |
289 "Select a project file to open."), |
315 ), |
290 pfilenamelist, 0, False) |
316 pfilenamelist, |
|
317 0, |
|
318 False, |
|
319 ) |
291 if ok: |
320 if ok: |
292 self.project.openProject( |
321 self.project.openProject(str(dpath / pfilename)) |
293 str(dpath / pfilename)) |
|
294 if export: |
322 if export: |
295 self.project.pdata["VCS"] = 'None' |
323 self.project.pdata["VCS"] = "None" |
296 self.project.vcs = self.project.initVCS() |
324 self.project.vcs = self.project.initVCS() |
297 self.project.setDirty(True) |
325 self.project.setDirty(True) |
298 self.project.saveProject() |
326 self.project.saveProject() |
299 else: |
327 else: |
300 res = EricMessageBox.yesNo( |
328 res = EricMessageBox.yesNo( |
301 self.parent(), |
329 self.parent(), |
302 QCoreApplication.translate( |
330 QCoreApplication.translate( |
303 "VcsProjectHelper", |
331 "VcsProjectHelper", "New project from repository" |
304 "New project from repository"), |
332 ), |
305 QCoreApplication.translate( |
333 QCoreApplication.translate( |
306 "VcsProjectHelper", |
334 "VcsProjectHelper", |
307 "The project retrieved from the repository" |
335 "The project retrieved from the repository" |
308 " does not contain an eric project file" |
336 " does not contain an eric project file" |
309 " (*.epj). Create it?"), |
337 " (*.epj). Create it?", |
310 yesDefault=True) |
338 ), |
|
339 yesDefault=True, |
|
340 ) |
311 if res: |
341 if res: |
312 self.project.ppath = projectdir |
342 self.project.ppath = projectdir |
313 self.project.opened = True |
343 self.project.opened = True |
314 |
344 |
315 from Project.PropertiesDialog import ( |
345 from Project.PropertiesDialog import PropertiesDialog |
316 PropertiesDialog |
346 |
317 ) |
|
318 dlg = PropertiesDialog(self.project, False) |
347 dlg = PropertiesDialog(self.project, False) |
319 if dlg.exec() == QDialog.DialogCode.Accepted: |
348 if dlg.exec() == QDialog.DialogCode.Accepted: |
320 dlg.storeData() |
349 dlg.storeData() |
321 self.project.initFileTypes() |
350 self.project.initFileTypes() |
322 self.project.pdata["VCS"] = selectedVcsSystem |
351 self.project.pdata["VCS"] = selectedVcsSystem |
323 self.project.setDirty(True) |
352 self.project.setDirty(True) |
324 if self.project.pdata["MAINSCRIPT"]: |
353 if self.project.pdata["MAINSCRIPT"]: |
325 ms = os.path.join( |
354 ms = os.path.join( |
326 self.project.ppath, |
355 self.project.ppath, |
327 self.project.pdata["MAINSCRIPT"]) |
356 self.project.pdata["MAINSCRIPT"], |
|
357 ) |
328 if os.path.exists(ms): |
358 if os.path.exists(ms): |
329 self.project.appendFile(ms) |
359 self.project.appendFile(ms) |
330 else: |
360 else: |
331 ms = "" |
361 ms = "" |
332 self.project.newProjectAddFiles(ms) |
362 self.project.newProjectAddFiles(ms) |
384 self.project.vcsProjectHelper = vcsHelper |
420 self.project.vcsProjectHelper = vcsHelper |
385 self.project.vcsBasicHelper = vcs is None |
421 self.project.vcsBasicHelper = vcs is None |
386 self.initMenu(self.project.vcsMenu) |
422 self.initMenu(self.project.vcsMenu) |
387 self.project.setDirty(True) |
423 self.project.setDirty(True) |
388 self.project.saveProject() |
424 self.project.saveProject() |
389 |
425 |
390 pdata_vcs = self.project.pdata["VCS"] |
426 pdata_vcs = self.project.pdata["VCS"] |
391 pdata_vcsoptions = copy.deepcopy(self.project.pdata["VCSOPTIONS"]) |
427 pdata_vcsoptions = copy.deepcopy(self.project.pdata["VCSOPTIONS"]) |
392 pdata_vcsother = copy.deepcopy(self.project.pdata["VCSOTHERDATA"]) |
428 pdata_vcsother = copy.deepcopy(self.project.pdata["VCSOTHERDATA"]) |
393 vcs = self.project.vcs |
429 vcs = self.project.vcs |
394 vcsHelper = self.project.vcsProjectHelper |
430 vcsHelper = self.project.vcsProjectHelper |
395 vcsSystemsDict = ericApp().getObject( |
431 vcsSystemsDict = ( |
396 "PluginManager").getPluginDisplayStrings("version_control") |
432 ericApp() |
|
433 .getObject("PluginManager") |
|
434 .getPluginDisplayStrings("version_control") |
|
435 ) |
397 if not vcsSystemsDict: |
436 if not vcsSystemsDict: |
398 # no version control system found |
437 # no version control system found |
399 return |
438 return |
400 |
439 |
401 vcsSystemsDisplay = [] |
440 vcsSystemsDisplay = [] |
402 keys = sorted(vcsSystemsDict.keys()) |
441 keys = sorted(vcsSystemsDict.keys()) |
403 for key in keys: |
442 for key in keys: |
404 vcsSystemsDisplay.append(vcsSystemsDict[key]) |
443 vcsSystemsDisplay.append(vcsSystemsDict[key]) |
405 vcsSelected, ok = QInputDialog.getItem( |
444 vcsSelected, ok = QInputDialog.getItem( |
406 None, |
445 None, |
407 QCoreApplication.translate("VcsProjectHelper", "Import Project"), |
446 QCoreApplication.translate("VcsProjectHelper", "Import Project"), |
408 QCoreApplication.translate( |
447 QCoreApplication.translate( |
409 "VcsProjectHelper", |
448 "VcsProjectHelper", "Select version control system for the project" |
410 "Select version control system for the project"), |
449 ), |
411 vcsSystemsDisplay, |
450 vcsSystemsDisplay, |
412 0, False) |
451 0, |
|
452 False, |
|
453 ) |
413 if not ok: |
454 if not ok: |
414 return |
455 return |
415 |
456 |
416 selectedVcsSystem = None |
457 selectedVcsSystem = None |
417 for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()): |
458 for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()): |
418 if vcsSystemDisplay == vcsSelected: |
459 if vcsSystemDisplay == vcsSelected: |
419 selectedVcsSystem = vcsSystem |
460 selectedVcsSystem = vcsSystem |
420 break |
461 break |
421 |
462 |
422 if selectedVcsSystem is not None: |
463 if selectedVcsSystem is not None: |
423 self.project.pdata["VCS"] = selectedVcsSystem |
464 self.project.pdata["VCS"] = selectedVcsSystem |
424 self.project.vcs = self.project.initVCS(selectedVcsSystem) |
465 self.project.vcs = self.project.initVCS(selectedVcsSystem) |
425 if self.project.vcs is not None: |
466 if self.project.vcs is not None: |
426 vcsdlg = self.project.vcs.vcsOptionsDialog( |
467 vcsdlg = self.project.vcs.vcsOptionsDialog( |
427 self.project, self.project.name, 1) |
468 self.project, self.project.name, 1 |
|
469 ) |
428 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
470 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
429 vcsDataDict = vcsdlg.getData() |
471 vcsDataDict = vcsdlg.getData() |
430 # edit VCS command options |
472 # edit VCS command options |
431 if self.project.vcs.vcsSupportCommandOptions(): |
473 if self.project.vcs.vcsSupportCommandOptions(): |
432 vcores = EricMessageBox.yesNo( |
474 vcores = EricMessageBox.yesNo( |
433 self.parent(), |
475 self.parent(), |
434 QCoreApplication.translate( |
476 QCoreApplication.translate( |
435 "VcsProjectHelper", "Import Project"), |
477 "VcsProjectHelper", "Import Project" |
|
478 ), |
436 QCoreApplication.translate( |
479 QCoreApplication.translate( |
437 "VcsProjectHelper", |
480 "VcsProjectHelper", |
438 """Would you like to edit the VCS command""" |
481 """Would you like to edit the VCS command""" |
439 """ options?""")) |
482 """ options?""", |
|
483 ), |
|
484 ) |
440 else: |
485 else: |
441 vcores = False |
486 vcores = False |
442 if vcores: |
487 if vcores: |
443 from .CommandOptionsDialog import ( |
488 from .CommandOptionsDialog import VcsCommandOptionsDialog |
444 VcsCommandOptionsDialog |
489 |
445 ) |
|
446 codlg = VcsCommandOptionsDialog(self.project.vcs) |
490 codlg = VcsCommandOptionsDialog(self.project.vcs) |
447 if codlg.exec() == QDialog.DialogCode.Accepted: |
491 if codlg.exec() == QDialog.DialogCode.Accepted: |
448 self.project.vcs.vcsSetOptions(codlg.getOptions()) |
492 self.project.vcs.vcsSetOptions(codlg.getOptions()) |
449 self.project.setDirty(True) |
493 self.project.setDirty(True) |
450 self.project.vcs.vcsSetDataFromDict(vcsDataDict) |
494 self.project.vcs.vcsSetDataFromDict(vcsDataDict) |
451 self.project.saveProject() |
495 self.project.saveProject() |
452 isVcsControlled = self.project.vcs.vcsImport( |
496 isVcsControlled = self.project.vcs.vcsImport( |
453 vcsDataDict, self.project.ppath)[0] |
497 vcsDataDict, self.project.ppath |
|
498 )[0] |
454 if isVcsControlled: |
499 if isVcsControlled: |
455 # reopen the project |
500 # reopen the project |
456 self.project.openProject(self.project.pfile) |
501 self.project.openProject(self.project.pfile) |
457 else: |
502 else: |
458 # revert the changes to the local project |
503 # revert the changes to the local project |
467 Protected slot used to update the local project from the repository. |
512 Protected slot used to update the local project from the repository. |
468 """ |
513 """ |
469 if self.vcs is None: |
514 if self.vcs is None: |
470 # just in case |
515 # just in case |
471 return |
516 return |
472 |
517 |
473 shouldReopen = self.vcs.vcsUpdate(self.project.ppath) |
518 shouldReopen = self.vcs.vcsUpdate(self.project.ppath) |
474 if shouldReopen: |
519 if shouldReopen: |
475 res = EricMessageBox.yesNo( |
520 res = EricMessageBox.yesNo( |
476 self.parent(), |
521 self.parent(), |
477 QCoreApplication.translate("VcsProjectHelper", "Update"), |
522 QCoreApplication.translate("VcsProjectHelper", "Update"), |
478 QCoreApplication.translate( |
523 QCoreApplication.translate( |
479 "VcsProjectHelper", |
524 "VcsProjectHelper", """The project should be reread. Do this now?""" |
480 """The project should be reread. Do this now?"""), |
525 ), |
481 yesDefault=True) |
526 yesDefault=True, |
|
527 ) |
482 if res: |
528 if res: |
483 self.project.reopenProject() |
529 self.project.reopenProject() |
484 |
530 |
485 def _vcsCommit(self): |
531 def _vcsCommit(self): |
486 """ |
532 """ |
487 Protected slot used to commit changes to the local project to the |
533 Protected slot used to commit changes to the local project to the |
488 repository. |
534 repository. |
489 """ |
535 """ |
490 if self.vcs is None: |
536 if self.vcs is None: |
491 # just in case |
537 # just in case |
492 return |
538 return |
493 |
539 |
494 if Preferences.getVCS("AutoSaveProject"): |
540 if Preferences.getVCS("AutoSaveProject"): |
495 self.project.saveProject() |
541 self.project.saveProject() |
496 if Preferences.getVCS("AutoSaveFiles"): |
542 if Preferences.getVCS("AutoSaveFiles"): |
497 self.project.saveAllScripts() |
543 self.project.saveAllScripts() |
498 self.vcs.vcsCommit(self.project.ppath, '') |
544 self.vcs.vcsCommit(self.project.ppath, "") |
499 |
545 |
500 def _vcsRemove(self): |
546 def _vcsRemove(self): |
501 """ |
547 """ |
502 Protected slot used to remove the local project from the repository. |
548 Protected slot used to remove the local project from the repository. |
503 |
549 |
504 Depending on the parameters set in the vcs object the project |
550 Depending on the parameters set in the vcs object the project |
505 may be removed from the local disk as well. |
551 may be removed from the local disk as well. |
506 """ |
552 """ |
507 if self.vcs is None: |
553 if self.vcs is None: |
508 # just in case |
554 # just in case |
509 return |
555 return |
510 |
556 |
511 res = EricMessageBox.yesNo( |
557 res = EricMessageBox.yesNo( |
512 self.parent(), |
558 self.parent(), |
513 QCoreApplication.translate( |
559 QCoreApplication.translate( |
514 "VcsProjectHelper", |
560 "VcsProjectHelper", "Remove project from repository" |
515 "Remove project from repository"), |
561 ), |
516 QCoreApplication.translate( |
562 QCoreApplication.translate( |
517 "VcsProjectHelper", |
563 "VcsProjectHelper", |
518 "Dou you really want to remove this project from" |
564 "Dou you really want to remove this project from" |
519 " the repository (and disk)?")) |
565 " the repository (and disk)?", |
|
566 ), |
|
567 ) |
520 if res: |
568 if res: |
521 self.vcs.vcsRemove(self.project.ppath, True) |
569 self.vcs.vcsRemove(self.project.ppath, True) |
522 self._vcsCommit() |
570 self._vcsCommit() |
523 if not os.path.exists(self.project.pfile): |
571 if not os.path.exists(self.project.pfile): |
524 ppath = self.project.ppath |
572 ppath = self.project.ppath |
525 self.setDirty(False) |
573 self.setDirty(False) |
526 self.project.closeProject() |
574 self.project.closeProject() |
527 shutil.rmtree(ppath, True) |
575 shutil.rmtree(ppath, True) |
528 |
576 |
529 def _vcsCommandOptions(self): |
577 def _vcsCommandOptions(self): |
530 """ |
578 """ |
531 Protected slot to edit the VCS command options. |
579 Protected slot to edit the VCS command options. |
532 """ |
580 """ |
533 if self.vcs is None: |
581 if self.vcs is None: |
534 # just in case |
582 # just in case |
535 return |
583 return |
536 |
584 |
537 if self.vcs.vcsSupportCommandOptions(): |
585 if self.vcs.vcsSupportCommandOptions(): |
538 from .CommandOptionsDialog import VcsCommandOptionsDialog |
586 from .CommandOptionsDialog import VcsCommandOptionsDialog |
|
587 |
539 codlg = VcsCommandOptionsDialog(self.vcs) |
588 codlg = VcsCommandOptionsDialog(self.vcs) |
540 if codlg.exec() == QDialog.DialogCode.Accepted: |
589 if codlg.exec() == QDialog.DialogCode.Accepted: |
541 self.vcs.vcsSetOptions(codlg.getOptions()) |
590 self.vcs.vcsSetOptions(codlg.getOptions()) |
542 self.project.setDirty(True) |
591 self.project.setDirty(True) |
543 |
592 |
544 def _vcsLogBrowser(self): |
593 def _vcsLogBrowser(self): |
545 """ |
594 """ |
546 Protected slot used to show the log of the local project with a |
595 Protected slot used to show the log of the local project with a |
547 log browser dialog. |
596 log browser dialog. |
548 """ |
597 """ |
549 if self.vcs is None: |
598 if self.vcs is None: |
550 # just in case |
599 # just in case |
551 return |
600 return |
552 |
601 |
553 self.vcs.vcsLogBrowser(self.project.ppath) |
602 self.vcs.vcsLogBrowser(self.project.ppath) |
554 |
603 |
555 def _vcsDiff(self): |
604 def _vcsDiff(self): |
556 """ |
605 """ |
557 Protected slot used to show the difference of the local project to |
606 Protected slot used to show the difference of the local project to |
558 the repository. |
607 the repository. |
559 """ |
608 """ |
560 if self.vcs is None: |
609 if self.vcs is None: |
561 # just in case |
610 # just in case |
562 return |
611 return |
563 |
612 |
564 self.vcs.vcsDiff(self.project.ppath) |
613 self.vcs.vcsDiff(self.project.ppath) |
565 |
614 |
566 def _vcsStatus(self): |
615 def _vcsStatus(self): |
567 """ |
616 """ |
568 Protected slot used to show the status of the local project. |
617 Protected slot used to show the status of the local project. |
569 """ |
618 """ |
570 if self.vcs is None: |
619 if self.vcs is None: |
571 # just in case |
620 # just in case |
572 return |
621 return |
573 |
622 |
574 self.vcs.vcsStatus(self.project.ppath) |
623 self.vcs.vcsStatus(self.project.ppath) |
575 |
624 |
576 def _vcsTag(self): |
625 def _vcsTag(self): |
577 """ |
626 """ |
578 Protected slot used to tag the local project in the repository. |
627 Protected slot used to tag the local project in the repository. |
579 """ |
628 """ |
580 if self.vcs is None: |
629 if self.vcs is None: |
581 # just in case |
630 # just in case |
582 return |
631 return |
583 |
632 |
584 self.vcs.vcsTag(self.project.ppath) |
633 self.vcs.vcsTag(self.project.ppath) |
585 |
634 |
586 def _vcsRevert(self): |
635 def _vcsRevert(self): |
587 """ |
636 """ |
588 Protected slot used to revert changes made to the local project. |
637 Protected slot used to revert changes made to the local project. |
589 """ |
638 """ |
590 if self.vcs is None: |
639 if self.vcs is None: |
591 # just in case |
640 # just in case |
592 return |
641 return |
593 |
642 |
594 self.vcs.vcsRevert(self.project.ppath) |
643 self.vcs.vcsRevert(self.project.ppath) |
595 |
644 |
596 def _vcsSwitch(self): |
645 def _vcsSwitch(self): |
597 """ |
646 """ |
598 Protected slot used to switch the local project to another tag/branch. |
647 Protected slot used to switch the local project to another tag/branch. |
599 """ |
648 """ |
600 if self.vcs is None: |
649 if self.vcs is None: |
601 # just in case |
650 # just in case |
602 return |
651 return |
603 |
652 |
604 shouldReopen = self.vcs.vcsSwitch(self.project.ppath) |
653 shouldReopen = self.vcs.vcsSwitch(self.project.ppath) |
605 if shouldReopen: |
654 if shouldReopen: |
606 res = EricMessageBox.yesNo( |
655 res = EricMessageBox.yesNo( |
607 self.parent(), |
656 self.parent(), |
608 QCoreApplication.translate("VcsProjectHelper", "Switch"), |
657 QCoreApplication.translate("VcsProjectHelper", "Switch"), |
609 QCoreApplication.translate( |
658 QCoreApplication.translate( |
610 "VcsProjectHelper", |
659 "VcsProjectHelper", """The project should be reread. Do this now?""" |
611 """The project should be reread. Do this now?"""), |
660 ), |
612 yesDefault=True) |
661 yesDefault=True, |
|
662 ) |
613 if res: |
663 if res: |
614 self.project.reopenProject() |
664 self.project.reopenProject() |
615 |
665 |
616 def _vcsMerge(self): |
666 def _vcsMerge(self): |
617 """ |
667 """ |
618 Protected slot used to merge changes of a tag/revision into the local |
668 Protected slot used to merge changes of a tag/revision into the local |
619 project. |
669 project. |
620 """ |
670 """ |
621 if self.vcs is None: |
671 if self.vcs is None: |
622 # just in case |
672 # just in case |
623 return |
673 return |
624 |
674 |
625 self.vcs.vcsMerge(self.project.ppath) |
675 self.vcs.vcsMerge(self.project.ppath) |
626 |
676 |
627 def _vcsCleanup(self): |
677 def _vcsCleanup(self): |
628 """ |
678 """ |
629 Protected slot used to cleanup the local project. |
679 Protected slot used to cleanup the local project. |
630 """ |
680 """ |
631 if self.vcs is None: |
681 if self.vcs is None: |
632 # just in case |
682 # just in case |
633 return |
683 return |
634 |
684 |
635 self.vcs.vcsCleanup(self.project.ppath) |
685 self.vcs.vcsCleanup(self.project.ppath) |
636 |
686 |
637 def _vcsCommand(self): |
687 def _vcsCommand(self): |
638 """ |
688 """ |
639 Protected slot used to execute an arbitrary vcs command. |
689 Protected slot used to execute an arbitrary vcs command. |
640 """ |
690 """ |
641 if self.vcs is None: |
691 if self.vcs is None: |
642 # just in case |
692 # just in case |
643 return |
693 return |
644 |
694 |
645 self.vcs.vcsCommandLine(self.project.ppath) |
695 self.vcs.vcsCommandLine(self.project.ppath) |
646 |
696 |
647 def _vcsInfoDisplay(self): |
697 def _vcsInfoDisplay(self): |
648 """ |
698 """ |
649 Protected slot called to show some vcs information. |
699 Protected slot called to show some vcs information. |
650 """ |
700 """ |
651 if self.vcs is None: |
701 if self.vcs is None: |
652 # just in case |
702 # just in case |
653 return |
703 return |
654 |
704 |
655 from .RepositoryInfoDialog import VcsRepositoryInfoDialog |
705 from .RepositoryInfoDialog import VcsRepositoryInfoDialog |
|
706 |
656 info = self.vcs.vcsRepositoryInfos(self.project.ppath) |
707 info = self.vcs.vcsRepositoryInfos(self.project.ppath) |
657 dlg = VcsRepositoryInfoDialog(None, info) |
708 dlg = VcsRepositoryInfoDialog(None, info) |
658 dlg.exec() |
709 dlg.exec() |