57 @return tuple of flag indicating successful operation (boolean) and |
57 @return tuple of flag indicating successful operation (boolean) and |
58 a status message in case of non successful operation (string) |
58 a status message in case of non successful operation (string) |
59 """ |
59 """ |
60 self.shouldUpdate = False |
60 self.shouldUpdate = False |
61 |
61 |
62 if self.__client is None and not self.__useCommandLine: |
62 self.__initClient() |
63 from .HgClient import HgClient |
|
64 client = HgClient(self.projectDir, "utf-8", self.vcs) |
|
65 ok, err = client.startServer() |
|
66 if ok: |
|
67 self.__client = client |
|
68 else: |
|
69 self.__useCommandLine = True |
|
70 |
63 |
71 # step 1: get overall status |
64 # step 1: get overall status |
72 args = self.vcs.initCommand("status") |
65 args = self.vcs.initCommand("status") |
73 args.append('--noninteractive') |
66 args.append('--noninteractive') |
74 args.append('--all') |
67 args.append('--all') |
148 self.reportedStates = states |
141 self.reportedStates = states |
149 |
142 |
150 return True, \ |
143 return True, \ |
151 self.tr("Mercurial status checked successfully") |
144 self.tr("Mercurial status checked successfully") |
152 |
145 |
|
146 def _getInfo(self): |
|
147 """ |
|
148 Protected method implementing the real info action. |
|
149 |
|
150 This method should be overridden and create a short info message to be |
|
151 shown in the main window status bar right next to the status indicator. |
|
152 |
|
153 @return short info message |
|
154 @rtype str |
|
155 """ |
|
156 self.__initClient() |
|
157 |
|
158 args = self.vcs.initCommand("identify") |
|
159 args.append('--num') |
|
160 args.append('--id') |
|
161 args.append('--branch') |
|
162 |
|
163 output = "" |
|
164 error = "" |
|
165 if self.__client: |
|
166 output, error = self.__client.runcommand(args) |
|
167 else: |
|
168 process = QProcess() |
|
169 process.setWorkingDirectory(self.projectDir) |
|
170 process.start('hg', args) |
|
171 procStarted = process.waitForStarted(5000) |
|
172 if procStarted: |
|
173 finished = process.waitForFinished(300000) |
|
174 if finished and process.exitCode() == 0: |
|
175 output = str(process.readAllStandardOutput(), |
|
176 self.vcs.getEncoding(), 'replace') |
|
177 else: |
|
178 process.kill() |
|
179 process.waitForFinished() |
|
180 error = str(process.readAllStandardError(), |
|
181 self.vcs.getEncoding(), 'replace') |
|
182 else: |
|
183 process.kill() |
|
184 process.waitForFinished() |
|
185 error = self.tr("Could not start the Mercurial process.") |
|
186 |
|
187 if error: |
|
188 # ignore errors |
|
189 return "" |
|
190 |
|
191 globalRev, localRev, branch = output.splitlines()[0].split() |
|
192 if globalRev.endswith("+"): |
|
193 globalRev = globalRev[:-1] |
|
194 if localRev.endswith("+"): |
|
195 localRev = localRev[:-1] |
|
196 |
|
197 return self.tr("{0} / {1}:{2}", "branch, local id, global id").format( |
|
198 branch, localRev, globalRev) |
|
199 |
153 def _shutdown(self): |
200 def _shutdown(self): |
154 """ |
201 """ |
155 Protected method performing shutdown actions. |
202 Protected method performing shutdown actions. |
156 """ |
203 """ |
157 if self.__client: |
204 if self.__client: |
158 self.__client.stopServer() |
205 self.__client.stopServer() |
|
206 |
|
207 def __initClient(self): |
|
208 """ |
|
209 Private method to initialize the Mercurial client. |
|
210 """ |
|
211 if self.__client is None and not self.__useCommandLine: |
|
212 from .HgClient import HgClient |
|
213 client = HgClient(self.projectDir, "utf-8", self.vcs) |
|
214 ok, err = client.startServer() |
|
215 if ok: |
|
216 self.__client = client |
|
217 else: |
|
218 self.__useCommandLine = True |