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

branch
eric7
changeset 10438
4cd7e5a8b3cf
parent 10069
435cc5875135
child 10439
21c28b0f9e41
equal deleted inserted replaced
10437:2f70ca07f0af 10438:4cd7e5a8b3cf
26 def __init__(self, vcs, parent=None): 26 def __init__(self, vcs, parent=None):
27 """ 27 """
28 Constructor 28 Constructor
29 29
30 @param vcs reference to the vcs object 30 @param vcs reference to the vcs object
31 @param parent parent widget (QWidget) 31 @type Git
32 @param parent parent widget
33 @type QWidget
32 """ 34 """
33 super().__init__(parent) 35 super().__init__(parent)
34 36
35 self.vcs = vcs 37 self.vcs = vcs
36 38
67 69
68 def start(self, fn, versions=None, diffMode="work2repo", stashName=""): 70 def start(self, fn, versions=None, diffMode="work2repo", stashName=""):
69 """ 71 """
70 Public slot to start the git diff command. 72 Public slot to start the git diff command.
71 73
72 @param fn filename to be diffed (string) 74 @param fn filename to be diffed
73 @param versions list of versions to be diffed (list of up to 2 strings 75 @type str
74 or None) 76 @param versions list of versions to be diffed
77 @type list of up to 2 str or None
75 @param diffMode indication for the type of diff to be performed ( 78 @param diffMode indication for the type of diff to be performed (
76 'work2repo' compares the working tree with the HEAD commit, 79 'work2repo' compares the working tree with the HEAD commit,
77 'work2stage' compares the working tree with the staging area, 80 'work2stage' compares the working tree with the staging area,
78 'stage2repo' compares the staging area with the HEAD commit, 81 'stage2repo' compares the staging area with the HEAD commit,
79 'work2stage2repo' compares the working tree with the staging area 82 'work2stage2repo' compares the working tree with the staging area
80 and the staging area with the HEAD commit, 83 and the staging area with the HEAD commit,
81 'stash' shows the diff for a stash) 84 'stash' shows the diff for a stash)
82 @param stashName name of the stash to show a diff for (string) 85 @type str
83 @return flag indicating the start status (boolean) 86 @param stashName name of the stash to show a diff for
87 @type str
88 @return flag indicating the start status
89 @rtype bool
84 @exception ValueError raised to indicate a bad value for the 'diffMode' 90 @exception ValueError raised to indicate a bad value for the 'diffMode'
85 parameter. 91 parameter.
86 """ 92 """
87 if diffMode not in [ 93 if diffMode not in [
88 "work2repo", 94 "work2repo",
164 @pyqtSlot(int, QProcess.ExitStatus) 170 @pyqtSlot(int, QProcess.ExitStatus)
165 def __procFinished(self, exitCode, exitStatus): 171 def __procFinished(self, exitCode, exitStatus):
166 """ 172 """
167 Private slot connected to the finished signal. 173 Private slot connected to the finished signal.
168 174
169 @param exitCode exit code of the process (integer) 175 @param exitCode exit code of the process
170 @param exitStatus exit status of the process (QProcess.ExitStatus) 176 @type int
177 @param exitStatus exit status of the process
178 @type QProcess.ExitStatus
171 """ 179 """
172 if ( 180 if (
173 self.__process.state() == QProcess.ProcessState.NotRunning 181 self.__process.state() == QProcess.ProcessState.NotRunning
174 and self.__process2.state() == QProcess.ProcessState.NotRunning 182 and self.__process2.state() == QProcess.ProcessState.NotRunning
175 ): 183 ):
181 189
182 @return tuple of lists of string containing lines of the diff, the diff 190 @return tuple of lists of string containing lines of the diff, the diff
183 between stage and repo for 'work2stage2repo' mode (empty 191 between stage and repo for 'work2stage2repo' mode (empty
184 otherwise), the list of errors and a list of tuples of filenames 192 otherwise), the list of errors and a list of tuples of filenames
185 and the line into the diff output. 193 and the line into the diff output.
194 @rtype tuple of (list of str, list of str, list of str, list of (str, int))
186 """ 195 """
187 return (self.__output1, self.__output2, self.__errors, self.__fileSeparators) 196 return (self.__output1, self.__output2, self.__errors, self.__fileSeparators)
188 197
189 def __processFileLine(self, line, isTopDiff): 198 def __processFileLine(self, line, isTopDiff):
190 """ 199 """
191 Private slot to process a line giving the old/new file. 200 Private slot to process a line giving the old/new file.
192 201
193 @param line line to be processed (string) 202 @param line line to be processed
203 @type str
194 @param isTopDiff flag indicating to show the output in the top 204 @param isTopDiff flag indicating to show the output in the top
195 output widget (boolean) 205 output widget
206 @type bool
196 """ 207 """
197 prefix, filenames = line.split(" a/", 1) 208 prefix, filenames = line.split(" a/", 1)
198 oldFile, newFile = filenames.split(" b/", 1) 209 oldFile, newFile = filenames.split(" b/", 1)
199 if isTopDiff: 210 if isTopDiff:
200 self.__fileSeparators.append( 211 self.__fileSeparators.append(
207 218
208 def __processLine(self, line, isTopDiff): 219 def __processLine(self, line, isTopDiff):
209 """ 220 """
210 Private method to process one line of output. 221 Private method to process one line of output.
211 222
212 @param line output line to process (string) 223 @param line output line to process
224 @type str
213 @param isTopDiff flag indicating to show the output in the top 225 @param isTopDiff flag indicating to show the output in the top
214 output widget (boolean) 226 output widget
227 @type bool
215 """ 228 """
216 if line.startswith("diff --git"): 229 if line.startswith("diff --git"):
217 self.__processFileLine(line, isTopDiff) 230 self.__processFileLine(line, isTopDiff)
218 231
219 if isTopDiff: 232 if isTopDiff:

eric ide

mercurial