7 Module implementing the VCS status monitor thread class for Mercurial. |
7 Module implementing the VCS status monitor thread class for Mercurial. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 try: |
11 try: |
12 str = unicode # __IGNORE_WARNING__ |
12 str = unicode |
13 except (NameError): |
13 except NameError: |
14 pass |
14 pass |
15 |
15 |
16 from PyQt4.QtCore import QProcess |
16 from PyQt4.QtCore import QProcess |
17 |
17 |
18 from VCS.StatusMonitorThread import VcsStatusMonitorThread |
18 from VCS.StatusMonitorThread import VcsStatusMonitorThread |
19 |
|
20 import Preferences |
|
21 |
19 |
22 |
20 |
23 class HgStatusMonitorThread(VcsStatusMonitorThread): |
21 class HgStatusMonitorThread(VcsStatusMonitorThread): |
24 """ |
22 """ |
25 Class implementing the VCS status monitor thread class for Mercurial. |
23 Class implementing the VCS status monitor thread class for Mercurial. |
32 @param project reference to the project object (Project) |
30 @param project reference to the project object (Project) |
33 @param vcs reference to the version control object |
31 @param vcs reference to the version control object |
34 @param parent reference to the parent object (QObject) |
32 @param parent reference to the parent object (QObject) |
35 """ |
33 """ |
36 VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent) |
34 VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent) |
37 |
|
38 self.__ioEncoding = Preferences.getSystem("IOEncoding") |
|
39 |
35 |
40 self.__client = None |
36 self.__client = None |
41 self.__useCommandLine = False |
37 self.__useCommandLine = False |
42 |
38 |
43 def _performMonitor(self): |
39 def _performMonitor(self): |
94 procStarted = process.waitForStarted(5000) |
89 procStarted = process.waitForStarted(5000) |
95 if procStarted: |
90 if procStarted: |
96 finished = process.waitForFinished(300000) |
91 finished = process.waitForFinished(300000) |
97 if finished and process.exitCode() == 0: |
92 if finished and process.exitCode() == 0: |
98 output = str(process.readAllStandardOutput(), |
93 output = str(process.readAllStandardOutput(), |
99 self.__ioEncoding, 'replace') |
94 self.vcs.getEncoding(), 'replace') |
100 else: |
95 else: |
101 process.kill() |
96 process.kill() |
102 process.waitForFinished() |
97 process.waitForFinished() |
103 error = str(process.readAllStandardError(), |
98 error = str(process.readAllStandardError(), |
104 self.__ioEncoding, 'replace') |
99 self.vcs.getEncoding(), 'replace') |
105 else: |
100 else: |
106 process.kill() |
101 process.kill() |
107 process.waitForFinished() |
102 process.waitForFinished() |
108 error = self.trUtf8("Could not start the Mercurial process.") |
103 error = self.tr("Could not start the Mercurial process.") |
109 |
104 |
110 if error: |
105 if error: |
111 return False, error |
106 return False, error |
112 |
107 |
113 states = {} |
108 states = {} |
135 process.start('hg', args) |
129 process.start('hg', args) |
136 procStarted = process.waitForStarted(5000) |
130 procStarted = process.waitForStarted(5000) |
137 if procStarted: |
131 if procStarted: |
138 finished = process.waitForFinished(300000) |
132 finished = process.waitForFinished(300000) |
139 if finished and process.exitCode() == 0: |
133 if finished and process.exitCode() == 0: |
140 output = str( |
134 output = str(process.readAllStandardOutput(), |
141 process.readAllStandardOutput(), |
135 self.vcs.getEncoding(), 'replace') |
142 self.__ioEncoding, 'replace') |
|
143 |
136 |
144 for line in output.splitlines(): |
137 for line in output.splitlines(): |
145 flag, name = line.split(" ", 1) |
138 flag, name = line.split(" ", 1) |
146 if flag == "U": |
139 if flag == "U": |
147 states[name] = "Z" # conflict |
140 states[name] = "Z" # conflict |
158 if name not in states: |
151 if name not in states: |
159 self.statusList.append(" {0}".format(name)) |
152 self.statusList.append(" {0}".format(name)) |
160 self.reportedStates = states |
153 self.reportedStates = states |
161 |
154 |
162 return True, \ |
155 return True, \ |
163 self.trUtf8("Mercurial status checked successfully") |
156 self.tr("Mercurial status checked successfully") |
164 |
157 |
165 def _shutdown(self): |
158 def _shutdown(self): |
166 """ |
159 """ |
167 Protected method performing shutdown actions. |
160 Protected method performing shutdown actions. |
168 """ |
161 """ |