49 def __init__(self, vcs, parent=None): |
49 def __init__(self, vcs, parent=None): |
50 """ |
50 """ |
51 Constructor |
51 Constructor |
52 |
52 |
53 @param vcs reference to the vcs object |
53 @param vcs reference to the vcs object |
54 @param parent parent widget (QWidget) |
54 @type Git |
|
55 @param parent parent widget |
|
56 @type QWidget |
55 """ |
57 """ |
56 super().__init__(parent) |
58 super().__init__(parent) |
57 self.setupUi(self) |
59 self.setupUi(self) |
58 |
60 |
59 self.__toBeCommittedColumn = 0 |
61 self.__toBeCommittedColumn = 0 |
277 |
279 |
278 def closeEvent(self, e): |
280 def closeEvent(self, e): |
279 """ |
281 """ |
280 Protected slot implementing a close event handler. |
282 Protected slot implementing a close event handler. |
281 |
283 |
282 @param e close event (QCloseEvent) |
284 @param e close event |
|
285 @type QCloseEvent |
283 """ |
286 """ |
284 if ( |
287 if ( |
285 self.process is not None |
288 self.process is not None |
286 and self.process.state() != QProcess.ProcessState.NotRunning |
289 and self.process.state() != QProcess.ProcessState.NotRunning |
287 ): |
290 ): |
333 |
336 |
334 def __generateItem(self, status, path): |
337 def __generateItem(self, status, path): |
335 """ |
338 """ |
336 Private method to generate a status item in the status list. |
339 Private method to generate a status item in the status list. |
337 |
340 |
338 @param status status indicator (string) |
341 @param status status indicator |
339 @param path path of the file or directory (string) |
342 @type str |
|
343 @param path path of the file or directory |
|
344 @type str |
340 """ |
345 """ |
341 statusWorkText = self.status[status[1]] |
346 statusWorkText = self.status[status[1]] |
342 statusIndexText = self.status[status[0]] |
347 statusIndexText = self.status[status[0]] |
343 itm = QTreeWidgetItem( |
348 itm = QTreeWidgetItem( |
344 self.statusList, |
349 self.statusList, |
380 def start(self, fn): |
385 def start(self, fn): |
381 """ |
386 """ |
382 Public slot to start the git status command. |
387 Public slot to start the git status command. |
383 |
388 |
384 @param fn filename(s)/directoryname(s) to show the status of |
389 @param fn filename(s)/directoryname(s) to show the status of |
385 (string or list of strings) |
390 @type str or list of str |
386 """ |
391 """ |
387 self.errorGroup.hide() |
392 self.errorGroup.hide() |
388 self.intercept = False |
393 self.intercept = False |
389 self.args = fn |
394 self.args = fn |
390 |
395 |
475 |
480 |
476 def on_buttonBox_clicked(self, button): |
481 def on_buttonBox_clicked(self, button): |
477 """ |
482 """ |
478 Private slot called by a button of the button box clicked. |
483 Private slot called by a button of the button box clicked. |
479 |
484 |
480 @param button button that was clicked (QAbstractButton) |
485 @param button button that was clicked |
|
486 @type QAbstractButton |
481 """ |
487 """ |
482 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): |
488 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): |
483 self.close() |
489 self.close() |
484 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): |
490 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): |
485 self.__finish() |
491 self.__finish() |
489 @pyqtSlot(int, QProcess.ExitStatus) |
495 @pyqtSlot(int, QProcess.ExitStatus) |
490 def __procFinished(self, exitCode, exitStatus): |
496 def __procFinished(self, exitCode, exitStatus): |
491 """ |
497 """ |
492 Private slot connected to the finished signal. |
498 Private slot connected to the finished signal. |
493 |
499 |
494 @param exitCode exit code of the process (integer) |
500 @param exitCode exit code of the process |
495 @param exitStatus exit status of the process (QProcess.ExitStatus) |
501 @type int |
|
502 @param exitStatus exit status of the process |
|
503 @type QProcess.ExitStatus |
496 """ |
504 """ |
497 self.__finish() |
505 self.__finish() |
498 |
506 |
499 def __readStdout(self): |
507 def __readStdout(self): |
500 """ |
508 """ |
532 |
540 |
533 def on_passwordCheckBox_toggled(self, isOn): |
541 def on_passwordCheckBox_toggled(self, isOn): |
534 """ |
542 """ |
535 Private slot to handle the password checkbox toggled. |
543 Private slot to handle the password checkbox toggled. |
536 |
544 |
537 @param isOn flag indicating the status of the check box (boolean) |
545 @param isOn flag indicating the status of the check box |
|
546 @type bool |
538 """ |
547 """ |
539 if isOn: |
548 if isOn: |
540 self.input.setEchoMode(QLineEdit.EchoMode.Password) |
549 self.input.setEchoMode(QLineEdit.EchoMode.Password) |
541 else: |
550 else: |
542 self.input.setEchoMode(QLineEdit.EchoMode.Normal) |
551 self.input.setEchoMode(QLineEdit.EchoMode.Normal) |
661 |
671 |
662 def __commit(self, amend=False): |
672 def __commit(self, amend=False): |
663 """ |
673 """ |
664 Private slot to handle the Commit context menu entry. |
674 Private slot to handle the Commit context menu entry. |
665 |
675 |
666 @param amend flag indicating to perform an amend operation (boolean) |
676 @param amend flag indicating to perform an amend operation |
|
677 @type bool |
667 """ |
678 """ |
668 names = [ |
679 names = [ |
669 os.path.join(self.dname, itm.text(self.__pathColumn)) |
680 os.path.join(self.dname, itm.text(self.__pathColumn)) |
670 for itm in self.__getCommitableItems() |
681 for itm in self.__getCommitableItems() |
671 ] |
682 ] |
947 def __getCommitableItems(self): |
958 def __getCommitableItems(self): |
948 """ |
959 """ |
949 Private method to retrieve all entries the user wants to commit. |
960 Private method to retrieve all entries the user wants to commit. |
950 |
961 |
951 @return list of all items, the user has checked |
962 @return list of all items, the user has checked |
|
963 @rtype list of QTreeWidgetItem |
952 """ |
964 """ |
953 commitableItems = [] |
965 commitableItems = [] |
954 for index in range(self.statusList.topLevelItemCount()): |
966 for index in range(self.statusList.topLevelItemCount()): |
955 itm = self.statusList.topLevelItem(index) |
967 itm = self.statusList.topLevelItem(index) |
956 if itm.checkState(self.__toBeCommittedColumn) == Qt.CheckState.Checked: |
968 if itm.checkState(self.__toBeCommittedColumn) == Qt.CheckState.Checked: |
961 """ |
973 """ |
962 Private method to retrieve all entries the user may commit but hasn't |
974 Private method to retrieve all entries the user may commit but hasn't |
963 selected. |
975 selected. |
964 |
976 |
965 @return list of all items, the user has not checked |
977 @return list of all items, the user has not checked |
|
978 @rtype list of QTreeWidgetItem |
966 """ |
979 """ |
967 items = [] |
980 items = [] |
968 for index in range(self.statusList.topLevelItemCount()): |
981 for index in range(self.statusList.topLevelItemCount()): |
969 itm = self.statusList.topLevelItem(index) |
982 itm = self.statusList.topLevelItem(index) |
970 if ( |
983 if ( |
977 def __getModifiedItems(self): |
990 def __getModifiedItems(self): |
978 """ |
991 """ |
979 Private method to retrieve all entries, that have a modified status. |
992 Private method to retrieve all entries, that have a modified status. |
980 |
993 |
981 @return list of all items with a modified status |
994 @return list of all items with a modified status |
|
995 @rtype list of QTreeWidgetItem |
982 """ |
996 """ |
983 modifiedItems = [] |
997 modifiedItems = [] |
984 for itm in self.statusList.selectedItems(): |
998 for itm in self.statusList.selectedItems(): |
985 if ( |
999 if ( |
986 itm.text(self.__statusWorkColumn) in self.modifiedIndicators |
1000 itm.text(self.__statusWorkColumn) in self.modifiedIndicators |
992 def __getModifiedOnlyItems(self): |
1006 def __getModifiedOnlyItems(self): |
993 """ |
1007 """ |
994 Private method to retrieve all entries, that have a modified status. |
1008 Private method to retrieve all entries, that have a modified status. |
995 |
1009 |
996 @return list of all items with a modified status |
1010 @return list of all items with a modified status |
|
1011 @rtype list of QTreeWidgetItem |
997 """ |
1012 """ |
998 modifiedItems = [] |
1013 modifiedItems = [] |
999 for itm in self.statusList.selectedItems(): |
1014 for itm in self.statusList.selectedItems(): |
1000 if ( |
1015 if ( |
1001 itm.text(self.__statusWorkColumn) in self.modifiedOnlyIndicators |
1016 itm.text(self.__statusWorkColumn) in self.modifiedOnlyIndicators |
1008 """ |
1023 """ |
1009 Private method to retrieve all entries, that have an unversioned |
1024 Private method to retrieve all entries, that have an unversioned |
1010 status. |
1025 status. |
1011 |
1026 |
1012 @return list of all items with an unversioned status |
1027 @return list of all items with an unversioned status |
|
1028 @rtype list of QTreeWidgetItem |
1013 """ |
1029 """ |
1014 unversionedItems = [] |
1030 unversionedItems = [] |
1015 for itm in self.statusList.selectedItems(): |
1031 for itm in self.statusList.selectedItems(): |
1016 if itm.text(self.__statusWorkColumn) in self.unversionedIndicators: |
1032 if itm.text(self.__statusWorkColumn) in self.unversionedIndicators: |
1017 unversionedItems.append(itm) |
1033 unversionedItems.append(itm) |
1021 """ |
1037 """ |
1022 Private method to retrieve all entries, that have a stageable |
1038 Private method to retrieve all entries, that have a stageable |
1023 status. |
1039 status. |
1024 |
1040 |
1025 @return list of all items with a stageable status |
1041 @return list of all items with a stageable status |
|
1042 @rtype list of QTreeWidgetItem |
1026 """ |
1043 """ |
1027 stageableItems = [] |
1044 stageableItems = [] |
1028 for itm in self.statusList.selectedItems(): |
1045 for itm in self.statusList.selectedItems(): |
1029 if ( |
1046 if ( |
1030 itm.text(self.__statusWorkColumn) |
1047 itm.text(self.__statusWorkColumn) |
1037 """ |
1054 """ |
1038 Private method to retrieve all entries, that have an unstageable |
1055 Private method to retrieve all entries, that have an unstageable |
1039 status. |
1056 status. |
1040 |
1057 |
1041 @return list of all items with an unstageable status |
1058 @return list of all items with an unstageable status |
|
1059 @rtype list of QTreeWidgetItem |
1042 """ |
1060 """ |
1043 unstageableItems = [] |
1061 unstageableItems = [] |
1044 for itm in self.statusList.selectedItems(): |
1062 for itm in self.statusList.selectedItems(): |
1045 if itm.text(self.__statusIndexColumn) in self.modifiedIndicators: |
1063 if itm.text(self.__statusIndexColumn) in self.modifiedIndicators: |
1046 unstageableItems.append(itm) |
1064 unstageableItems.append(itm) |
1049 def __getMissingItems(self): |
1067 def __getMissingItems(self): |
1050 """ |
1068 """ |
1051 Private method to retrieve all entries, that have a missing status. |
1069 Private method to retrieve all entries, that have a missing status. |
1052 |
1070 |
1053 @return list of all items with a missing status |
1071 @return list of all items with a missing status |
|
1072 @rtype list of QTreeWidgetItem |
1054 """ |
1073 """ |
1055 missingItems = [] |
1074 missingItems = [] |
1056 for itm in self.statusList.selectedItems(): |
1075 for itm in self.statusList.selectedItems(): |
1057 if itm.text(self.__statusWorkColumn) in self.missingIndicators: |
1076 if itm.text(self.__statusWorkColumn) in self.missingIndicators: |
1058 missingItems.append(itm) |
1077 missingItems.append(itm) |
1061 def __getConflictingItems(self): |
1080 def __getConflictingItems(self): |
1062 """ |
1081 """ |
1063 Private method to retrieve all entries, that have a conflict status. |
1082 Private method to retrieve all entries, that have a conflict status. |
1064 |
1083 |
1065 @return list of all items with a conflict status |
1084 @return list of all items with a conflict status |
|
1085 @rtype list of QTreeWidgetItem |
1066 """ |
1086 """ |
1067 conflictingItems = [] |
1087 conflictingItems = [] |
1068 for itm in self.statusList.selectedItems(): |
1088 for itm in self.statusList.selectedItems(): |
1069 if itm.data(0, self.ConflictRole): |
1089 if itm.data(0, self.ConflictRole): |
1070 conflictingItems.append(itm) |
1090 conflictingItems.append(itm) |
1072 |
1092 |
1073 def __commitSelect(self, selected): |
1093 def __commitSelect(self, selected): |
1074 """ |
1094 """ |
1075 Private slot to select or deselect all entries. |
1095 Private slot to select or deselect all entries. |
1076 |
1096 |
1077 @param selected commit selection state to be set (boolean) |
1097 @param selected commit selection state to be set |
|
1098 @type bool |
1078 """ |
1099 """ |
1079 for index in range(self.statusList.topLevelItemCount()): |
1100 for index in range(self.statusList.topLevelItemCount()): |
1080 itm = self.statusList.topLevelItem(index) |
1101 itm = self.statusList.topLevelItem(index) |
1081 if ( |
1102 if ( |
1082 itm.flags() & Qt.ItemFlag.ItemIsUserCheckable |
1103 itm.flags() & Qt.ItemFlag.ItemIsUserCheckable |
1144 |
1165 |
1145 def __showLDiffContextMenu(self, coord): |
1166 def __showLDiffContextMenu(self, coord): |
1146 """ |
1167 """ |
1147 Private slot to show the context menu of the status list. |
1168 Private slot to show the context menu of the status list. |
1148 |
1169 |
1149 @param coord position of the mouse pointer (QPoint) |
1170 @param coord position of the mouse pointer |
|
1171 @type QPoint |
1150 """ |
1172 """ |
1151 if bool(self.lDiffEdit.toPlainText()): |
1173 if bool(self.lDiffEdit.toPlainText()): |
1152 cursor = self.lDiffEdit.textCursor() |
1174 cursor = self.lDiffEdit.textCursor() |
1153 if cursor.hasSelection(): |
1175 if cursor.hasSelection(): |
1154 self.__stageLinesAct.setEnabled(True) |
1176 self.__stageLinesAct.setEnabled(True) |
1168 |
1190 |
1169 def __showRDiffContextMenu(self, coord): |
1191 def __showRDiffContextMenu(self, coord): |
1170 """ |
1192 """ |
1171 Private slot to show the context menu of the status list. |
1193 Private slot to show the context menu of the status list. |
1172 |
1194 |
1173 @param coord position of the mouse pointer (QPoint) |
1195 @param coord position of the mouse pointer |
|
1196 @type QPoint |
1174 """ |
1197 """ |
1175 if bool(self.rDiffEdit.toPlainText()): |
1198 if bool(self.rDiffEdit.toPlainText()): |
1176 cursor = self.rDiffEdit.textCursor() |
1199 cursor = self.rDiffEdit.textCursor() |
1177 if cursor.hasSelection(): |
1200 if cursor.hasSelection(): |
1178 self.__unstageLinesAct.setEnabled(True) |
1201 self.__unstageLinesAct.setEnabled(True) |
1267 |
1290 |
1268 def __selectedLinesIndexes(self, diffEdit): |
1291 def __selectedLinesIndexes(self, diffEdit): |
1269 """ |
1292 """ |
1270 Private method to extract the indexes of the selected lines. |
1293 Private method to extract the indexes of the selected lines. |
1271 |
1294 |
1272 @param diffEdit reference to the edit widget (QTextEdit) |
1295 @param diffEdit reference to the edit widget |
1273 @return tuple of start and end indexes (integer, integer) |
1296 @type QTextEdit |
|
1297 @return tuple of start and end indexes |
|
1298 @rtype tuple of (int, int) |
1274 """ |
1299 """ |
1275 cursor = diffEdit.textCursor() |
1300 cursor = diffEdit.textCursor() |
1276 selectionStart = cursor.selectionStart() |
1301 selectionStart = cursor.selectionStart() |
1277 selectionEnd = cursor.selectionEnd() |
1302 selectionEnd = cursor.selectionEnd() |
1278 |
1303 |
1292 |
1317 |
1293 def __tmpPatchFileName(self): |
1318 def __tmpPatchFileName(self): |
1294 """ |
1319 """ |
1295 Private method to generate a temporary patch file. |
1320 Private method to generate a temporary patch file. |
1296 |
1321 |
1297 @return name of the temporary file (string) |
1322 @return name of the temporary file |
|
1323 @rtype str |
1298 """ |
1324 """ |
1299 prefix = "eric-git-{0}-".format(os.getpid()) |
1325 prefix = "eric-git-{0}-".format(os.getpid()) |
1300 suffix = "-patch" |
1326 suffix = "-patch" |
1301 fd, path = tempfile.mkstemp(suffix, prefix) |
1327 fd, path = tempfile.mkstemp(suffix, prefix) |
1302 os.close(fd) |
1328 os.close(fd) |