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

branch
eric7
changeset 9482
a2bc06a54d9d
parent 9473
3f23dbf37dbe
child 9573
9960d19d66b5
equal deleted inserted replaced
9481:0b936ff1bbb9 9482:a2bc06a54d9d
10 import contextlib 10 import contextlib
11 import os 11 import os
12 import pathlib 12 import pathlib
13 import re 13 import re
14 import shutil 14 import shutil
15 import sys
15 16
16 from PyQt6.QtCore import QProcess, pyqtSignal 17 from PyQt6.QtCore import QProcess, pyqtSignal
17 from PyQt6.QtWidgets import QApplication, QDialog, QInputDialog, QLineEdit 18 from PyQt6.QtWidgets import QApplication, QDialog, QInputDialog, QLineEdit
18 19
19 from eric7 import Globals, Preferences, Utilities 20 from eric7 import Globals, Preferences, Utilities
355 @param message message for this operation (string) 356 @param message message for this operation (string)
356 @param noDialog flag indicating quiet operations (boolean) 357 @param noDialog flag indicating quiet operations (boolean)
357 @param commitAll flag indicating to commit all local changes (boolean) 358 @param commitAll flag indicating to commit all local changes (boolean)
358 @param amend flag indicating to amend the HEAD commit (boolean) 359 @param amend flag indicating to amend the HEAD commit (boolean)
359 """ 360 """
361 from .GitCommitDialog import GitCommitDialog
362
360 if not noDialog: 363 if not noDialog:
361 # call CommitDialog and get message from there 364 # call CommitDialog and get message from there
362 if self.__commitDialog is None: 365 if self.__commitDialog is None:
363 from .GitCommitDialog import GitCommitDialog
364
365 self.__commitDialog = GitCommitDialog( 366 self.__commitDialog = GitCommitDialog(
366 self, message, amend, commitAll, self.__ui 367 self, message, amend, commitAll, self.__ui
367 ) 368 )
368 self.__commitDialog.accepted.connect(self.__vcsCommit_Step2) 369 self.__commitDialog.accepted.connect(self.__vcsCommit_Step2)
369 self.__commitDialog.show() 370 self.__commitDialog.show()
711 @param project reference to the project object 712 @param project reference to the project object
712 @param target new name of the file/directory (string) 713 @param target new name of the file/directory (string)
713 @param noDialog flag indicating quiet operations 714 @param noDialog flag indicating quiet operations
714 @return flag indicating successful operation (boolean) 715 @return flag indicating successful operation (boolean)
715 """ 716 """
717 from .GitCopyDialog import GitCopyDialog
718
716 isDir = os.path.isdir(name) 719 isDir = os.path.isdir(name)
717 720
718 res = False 721 res = False
719 if noDialog: 722 if noDialog:
720 if target is None: 723 if target is None:
721 return False 724 return False
722 force = True 725 force = True
723 accepted = True 726 accepted = True
724 else: 727 else:
725 from .GitCopyDialog import GitCopyDialog
726
727 dlg = GitCopyDialog(name, None, True) 728 dlg = GitCopyDialog(name, None, True)
728 accepted = dlg.exec() == QDialog.DialogCode.Accepted 729 accepted = dlg.exec() == QDialog.DialogCode.Accepted
729 if accepted: 730 if accepted:
730 target, force = dlg.getData() 731 target, force = dlg.getData()
731 732
773 774
774 @param name file/directory name to show the log of (string) 775 @param name file/directory name to show the log of (string)
775 @param isFile flag indicating log for a file is to be shown 776 @param isFile flag indicating log for a file is to be shown
776 (boolean) 777 (boolean)
777 """ 778 """
779 from .GitLogBrowserDialog import GitLogBrowserDialog
780
778 if self.logBrowser is None: 781 if self.logBrowser is None:
779 from .GitLogBrowserDialog import GitLogBrowserDialog
780
781 self.logBrowser = GitLogBrowserDialog(self) 782 self.logBrowser = GitLogBrowserDialog(self)
782 self.logBrowser.show() 783 self.logBrowser.show()
783 self.logBrowser.raise_() 784 self.logBrowser.raise_()
784 self.logBrowser.start(name, isFile=isFile) 785 self.logBrowser.start(name, isFile=isFile)
785 786
787 """ 788 """
788 Public method used to browse the reflog of the project. 789 Public method used to browse the reflog of the project.
789 790
790 @param projectDir name of the project directory (string) 791 @param projectDir name of the project directory (string)
791 """ 792 """
793 from .GitReflogBrowserDialog import GitReflogBrowserDialog
794
792 if self.reflogBrowser is None: 795 if self.reflogBrowser is None:
793 from .GitReflogBrowserDialog import GitReflogBrowserDialog
794
795 self.reflogBrowser = GitReflogBrowserDialog(self) 796 self.reflogBrowser = GitReflogBrowserDialog(self)
796 self.reflogBrowser.show() 797 self.reflogBrowser.show()
797 self.reflogBrowser.raise_() 798 self.reflogBrowser.raise_()
798 self.reflogBrowser.start(projectDir) 799 self.reflogBrowser.start(projectDir)
799 800
807 being edited and has unsaved modification, they can be saved or the 808 being edited and has unsaved modification, they can be saved or the
808 operation may be aborted. 809 operation may be aborted.
809 810
810 @param name file/directory name to be diffed (string) 811 @param name file/directory name to be diffed (string)
811 """ 812 """
813 from .GitDiffDialog import GitDiffDialog
814
812 names = name[:] if isinstance(name, list) else [name] 815 names = name[:] if isinstance(name, list) else [name]
813 for nam in names: 816 for nam in names:
814 if os.path.isfile(nam): 817 if os.path.isfile(nam):
815 editor = ericApp().getObject("ViewManager").getOpenEditor(nam) 818 editor = ericApp().getObject("ViewManager").getOpenEditor(nam)
816 if editor and not editor.checkDirty(): 819 if editor and not editor.checkDirty():
818 else: 821 else:
819 project = ericApp().getObject("Project") 822 project = ericApp().getObject("Project")
820 if nam == project.ppath and not project.saveAllScripts(): 823 if nam == project.ppath and not project.saveAllScripts():
821 return 824 return
822 if self.diff is None: 825 if self.diff is None:
823 from .GitDiffDialog import GitDiffDialog
824
825 self.diff = GitDiffDialog(self) 826 self.diff = GitDiffDialog(self)
826 self.diff.show() 827 self.diff.show()
827 self.diff.raise_() 828 self.diff.raise_()
828 QApplication.processEvents() 829 QApplication.processEvents()
829 self.diff.start(name, diffMode="work2stage2repo", refreshable=True) 830 self.diff.start(name, diffMode="work2stage2repo", refreshable=True)
834 Git repository. 835 Git repository.
835 836
836 @param name file/directory name(s) to show the status of 837 @param name file/directory name(s) to show the status of
837 (string or list of strings) 838 (string or list of strings)
838 """ 839 """
840 from .GitStatusDialog import GitStatusDialog
841
839 if self.status is None: 842 if self.status is None:
840 from .GitStatusDialog import GitStatusDialog
841
842 self.status = GitStatusDialog(self) 843 self.status = GitStatusDialog(self)
843 self.status.show() 844 self.status.show()
844 self.status.raise_() 845 self.status.raise_()
845 self.status.start(name) 846 self.status.start(name)
846 847
889 @type str 890 @type str
890 @return flag indicating, that the update contained an add 891 @return flag indicating, that the update contained an add
891 or delete 892 or delete
892 @rtype bool 893 @rtype bool
893 """ 894 """
895 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog
896
894 args = self.initCommand("checkout") 897 args = self.initCommand("checkout")
895 args.append("--") 898 args.append("--")
896 if isinstance(name, list): 899 if isinstance(name, list):
897 dname, fnames = self.splitPathList(name) 900 dname, fnames = self.splitPathList(name)
898 self.addArguments(args, name) 901 self.addArguments(args, name)
910 return False 913 return False
911 914
912 project = ericApp().getObject("Project") 915 project = ericApp().getObject("Project")
913 names = [project.getRelativePath(nam) for nam in names] 916 names = [project.getRelativePath(nam) for nam in names]
914 if names[0]: 917 if names[0]:
915 from eric7.UI.DeleteFilesConfirmationDialog import (
916 DeleteFilesConfirmationDialog,
917 )
918
919 dlg = DeleteFilesConfirmationDialog( 918 dlg = DeleteFilesConfirmationDialog(
920 self.parent(), 919 self.parent(),
921 self.tr("Revert changes"), 920 self.tr("Revert changes"),
922 self.tr( 921 self.tr(
923 "Do you really want to revert all changes to these files" 922 "Do you really want to revert all changes to these files"
951 """ 950 """
952 Public method used to merge a URL/revision into the local project. 951 Public method used to merge a URL/revision into the local project.
953 952
954 @param name file/directory name to be merged (string) 953 @param name file/directory name to be merged (string)
955 """ 954 """
955 from .GitMergeDialog import GitMergeDialog
956
956 dname, fname = self.splitPath(name) 957 dname, fname = self.splitPath(name)
957 958
958 # find the root of the repo 959 # find the root of the repo
959 repodir = dname 960 repodir = dname
960 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 961 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
961 repodir = os.path.dirname(repodir) 962 repodir = os.path.dirname(repodir)
962 if os.path.splitdrive(repodir)[1] == os.sep: 963 if os.path.splitdrive(repodir)[1] == os.sep:
963 return 964 return
964
965 from .GitMergeDialog import GitMergeDialog
966 965
967 dlg = GitMergeDialog( 966 dlg = GitMergeDialog(
968 self.gitGetTagsList(repodir), 967 self.gitGetTagsList(repodir),
969 self.gitGetBranchesList(repodir, withMaster=True), 968 self.gitGetBranchesList(repodir, withMaster=True),
970 self.gitGetCurrentBranch(repodir), 969 self.gitGetCurrentBranch(repodir),
1003 1002
1004 @param name directory name to be switched (string) 1003 @param name directory name to be switched (string)
1005 @return flag indicating, that the switch contained an add 1004 @return flag indicating, that the switch contained an add
1006 or delete (boolean) 1005 or delete (boolean)
1007 """ 1006 """
1007 from .GitRevisionSelectionDialog import GitRevisionSelectionDialog
1008
1008 dname, fname = self.splitPath(name) 1009 dname, fname = self.splitPath(name)
1009 1010
1010 # find the root of the repo 1011 # find the root of the repo
1011 repodir = dname 1012 repodir = dname
1012 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1013 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1013 repodir = os.path.dirname(repodir) 1014 repodir = os.path.dirname(repodir)
1014 if os.path.splitdrive(repodir)[1] == os.sep: 1015 if os.path.splitdrive(repodir)[1] == os.sep:
1015 return False 1016 return False
1016
1017 from .GitRevisionSelectionDialog import GitRevisionSelectionDialog
1018 1017
1019 dlg = GitRevisionSelectionDialog( 1018 dlg = GitRevisionSelectionDialog(
1020 self.gitGetTagsList(repodir), 1019 self.gitGetTagsList(repodir),
1021 self.gitGetBranchesList(repodir), 1020 self.gitGetBranchesList(repodir),
1022 trackingBranchesList=self.gitGetBranchesList(repodir, remotes=True), 1021 trackingBranchesList=self.gitGetBranchesList(repodir, remotes=True),
1550 @param name file name to show the annotations for 1549 @param name file name to show the annotations for
1551 @type str 1550 @type str
1552 @param skiplist name of a skip list file 1551 @param skiplist name of a skip list file
1553 @type str 1552 @type str
1554 """ 1553 """
1554 from .GitBlameDialog import GitBlameDialog
1555
1555 if self.blame is None: 1556 if self.blame is None:
1556 from .GitBlameDialog import GitBlameDialog
1557
1558 self.blame = GitBlameDialog(self) 1557 self.blame = GitBlameDialog(self)
1559 self.blame.show() 1558 self.blame.show()
1560 self.blame.raise_() 1559 self.blame.raise_()
1561 self.blame.start(name, skiplist=skiplist) 1560 self.blame.start(name, skiplist=skiplist)
1562 1561
1572 1571
1573 This method gives the chance to enter the revisions to be compared. 1572 This method gives the chance to enter the revisions to be compared.
1574 1573
1575 @param name file/directory name to be diffed (string) 1574 @param name file/directory name to be diffed (string)
1576 """ 1575 """
1576 from .GitDiffDialog import GitDiffDialog
1577 from .GitRevisionsSelectionDialog import GitRevisionsSelectionDialog
1578
1577 if isinstance(name, list): 1579 if isinstance(name, list):
1578 dname, fnames = self.splitPathList(name) 1580 dname, fnames = self.splitPathList(name)
1579 names = name[:] 1581 names = name[:]
1580 else: 1582 else:
1581 dname, fname = self.splitPath(name) 1583 dname, fname = self.splitPath(name)
1595 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1597 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1596 repodir = os.path.dirname(repodir) 1598 repodir = os.path.dirname(repodir)
1597 if os.path.splitdrive(repodir)[1] == os.sep: 1599 if os.path.splitdrive(repodir)[1] == os.sep:
1598 return 1600 return
1599 1601
1600 from .GitRevisionsSelectionDialog import GitRevisionsSelectionDialog
1601
1602 dlg = GitRevisionsSelectionDialog( 1602 dlg = GitRevisionsSelectionDialog(
1603 self.gitGetTagsList(repodir), self.gitGetBranchesList(repodir) 1603 self.gitGetTagsList(repodir), self.gitGetBranchesList(repodir)
1604 ) 1604 )
1605 if dlg.exec() == QDialog.DialogCode.Accepted: 1605 if dlg.exec() == QDialog.DialogCode.Accepted:
1606 revisions = dlg.getRevisions() 1606 revisions = dlg.getRevisions()
1607 if self.diff is None: 1607 if self.diff is None:
1608 from .GitDiffDialog import GitDiffDialog
1609
1610 self.diff = GitDiffDialog(self) 1608 self.diff = GitDiffDialog(self)
1611 self.diff.show() 1609 self.diff.show()
1612 self.diff.raise_() 1610 self.diff.raise_()
1613 self.diff.start(name, revisions) 1611 self.diff.start(name, revisions)
1614 1612
1673 @param name file name to be diffed (string) 1671 @param name file name to be diffed (string)
1674 @param extended flag indicating the extended variant (boolean) 1672 @param extended flag indicating the extended variant (boolean)
1675 @param revisions tuple of two revisions (tuple of strings) 1673 @param revisions tuple of two revisions (tuple of strings)
1676 @exception ValueError raised to indicate an invalid name parameter 1674 @exception ValueError raised to indicate an invalid name parameter
1677 """ 1675 """
1676 from eric7.UI.CompareDialog import CompareDialog
1677
1678 from .GitRevisionsSelectionDialog import GitRevisionsSelectionDialog
1679
1678 if isinstance(name, list): 1680 if isinstance(name, list):
1679 raise ValueError("Wrong parameter type") 1681 raise ValueError("Wrong parameter type")
1680 1682
1681 if extended: 1683 if extended:
1682 # find the root of the repo 1684 # find the root of the repo
1683 repodir = self.splitPath(name)[0] 1685 repodir = self.splitPath(name)[0]
1684 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1686 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1685 repodir = os.path.dirname(repodir) 1687 repodir = os.path.dirname(repodir)
1686 if os.path.splitdrive(repodir)[1] == os.sep: 1688 if os.path.splitdrive(repodir)[1] == os.sep:
1687 return 1689 return
1688
1689 from .GitRevisionsSelectionDialog import GitRevisionsSelectionDialog
1690 1690
1691 dlg = GitRevisionsSelectionDialog( 1691 dlg = GitRevisionsSelectionDialog(
1692 self.gitGetTagsList(repodir), self.gitGetBranchesList(repodir) 1692 self.gitGetTagsList(repodir), self.gitGetBranchesList(repodir)
1693 ) 1693 )
1694 if dlg.exec() == QDialog.DialogCode.Accepted: 1694 if dlg.exec() == QDialog.DialogCode.Accepted:
1731 ), 1731 ),
1732 ) 1732 )
1733 return 1733 return
1734 1734
1735 if self.sbsDiff is None: 1735 if self.sbsDiff is None:
1736 from eric7.UI.CompareDialog import CompareDialog
1737
1738 self.sbsDiff = CompareDialog() 1736 self.sbsDiff = CompareDialog()
1739 self.sbsDiff.show() 1737 self.sbsDiff.show()
1740 self.sbsDiff.raise_() 1738 self.sbsDiff.raise_()
1741 self.sbsDiff.compare(output1, output2, name1, name2) 1739 self.sbsDiff.compare(output1, output2, name1, name2)
1742 1740
1744 """ 1742 """
1745 Public method to fetch changes from a remote repository. 1743 Public method to fetch changes from a remote repository.
1746 1744
1747 @param name directory name (string) 1745 @param name directory name (string)
1748 """ 1746 """
1747 from .GitFetchDialog import GitFetchDialog
1748
1749 # find the root of the repo 1749 # find the root of the repo
1750 repodir = self.splitPath(name)[0] 1750 repodir = self.splitPath(name)[0]
1751 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1751 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1752 repodir = os.path.dirname(repodir) 1752 repodir = os.path.dirname(repodir)
1753 if os.path.splitdrive(repodir)[1] == os.sep: 1753 if os.path.splitdrive(repodir)[1] == os.sep:
1754 return 1754 return
1755
1756 from .GitFetchDialog import GitFetchDialog
1757 1755
1758 dlg = GitFetchDialog(self, repodir) 1756 dlg = GitFetchDialog(self, repodir)
1759 if dlg.exec() == QDialog.DialogCode.Accepted: 1757 if dlg.exec() == QDialog.DialogCode.Accepted:
1760 ( 1758 (
1761 remote, 1759 remote,
1794 1792
1795 @param name directory name of the project to be pulled to (string) 1793 @param name directory name of the project to be pulled to (string)
1796 @return flag indicating, that the update contained an add 1794 @return flag indicating, that the update contained an add
1797 or delete (boolean) 1795 or delete (boolean)
1798 """ 1796 """
1797 from .GitPullDialog import GitPullDialog
1798
1799 # find the root of the repo 1799 # find the root of the repo
1800 repodir = self.splitPath(name)[0] 1800 repodir = self.splitPath(name)[0]
1801 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1801 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1802 repodir = os.path.dirname(repodir) 1802 repodir = os.path.dirname(repodir)
1803 if os.path.splitdrive(repodir)[1] == os.sep: 1803 if os.path.splitdrive(repodir)[1] == os.sep:
1804 return False 1804 return False
1805
1806 from .GitPullDialog import GitPullDialog
1807 1805
1808 dlg = GitPullDialog(self, repodir) 1806 dlg = GitPullDialog(self, repodir)
1809 if dlg.exec() == QDialog.DialogCode.Accepted: 1807 if dlg.exec() == QDialog.DialogCode.Accepted:
1810 remote, url, branches, pullAll, prune = dlg.getData() 1808 remote, url, branches, pullAll, prune = dlg.getData()
1811 1809
1834 """ 1832 """
1835 Public method used to push changes to a remote Git repository. 1833 Public method used to push changes to a remote Git repository.
1836 1834
1837 @param name directory name of the project to be pushed from (string) 1835 @param name directory name of the project to be pushed from (string)
1838 """ 1836 """
1837 from .GitPushDialog import GitPushDialog
1838
1839 # find the root of the repo 1839 # find the root of the repo
1840 repodir = self.splitPath(name)[0] 1840 repodir = self.splitPath(name)[0]
1841 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1841 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1842 repodir = os.path.dirname(repodir) 1842 repodir = os.path.dirname(repodir)
1843 if os.path.splitdrive(repodir)[1] == os.sep: 1843 if os.path.splitdrive(repodir)[1] == os.sep:
1844 return 1844 return
1845
1846 from .GitPushDialog import GitPushDialog
1847 1845
1848 dlg = GitPushDialog(self, repodir) 1846 dlg = GitPushDialog(self, repodir)
1849 if dlg.exec() == QDialog.DialogCode.Accepted: 1847 if dlg.exec() == QDialog.DialogCode.Accepted:
1850 remote, refspecs, tags, tracking, submodule = dlg.getData() 1848 remote, refspecs, tags, tracking, submodule = dlg.getData()
1851 1849
1880 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1878 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1881 repodir = os.path.dirname(repodir) 1879 repodir = os.path.dirname(repodir)
1882 if os.path.splitdrive(repodir)[1] == os.sep: 1880 if os.path.splitdrive(repodir)[1] == os.sep:
1883 return 1881 return
1884 1882
1885 import sys
1886
1887 editor = sys.argv[0].replace(".py", "_editor.py") 1883 editor = sys.argv[0].replace(".py", "_editor.py")
1888 env = {"GIT_EDITOR": "{0} {1}".format(Globals.getPythonExecutable(), editor)} 1884 env = {"GIT_EDITOR": "{0} {1}".format(Globals.getPythonExecutable(), editor)}
1889 1885
1890 args = self.initCommand("commit") 1886 args = self.initCommand("commit")
1891 1887
1957 apply cleanly. 1953 apply cleanly.
1958 1954
1959 @param projectDir directory name of the project (string) 1955 @param projectDir directory name of the project (string)
1960 @param check flag indicating to perform a check operation (boolean) 1956 @param check flag indicating to perform a check operation (boolean)
1961 """ 1957 """
1958 from .GitPatchFilesDialog import GitPatchFilesDialog
1959
1962 # find the root of the repo 1960 # find the root of the repo
1963 repodir = projectDir 1961 repodir = projectDir
1964 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1962 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1965 repodir = os.path.dirname(repodir) 1963 repodir = os.path.dirname(repodir)
1966 if os.path.splitdrive(repodir)[1] == os.sep: 1964 if os.path.splitdrive(repodir)[1] == os.sep:
1967 return 1965 return
1968
1969 from .GitPatchFilesDialog import GitPatchFilesDialog
1970 1966
1971 dlg = GitPatchFilesDialog(repodir, self.__patchCheckData) 1967 dlg = GitPatchFilesDialog(repodir, self.__patchCheckData)
1972 if dlg.exec() == QDialog.DialogCode.Accepted: 1968 if dlg.exec() == QDialog.DialogCode.Accepted:
1973 patchFilesList, stripCount, inaccurateEof, recount = dlg.getData() 1969 patchFilesList, stripCount, inaccurateEof, recount = dlg.getData()
1974 if patchFilesList: 1970 if patchFilesList:
2003 """ 1999 """
2004 Public method to show statistics for a set of patch files. 2000 Public method to show statistics for a set of patch files.
2005 2001
2006 @param projectDir directory name of the project (string) 2002 @param projectDir directory name of the project (string)
2007 """ 2003 """
2004 from .GitPatchStatisticsDialog import GitPatchStatisticsDialog
2005
2008 if self.patchStatisticsDialog is None: 2006 if self.patchStatisticsDialog is None:
2009 from .GitPatchStatisticsDialog import GitPatchStatisticsDialog
2010
2011 self.patchStatisticsDialog = GitPatchStatisticsDialog(self) 2007 self.patchStatisticsDialog = GitPatchStatisticsDialog(self)
2012 self.patchStatisticsDialog.show() 2008 self.patchStatisticsDialog.show()
2013 self.patchStatisticsDialog.raise_() 2009 self.patchStatisticsDialog.raise_()
2014 self.patchStatisticsDialog.start(projectDir, self.__patchCheckData) 2010 self.patchStatisticsDialog.start(projectDir, self.__patchCheckData)
2015 self.__patchCheckData = self.patchStatisticsDialog.getData() 2011 self.__patchCheckData = self.patchStatisticsDialog.getData()
2026 (string) 2022 (string)
2027 @param revision revision to set tag for (string) 2023 @param revision revision to set tag for (string)
2028 @param tagName name of the tag (string) 2024 @param tagName name of the tag (string)
2029 @return flag indicating a performed tag action (boolean) 2025 @return flag indicating a performed tag action (boolean)
2030 """ 2026 """
2027 from .GitTagDialog import GitTagDialog
2028
2031 dname, fname = self.splitPath(name) 2029 dname, fname = self.splitPath(name)
2032 2030
2033 # find the root of the repo 2031 # find the root of the repo
2034 repodir = dname 2032 repodir = dname
2035 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 2033 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2036 repodir = os.path.dirname(repodir) 2034 repodir = os.path.dirname(repodir)
2037 if os.path.splitdrive(repodir)[1] == os.sep: 2035 if os.path.splitdrive(repodir)[1] == os.sep:
2038 return False 2036 return False
2039
2040 from .GitTagDialog import GitTagDialog
2041 2037
2042 dlg = GitTagDialog(self.gitGetTagsList(repodir), revision, tagName) 2038 dlg = GitTagDialog(self.gitGetTagsList(repodir), revision, tagName)
2043 if dlg.exec() == QDialog.DialogCode.Accepted: 2039 if dlg.exec() == QDialog.DialogCode.Accepted:
2044 tag, revision, tagOp, tagType, force = dlg.getParameters() 2040 tag, revision, tagOp, tagType, force = dlg.getParameters()
2045 else: 2041 else:
2117 (False = branches, True = tags) 2113 (False = branches, True = tags)
2118 @param listAll flag indicating to show all tags or branches (boolean) 2114 @param listAll flag indicating to show all tags or branches (boolean)
2119 @param merged flag indicating to show only merged or non-merged 2115 @param merged flag indicating to show only merged or non-merged
2120 branches (boolean) 2116 branches (boolean)
2121 """ 2117 """
2118 from .GitTagBranchListDialog import GitTagBranchListDialog
2119
2122 if self.tagbranchList is None: 2120 if self.tagbranchList is None:
2123 from .GitTagBranchListDialog import GitTagBranchListDialog
2124
2125 self.tagbranchList = GitTagBranchListDialog(self) 2121 self.tagbranchList = GitTagBranchListDialog(self)
2126 self.tagbranchList.show() 2122 self.tagbranchList.show()
2127 self.tagbranchList.raise_() 2123 self.tagbranchList.raise_()
2128 if tags: 2124 if tags:
2129 self.tagbranchList.start(path, tags) 2125 self.tagbranchList.start(path, tags)
2228 @param branchOp desired branch operation (integer) 2224 @param branchOp desired branch operation (integer)
2229 @return flag indicating a performed branch action (boolean) and 2225 @return flag indicating a performed branch action (boolean) and
2230 a flag indicating, that the branch operation contained an add 2226 a flag indicating, that the branch operation contained an add
2231 or delete (boolean) 2227 or delete (boolean)
2232 """ 2228 """
2229 from .GitBranchDialog import GitBranchDialog
2230
2233 dname, fname = self.splitPath(name) 2231 dname, fname = self.splitPath(name)
2234 2232
2235 # find the root of the repo 2233 # find the root of the repo
2236 repodir = dname 2234 repodir = dname
2237 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 2235 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2238 repodir = os.path.dirname(repodir) 2236 repodir = os.path.dirname(repodir)
2239 if os.path.splitdrive(repodir)[1] == os.sep: 2237 if os.path.splitdrive(repodir)[1] == os.sep:
2240 return False, False 2238 return False, False
2241
2242 from .GitBranchDialog import GitBranchDialog
2243 2239
2244 dlg = GitBranchDialog( 2240 dlg = GitBranchDialog(
2245 self.gitGetBranchesList(repodir, allBranches=True), 2241 self.gitGetBranchesList(repodir, allBranches=True),
2246 revision, 2242 revision,
2247 branchName, 2243 branchName,
2332 """ 2328 """
2333 Public method to delete a branch from a remote repository. 2329 Public method to delete a branch from a remote repository.
2334 2330
2335 @param name file/directory name (string) 2331 @param name file/directory name (string)
2336 """ 2332 """
2333 from .GitBranchPushDialog import GitBranchPushDialog
2334
2337 dname, fname = self.splitPath(name) 2335 dname, fname = self.splitPath(name)
2338 2336
2339 # find the root of the repo 2337 # find the root of the repo
2340 repodir = dname 2338 repodir = dname
2341 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 2339 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2342 repodir = os.path.dirname(repodir) 2340 repodir = os.path.dirname(repodir)
2343 if os.path.splitdrive(repodir)[1] == os.sep: 2341 if os.path.splitdrive(repodir)[1] == os.sep:
2344 return 2342 return
2345
2346 from .GitBranchPushDialog import GitBranchPushDialog
2347 2343
2348 dlg = GitBranchPushDialog( 2344 dlg = GitBranchPushDialog(
2349 self.gitGetBranchesList(repodir), 2345 self.gitGetBranchesList(repodir),
2350 self.gitGetRemotesList(repodir), 2346 self.gitGetRemotesList(repodir),
2351 delete=True, 2347 delete=True,
2394 """ 2390 """
2395 Public method to create a bundle file. 2391 Public method to create a bundle file.
2396 2392
2397 @param projectDir name of the project directory (string) 2393 @param projectDir name of the project directory (string)
2398 """ 2394 """
2395 from .GitBundleDialog import GitBundleDialog
2396
2399 # find the root of the repo 2397 # find the root of the repo
2400 repodir = projectDir 2398 repodir = projectDir
2401 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 2399 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2402 repodir = os.path.dirname(repodir) 2400 repodir = os.path.dirname(repodir)
2403 if os.path.splitdrive(repodir)[1] == os.sep: 2401 if os.path.splitdrive(repodir)[1] == os.sep:
2404 return 2402 return
2405
2406 from .GitBundleDialog import GitBundleDialog
2407 2403
2408 dlg = GitBundleDialog( 2404 dlg = GitBundleDialog(
2409 self.gitGetTagsList(repodir), self.gitGetBranchesList(repodir) 2405 self.gitGetTagsList(repodir), self.gitGetBranchesList(repodir)
2410 ) 2406 )
2411 if dlg.exec() == QDialog.DialogCode.Accepted: 2407 if dlg.exec() == QDialog.DialogCode.Accepted:
2555 Public method to fetch a head of a bundle file into the local 2551 Public method to fetch a head of a bundle file into the local
2556 repository. 2552 repository.
2557 2553
2558 @param projectDir name of the project directory (string) 2554 @param projectDir name of the project directory (string)
2559 """ 2555 """
2556 from .GitApplyBundleDataDialog import GitApplyBundleDataDialog
2557
2560 # find the root of the repo 2558 # find the root of the repo
2561 repodir = projectDir 2559 repodir = projectDir
2562 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 2560 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2563 repodir = os.path.dirname(repodir) 2561 repodir = os.path.dirname(repodir)
2564 if os.path.splitdrive(repodir)[1] == os.sep: 2562 if os.path.splitdrive(repodir)[1] == os.sep:
2571 self.tr("Git Bundle Files (*.bundle);;All Files (*)"), 2569 self.tr("Git Bundle Files (*.bundle);;All Files (*)"),
2572 ) 2570 )
2573 if fname: 2571 if fname:
2574 self.__lastBundlePath = os.path.dirname(fname) 2572 self.__lastBundlePath = os.path.dirname(fname)
2575 2573
2576 from .GitApplyBundleDataDialog import GitApplyBundleDataDialog
2577
2578 dlg = GitApplyBundleDataDialog( 2574 dlg = GitApplyBundleDataDialog(
2579 self.gitGetBundleHeads(repodir, fname), self.gitGetBranchesList(repodir) 2575 self.gitGetBundleHeads(repodir, fname), self.gitGetBranchesList(repodir)
2580 ) 2576 )
2581 if dlg.exec() == QDialog.DialogCode.Accepted: 2577 if dlg.exec() == QDialog.DialogCode.Accepted:
2582 bundleHead, branch = dlg.getData() 2578 bundleHead, branch = dlg.getData()
2603 2599
2604 @param projectDir name of the project directory (string) 2600 @param projectDir name of the project directory (string)
2605 @return flag indicating, that the update contained an add 2601 @return flag indicating, that the update contained an add
2606 or delete (boolean) 2602 or delete (boolean)
2607 """ 2603 """
2604 from .GitApplyBundleDataDialog import GitApplyBundleDataDialog
2605
2608 # find the root of the repo 2606 # find the root of the repo
2609 repodir = projectDir 2607 repodir = projectDir
2610 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 2608 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
2611 repodir = os.path.dirname(repodir) 2609 repodir = os.path.dirname(repodir)
2612 if os.path.splitdrive(repodir)[1] == os.sep: 2610 if os.path.splitdrive(repodir)[1] == os.sep:
2620 self.tr("Git Bundle Files (*.bundle);;All Files (*)"), 2618 self.tr("Git Bundle Files (*.bundle);;All Files (*)"),
2621 ) 2619 )
2622 if fname: 2620 if fname:
2623 self.__lastBundlePath = os.path.dirname(fname) 2621 self.__lastBundlePath = os.path.dirname(fname)
2624 2622
2625 from .GitApplyBundleDataDialog import GitApplyBundleDataDialog
2626
2627 dlg = GitApplyBundleDataDialog( 2623 dlg = GitApplyBundleDataDialog(
2628 self.gitGetBundleHeads(repodir, fname), self.gitGetBranchesList(repodir) 2624 self.gitGetBundleHeads(repodir, fname), self.gitGetBranchesList(repodir)
2629 ) 2625 )
2630 if dlg.exec() == QDialog.DialogCode.Accepted: 2626 if dlg.exec() == QDialog.DialogCode.Accepted:
2631 bundleHead, branch = dlg.getData() 2627 bundleHead, branch = dlg.getData()
2660 'start_extended', 'good', 'bad', 'skip' or 'reset') 2656 'start_extended', 'good', 'bad', 'skip' or 'reset')
2661 @return flag indicating, that the update contained an add 2657 @return flag indicating, that the update contained an add
2662 or delete (boolean) 2658 or delete (boolean)
2663 @exception ValueError raised to indicate an invalid bisect subcommand 2659 @exception ValueError raised to indicate an invalid bisect subcommand
2664 """ 2660 """
2661 from .GitBisectStartDialog import GitBisectStartDialog
2662 from .GitRevisionSelectionDialog import GitRevisionSelectionDialog
2663
2665 if subcommand not in ( 2664 if subcommand not in (
2666 "start", 2665 "start",
2667 "start_extended", 2666 "start_extended",
2668 "good", 2667 "good",
2669 "bad", 2668 "bad",
2684 res = False 2683 res = False
2685 rev = "" 2684 rev = ""
2686 if subcommand in ("good", "bad", "skip", "reset"): 2685 if subcommand in ("good", "bad", "skip", "reset"):
2687 showBranches = subcommand == "reset" 2686 showBranches = subcommand == "reset"
2688 showHead = subcommand == "reset" 2687 showHead = subcommand == "reset"
2689 from .GitRevisionSelectionDialog import GitRevisionSelectionDialog
2690
2691 dlg = GitRevisionSelectionDialog( 2688 dlg = GitRevisionSelectionDialog(
2692 self.gitGetTagsList(repodir), 2689 self.gitGetTagsList(repodir),
2693 self.gitGetBranchesList(repodir), 2690 self.gitGetBranchesList(repodir),
2694 showBranches=showBranches, 2691 showBranches=showBranches,
2695 showHead=showHead, 2692 showHead=showHead,
2699 else: 2696 else:
2700 return False 2697 return False
2701 2698
2702 args = self.initCommand("bisect") 2699 args = self.initCommand("bisect")
2703 if subcommand == "start_extended": 2700 if subcommand == "start_extended":
2704 from .GitBisectStartDialog import GitBisectStartDialog
2705
2706 dlg = GitBisectStartDialog() 2701 dlg = GitBisectStartDialog()
2707 if dlg.exec() == QDialog.DialogCode.Accepted: 2702 if dlg.exec() == QDialog.DialogCode.Accepted:
2708 bad, good, noCheckout = dlg.getData() 2703 bad, good, noCheckout = dlg.getData()
2709 args.append("start") 2704 args.append("start")
2710 if noCheckout: 2705 if noCheckout:
2733 """ 2728 """
2734 Public method used to browse the bisect log of the project. 2729 Public method used to browse the bisect log of the project.
2735 2730
2736 @param projectDir name of the project directory (string) 2731 @param projectDir name of the project directory (string)
2737 """ 2732 """
2733 from .GitBisectLogBrowserDialog import GitBisectLogBrowserDialog
2734
2738 if self.bisectlogBrowser is None: 2735 if self.bisectlogBrowser is None:
2739 from .GitBisectLogBrowserDialog import GitBisectLogBrowserDialog
2740
2741 self.bisectlogBrowser = GitBisectLogBrowserDialog(self) 2736 self.bisectlogBrowser = GitBisectLogBrowserDialog(self)
2742 self.bisectlogBrowser.show() 2737 self.bisectlogBrowser.show()
2743 self.bisectlogBrowser.raise_() 2738 self.bisectlogBrowser.raise_()
2744 self.bisectlogBrowser.start(projectDir) 2739 self.bisectlogBrowser.start(projectDir)
2745 2740
3056 """ 3051 """
3057 Public method to show available remote repositories. 3052 Public method to show available remote repositories.
3058 3053
3059 @param projectDir name of the project directory (string) 3054 @param projectDir name of the project directory (string)
3060 """ 3055 """
3056 from .GitRemoteRepositoriesDialog import GitRemoteRepositoriesDialog
3057
3061 if self.remotesDialog is None: 3058 if self.remotesDialog is None:
3062 from .GitRemoteRepositoriesDialog import GitRemoteRepositoriesDialog
3063
3064 self.remotesDialog = GitRemoteRepositoriesDialog(self) 3059 self.remotesDialog = GitRemoteRepositoriesDialog(self)
3065 self.remotesDialog.show() 3060 self.remotesDialog.show()
3066 self.remotesDialog.raise_() 3061 self.remotesDialog.raise_()
3067 self.remotesDialog.start(projectDir) 3062 self.remotesDialog.start(projectDir)
3068 3063
3070 """ 3065 """
3071 Public method to add a remote repository. 3066 Public method to add a remote repository.
3072 3067
3073 @param projectDir name of the project directory (string) 3068 @param projectDir name of the project directory (string)
3074 """ 3069 """
3070 from .GitAddRemoteDialog import GitAddRemoteDialog
3071
3075 # find the root of the repo 3072 # find the root of the repo
3076 repodir = projectDir 3073 repodir = projectDir
3077 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3074 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3078 repodir = os.path.dirname(repodir) 3075 repodir = os.path.dirname(repodir)
3079 if os.path.splitdrive(repodir)[1] == os.sep: 3076 if os.path.splitdrive(repodir)[1] == os.sep:
3080 return 3077 return
3081
3082 from .GitAddRemoteDialog import GitAddRemoteDialog
3083 3078
3084 dlg = GitAddRemoteDialog() 3079 dlg = GitAddRemoteDialog()
3085 if dlg.exec() == QDialog.DialogCode.Accepted: 3080 if dlg.exec() == QDialog.DialogCode.Accepted:
3086 name, url = dlg.getData() 3081 name, url = dlg.getData()
3087 args = self.initCommand("remote") 3082 args = self.initCommand("remote")
3128 @param remoteName name of the remote repository 3123 @param remoteName name of the remote repository
3129 @type str 3124 @type str
3130 @param remoteUrl URL of the remote repository 3125 @param remoteUrl URL of the remote repository
3131 @type str 3126 @type str
3132 """ 3127 """
3128 from .GitChangeRemoteUrlDialog import GitChangeRemoteUrlDialog
3129
3133 # find the root of the repo 3130 # find the root of the repo
3134 repodir = projectDir 3131 repodir = projectDir
3135 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3132 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3136 repodir = os.path.dirname(repodir) 3133 repodir = os.path.dirname(repodir)
3137 if os.path.splitdrive(repodir)[1] == os.sep: 3134 if os.path.splitdrive(repodir)[1] == os.sep:
3138 return 3135 return
3139 3136
3140 if not remoteUrl: 3137 if not remoteUrl:
3141 remoteUrl = self.gitGetRemoteUrl(repodir, remoteName) 3138 remoteUrl = self.gitGetRemoteUrl(repodir, remoteName)
3142
3143 from .GitChangeRemoteUrlDialog import GitChangeRemoteUrlDialog
3144 3139
3145 dlg = GitChangeRemoteUrlDialog(remoteName, remoteUrl) 3140 dlg = GitChangeRemoteUrlDialog(remoteName, remoteUrl)
3146 if dlg.exec() == QDialog.DialogCode.Accepted: 3141 if dlg.exec() == QDialog.DialogCode.Accepted:
3147 name, url = dlg.getData() 3142 name, url = dlg.getData()
3148 if url != remoteUrl: 3143 if url != remoteUrl:
3164 @param remoteName name of the remote repository 3159 @param remoteName name of the remote repository
3165 @type str 3160 @type str
3166 @param remoteUrl URL of the remote repository 3161 @param remoteUrl URL of the remote repository
3167 @type str 3162 @type str
3168 """ 3163 """
3164 from .GitRemoteCredentialsDialog import GitRemoteCredentialsDialog
3165
3169 # find the root of the repo 3166 # find the root of the repo
3170 repodir = projectDir 3167 repodir = projectDir
3171 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3168 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3172 repodir = os.path.dirname(repodir) 3169 repodir = os.path.dirname(repodir)
3173 if os.path.splitdrive(repodir)[1] == os.sep: 3170 if os.path.splitdrive(repodir)[1] == os.sep:
3174 return 3171 return
3175 3172
3176 if not remoteUrl: 3173 if not remoteUrl:
3177 remoteUrl = self.gitGetRemoteUrl(repodir, remoteName) 3174 remoteUrl = self.gitGetRemoteUrl(repodir, remoteName)
3178
3179 from .GitRemoteCredentialsDialog import GitRemoteCredentialsDialog
3180 3175
3181 dlg = GitRemoteCredentialsDialog(remoteName, remoteUrl) 3176 dlg = GitRemoteCredentialsDialog(remoteName, remoteUrl)
3182 if dlg.exec() == QDialog.DialogCode.Accepted: 3177 if dlg.exec() == QDialog.DialogCode.Accepted:
3183 name, url = dlg.getData() 3178 name, url = dlg.getData()
3184 if url != remoteUrl: 3179 if url != remoteUrl:
3264 3259
3265 @param projectDir name of the project directory (string) 3260 @param projectDir name of the project directory (string)
3266 @param commits list of commits to start the search from 3261 @param commits list of commits to start the search from
3267 (list of strings) 3262 (list of strings)
3268 """ 3263 """
3264 from .GitDescribeDialog import GitDescribeDialog
3265
3269 if self.describeDialog is None: 3266 if self.describeDialog is None:
3270 from .GitDescribeDialog import GitDescribeDialog
3271
3272 self.describeDialog = GitDescribeDialog(self) 3267 self.describeDialog = GitDescribeDialog(self)
3273 self.describeDialog.show() 3268 self.describeDialog.show()
3274 self.describeDialog.raise_() 3269 self.describeDialog.raise_()
3275 self.describeDialog.start(projectDir, commits) 3270 self.describeDialog.start(projectDir, commits)
3276 3271
3285 3280
3286 @param projectDir name of the project directory (string) 3281 @param projectDir name of the project directory (string)
3287 @param commits list of commits to be applied (list of strings) 3282 @param commits list of commits to be applied (list of strings)
3288 @return flag indicating that the project should be reread (boolean) 3283 @return flag indicating that the project should be reread (boolean)
3289 """ 3284 """
3285 from .GitCherryPickDialog import GitCherryPickDialog
3286
3290 # find the root of the repo 3287 # find the root of the repo
3291 repodir = projectDir 3288 repodir = projectDir
3292 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3289 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3293 repodir = os.path.dirname(repodir) 3290 repodir = os.path.dirname(repodir)
3294 if os.path.splitdrive(repodir)[1] == os.sep: 3291 if os.path.splitdrive(repodir)[1] == os.sep:
3295 return False 3292 return False
3296 3293
3297 res = False 3294 res = False
3298
3299 from .GitCherryPickDialog import GitCherryPickDialog
3300 3295
3301 dlg = GitCherryPickDialog(commits) 3296 dlg = GitCherryPickDialog(commits)
3302 if dlg.exec() == QDialog.DialogCode.Accepted: 3297 if dlg.exec() == QDialog.DialogCode.Accepted:
3303 commits, cherrypickInfo, signoff, nocommit = dlg.getData() 3298 commits, cherrypickInfo, signoff, nocommit = dlg.getData()
3304 3299
3332 repodir = projectDir 3327 repodir = projectDir
3333 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3328 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3334 repodir = os.path.dirname(repodir) 3329 repodir = os.path.dirname(repodir)
3335 if os.path.splitdrive(repodir)[1] == os.sep: 3330 if os.path.splitdrive(repodir)[1] == os.sep:
3336 return False 3331 return False
3337
3338 import sys
3339 3332
3340 editor = sys.argv[0].replace(".py", "_editor.py") 3333 editor = sys.argv[0].replace(".py", "_editor.py")
3341 env = {"GIT_EDITOR": "{0} {1}".format(Globals.getPythonExecutable(), editor)} 3334 env = {"GIT_EDITOR": "{0} {1}".format(Globals.getPythonExecutable(), editor)}
3342 3335
3343 args = self.initCommand("cherry-pick") 3336 args = self.initCommand("cherry-pick")
3450 3443
3451 @param projectDir name of the project directory (string) 3444 @param projectDir name of the project directory (string)
3452 @return flag indicating, that the save contained an add 3445 @return flag indicating, that the save contained an add
3453 or delete (boolean) 3446 or delete (boolean)
3454 """ 3447 """
3448 from .GitStashDataDialog import GitStashDataDialog
3449
3455 # find the root of the repo 3450 # find the root of the repo
3456 repodir = projectDir 3451 repodir = projectDir
3457 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3452 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3458 repodir = os.path.dirname(repodir) 3453 repodir = os.path.dirname(repodir)
3459 if os.path.splitdrive(repodir)[1] == os.sep: 3454 if os.path.splitdrive(repodir)[1] == os.sep:
3460 return False 3455 return False
3461 3456
3462 res = False 3457 res = False
3463 from .GitStashDataDialog import GitStashDataDialog
3464
3465 dlg = GitStashDataDialog() 3458 dlg = GitStashDataDialog()
3466 if dlg.exec() == QDialog.DialogCode.Accepted: 3459 if dlg.exec() == QDialog.DialogCode.Accepted:
3467 message, keepIndex, untracked = dlg.getData() 3460 message, keepIndex, untracked = dlg.getData()
3468 args = self.initCommand("stash") 3461 args = self.initCommand("stash")
3469 args.append("save") 3462 args.append("save")
3488 """ 3481 """
3489 Public method used to browse the stashed changes. 3482 Public method used to browse the stashed changes.
3490 3483
3491 @param projectDir name of the project directory (string) 3484 @param projectDir name of the project directory (string)
3492 """ 3485 """
3486 from .GitStashBrowserDialog import GitStashBrowserDialog
3487
3493 if self.stashBrowser is None: 3488 if self.stashBrowser is None:
3494 from .GitStashBrowserDialog import GitStashBrowserDialog
3495
3496 self.stashBrowser = GitStashBrowserDialog(self) 3489 self.stashBrowser = GitStashBrowserDialog(self)
3497 self.stashBrowser.show() 3490 self.stashBrowser.show()
3498 self.stashBrowser.raise_() 3491 self.stashBrowser.raise_()
3499 self.stashBrowser.start(projectDir) 3492 self.stashBrowser.start(projectDir)
3500 3493
3503 Public method to show the contents of a stash. 3496 Public method to show the contents of a stash.
3504 3497
3505 @param projectDir name of the project directory (string) 3498 @param projectDir name of the project directory (string)
3506 @param stashName name of a stash (string) 3499 @param stashName name of a stash (string)
3507 """ 3500 """
3501 from .GitDiffDialog import GitDiffDialog
3502
3508 # find the root of the repo 3503 # find the root of the repo
3509 repodir = projectDir 3504 repodir = projectDir
3510 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3505 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3511 repodir = os.path.dirname(repodir) 3506 repodir = os.path.dirname(repodir)
3512 if os.path.splitdrive(repodir)[1] == os.sep: 3507 if os.path.splitdrive(repodir)[1] == os.sep:
3524 ) 3519 )
3525 if not ok: 3520 if not ok:
3526 return 3521 return
3527 3522
3528 if self.diff is None: 3523 if self.diff is None:
3529 from .GitDiffDialog import GitDiffDialog
3530
3531 self.diff = GitDiffDialog(self) 3524 self.diff = GitDiffDialog(self)
3532 self.diff.show() 3525 self.diff.show()
3533 self.diff.raise_() 3526 self.diff.raise_()
3534 self.diff.start(repodir, diffMode="stash", stashName=stashName) 3527 self.diff.start(repodir, diffMode="stash", stashName=stashName)
3535 3528
3768 3761
3769 def gitEditUserConfig(self): 3762 def gitEditUserConfig(self):
3770 """ 3763 """
3771 Public method used to edit the user configuration file. 3764 Public method used to edit the user configuration file.
3772 """ 3765 """
3766 from .GitUserConfigDataDialog import GitUserConfigDataDialog
3773 from .GitUtilities import getConfigPath 3767 from .GitUtilities import getConfigPath
3774 3768
3775 cfgFile = getConfigPath() 3769 cfgFile = getConfigPath()
3776 if not os.path.exists(cfgFile): 3770 if not os.path.exists(cfgFile):
3777 from .GitUserConfigDataDialog import GitUserConfigDataDialog
3778
3779 dlg = GitUserConfigDataDialog() 3771 dlg = GitUserConfigDataDialog()
3780 if dlg.exec() == QDialog.DialogCode.Accepted: 3772 if dlg.exec() == QDialog.DialogCode.Accepted:
3781 firstName, lastName, email = dlg.getData() 3773 firstName, lastName, email = dlg.getData()
3782 else: 3774 else:
3783 firstName, lastName, email = ("Firstname", "Lastname", "email_address") 3775 firstName, lastName, email = ("Firstname", "Lastname", "email_address")
3982 """ 3974 """
3983 Public method to show some statistics of the local repository. 3975 Public method to show some statistics of the local repository.
3984 3976
3985 @param projectDir name of the project directory (string) 3977 @param projectDir name of the project directory (string)
3986 """ 3978 """
3979 from .GitArchiveDataDialog import GitArchiveDataDialog
3980
3987 # find the root of the repo 3981 # find the root of the repo
3988 repodir = projectDir 3982 repodir = projectDir
3989 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 3983 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3990 repodir = os.path.dirname(repodir) 3984 repodir = os.path.dirname(repodir)
3991 if os.path.splitdrive(repodir)[1] == os.sep: 3985 if os.path.splitdrive(repodir)[1] == os.sep:
3992 return 3986 return
3993
3994 from .GitArchiveDataDialog import GitArchiveDataDialog
3995 3987
3996 dlg = GitArchiveDataDialog( 3988 dlg = GitArchiveDataDialog(
3997 self.gitGetTagsList(repodir), 3989 self.gitGetTagsList(repodir),
3998 self.gitGetBranchesList(repodir, withMaster=True), 3990 self.gitGetBranchesList(repodir, withMaster=True),
3999 self.gitGetArchiveFormats(repodir), 3991 self.gitGetArchiveFormats(repodir),
4024 Public method to add a submodule to the project. 4016 Public method to add a submodule to the project.
4025 4017
4026 @param projectDir name of the project directory 4018 @param projectDir name of the project directory
4027 @type str 4019 @type str
4028 """ 4020 """
4021 from .GitSubmoduleAddDialog import GitSubmoduleAddDialog
4022
4029 # find the root of the repo 4023 # find the root of the repo
4030 repodir = projectDir 4024 repodir = projectDir
4031 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 4025 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
4032 repodir = os.path.dirname(repodir) 4026 repodir = os.path.dirname(repodir)
4033 if os.path.splitdrive(repodir)[1] == os.sep: 4027 if os.path.splitdrive(repodir)[1] == os.sep:
4034 return 4028 return
4035
4036 from .GitSubmoduleAddDialog import GitSubmoduleAddDialog
4037 4029
4038 dlg = GitSubmoduleAddDialog(self, repodir) 4030 dlg = GitSubmoduleAddDialog(self, repodir)
4039 if dlg.exec() == QDialog.DialogCode.Accepted: 4031 if dlg.exec() == QDialog.DialogCode.Accepted:
4040 repo, branch, name, path, force = dlg.getData() 4032 repo, branch, name, path, force = dlg.getData()
4041 args = self.initCommand("submodule") 4033 args = self.initCommand("submodule")
4102 Public method to show a list of all submodules of the project. 4094 Public method to show a list of all submodules of the project.
4103 4095
4104 @param projectDir name of the project directory 4096 @param projectDir name of the project directory
4105 @type str 4097 @type str
4106 """ 4098 """
4099 from .GitSubmodulesListDialog import GitSubmodulesListDialog
4100
4107 # find the root of the repo 4101 # find the root of the repo
4108 repodir = projectDir 4102 repodir = projectDir
4109 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 4103 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
4110 repodir = os.path.dirname(repodir) 4104 repodir = os.path.dirname(repodir)
4111 if os.path.splitdrive(repodir)[1] == os.sep: 4105 if os.path.splitdrive(repodir)[1] == os.sep:
4112 return 4106 return
4113 4107
4114 submodulesList = self.__gitSubmodulesList(repodir) 4108 submodulesList = self.__gitSubmodulesList(repodir)
4115 if submodulesList: 4109 if submodulesList:
4116 from .GitSubmodulesListDialog import GitSubmodulesListDialog
4117
4118 dlg = GitSubmodulesListDialog(submodulesList) 4110 dlg = GitSubmodulesListDialog(submodulesList)
4119 dlg.exec() 4111 dlg.exec()
4120 else: 4112 else:
4121 EricMessageBox.information( 4113 EricMessageBox.information(
4122 None, 4114 None,
4157 @type str 4149 @type str
4158 @return tuple of selected submodule paths and flag indicating 4150 @return tuple of selected submodule paths and flag indicating
4159 a cancellation 4151 a cancellation
4160 @rtype tuple of (list of str, bool) 4152 @rtype tuple of (list of str, bool)
4161 """ 4153 """
4154 from .GitListDialog import GitListDialog
4155
4162 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)] 4156 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)]
4163
4164 from .GitListDialog import GitListDialog
4165 4157
4166 dlg = GitListDialog(sorted(paths)) 4158 dlg = GitListDialog(sorted(paths))
4167 if dlg.exec() == QDialog.DialogCode.Accepted: 4159 if dlg.exec() == QDialog.DialogCode.Accepted:
4168 selectedPaths = dlg.getSelection() 4160 selectedPaths = dlg.getSelection()
4169 return selectedPaths, True 4161 return selectedPaths, True
4200 Public method to unregister submodules. 4192 Public method to unregister submodules.
4201 4193
4202 @param projectDir name of the project directory 4194 @param projectDir name of the project directory
4203 @type str 4195 @type str
4204 """ 4196 """
4197 from .GitSubmodulesDeinitDialog import GitSubmodulesDeinitDialog
4198
4205 # find the root of the repo 4199 # find the root of the repo
4206 repodir = projectDir 4200 repodir = projectDir
4207 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 4201 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
4208 repodir = os.path.dirname(repodir) 4202 repodir = os.path.dirname(repodir)
4209 if os.path.splitdrive(repodir)[1] == os.sep: 4203 if os.path.splitdrive(repodir)[1] == os.sep:
4210 return 4204 return
4211 4205
4212 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)] 4206 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)]
4213
4214 from .GitSubmodulesDeinitDialog import GitSubmodulesDeinitDialog
4215 4207
4216 dlg = GitSubmodulesDeinitDialog(paths) 4208 dlg = GitSubmodulesDeinitDialog(paths)
4217 if dlg.exec() == QDialog.DialogCode.Accepted: 4209 if dlg.exec() == QDialog.DialogCode.Accepted:
4218 deinitAll, submodulePaths, force = dlg.getData() 4210 deinitAll, submodulePaths, force = dlg.getData()
4219 args = self.initCommand("submodule") 4211 args = self.initCommand("submodule")
4269 update options. 4261 update options.
4270 4262
4271 @param projectDir name of the project directory 4263 @param projectDir name of the project directory
4272 @type str 4264 @type str
4273 """ 4265 """
4266 from .GitSubmodulesUpdateOptionsDialog import GitSubmodulesUpdateOptionsDialog
4267
4274 # find the root of the repo 4268 # find the root of the repo
4275 repodir = projectDir 4269 repodir = projectDir
4276 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 4270 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
4277 repodir = os.path.dirname(repodir) 4271 repodir = os.path.dirname(repodir)
4278 if os.path.splitdrive(repodir)[1] == os.sep: 4272 if os.path.splitdrive(repodir)[1] == os.sep:
4279 return 4273 return
4280 4274
4281 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)] 4275 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)]
4282
4283 from .GitSubmodulesUpdateOptionsDialog import GitSubmodulesUpdateOptionsDialog
4284 4276
4285 dlg = GitSubmodulesUpdateOptionsDialog(paths) 4277 dlg = GitSubmodulesUpdateOptionsDialog(paths)
4286 if dlg.exec() == QDialog.DialogCode.Accepted: 4278 if dlg.exec() == QDialog.DialogCode.Accepted:
4287 procedure, init, remote, noFetch, force, submodulePaths = dlg.getData() 4279 procedure, init, remote, noFetch, force, submodulePaths = dlg.getData()
4288 4280
4309 Public method to synchronize submodules. 4301 Public method to synchronize submodules.
4310 4302
4311 @param projectDir name of the project directory 4303 @param projectDir name of the project directory
4312 @type str 4304 @type str
4313 """ 4305 """
4306 from .GitSubmodulesSyncDialog import GitSubmodulesSyncDialog
4307
4314 # find the root of the repo 4308 # find the root of the repo
4315 repodir = projectDir 4309 repodir = projectDir
4316 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 4310 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
4317 repodir = os.path.dirname(repodir) 4311 repodir = os.path.dirname(repodir)
4318 if os.path.splitdrive(repodir)[1] == os.sep: 4312 if os.path.splitdrive(repodir)[1] == os.sep:
4319 return 4313 return
4320 4314
4321 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)] 4315 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)]
4322
4323 from .GitSubmodulesSyncDialog import GitSubmodulesSyncDialog
4324 4316
4325 dlg = GitSubmodulesSyncDialog(paths) 4317 dlg = GitSubmodulesSyncDialog(paths)
4326 if dlg.exec() == QDialog.DialogCode.Accepted: 4318 if dlg.exec() == QDialog.DialogCode.Accepted:
4327 submodulePaths, recursive = dlg.getData() 4319 submodulePaths, recursive = dlg.getData()
4328 args = self.initCommand("submodule") 4320 args = self.initCommand("submodule")
4341 Public method to show the status of the submodules. 4333 Public method to show the status of the submodules.
4342 4334
4343 @param projectDir name of the project directory 4335 @param projectDir name of the project directory
4344 @type str 4336 @type str
4345 """ 4337 """
4338 from .GitSubmodulesStatusDialog import GitSubmodulesStatusDialog
4339
4346 if self.submoduleStatusDialog is None: 4340 if self.submoduleStatusDialog is None:
4347 from .GitSubmodulesStatusDialog import GitSubmodulesStatusDialog
4348
4349 self.submoduleStatusDialog = GitSubmodulesStatusDialog(self) 4341 self.submoduleStatusDialog = GitSubmodulesStatusDialog(self)
4350 self.submoduleStatusDialog.show() 4342 self.submoduleStatusDialog.show()
4351 self.submoduleStatusDialog.raise_() 4343 self.submoduleStatusDialog.raise_()
4352 self.submoduleStatusDialog.start(projectDir) 4344 self.submoduleStatusDialog.start(projectDir)
4353 4345
4356 Public method to show the status of the submodules. 4348 Public method to show the status of the submodules.
4357 4349
4358 @param projectDir name of the project directory 4350 @param projectDir name of the project directory
4359 @type str 4351 @type str
4360 """ 4352 """
4353 from .GitSubmodulesSummaryOptionsDialog import GitSubmodulesSummaryOptionsDialog
4354
4361 # find the root of the repo 4355 # find the root of the repo
4362 repodir = projectDir 4356 repodir = projectDir
4363 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 4357 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
4364 repodir = os.path.dirname(repodir) 4358 repodir = os.path.dirname(repodir)
4365 if os.path.splitdrive(repodir)[1] == os.sep: 4359 if os.path.splitdrive(repodir)[1] == os.sep:
4366 return 4360 return
4367 4361
4368 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)] 4362 paths = [submodule["path"] for submodule in self.__gitSubmodulesList(repodir)]
4369
4370 from .GitSubmodulesSummaryOptionsDialog import GitSubmodulesSummaryOptionsDialog
4371 4363
4372 dlg = GitSubmodulesSummaryOptionsDialog(paths) 4364 dlg = GitSubmodulesSummaryOptionsDialog(paths)
4373 if dlg.exec() == QDialog.DialogCode.Accepted: 4365 if dlg.exec() == QDialog.DialogCode.Accepted:
4374 submodulePaths, superProject, index, commit, limit = dlg.getData() 4366 submodulePaths, superProject, index, commit, limit = dlg.getData()
4375 args = self.initCommand("submodule") 4367 args = self.initCommand("submodule")

eric ide

mercurial