13 except NameError: |
13 except NameError: |
14 pass |
14 pass |
15 |
15 |
16 import os |
16 import os |
17 import shutil |
17 import shutil |
18 import re |
|
19 |
18 |
20 from PyQt5.QtCore import QProcess, pyqtSignal, QFileInfo, QFileSystemWatcher, \ |
19 from PyQt5.QtCore import QProcess, pyqtSignal, QFileInfo, QFileSystemWatcher, \ |
21 QCoreApplication |
20 QCoreApplication |
22 from PyQt5.QtWidgets import QApplication, QDialog, QInputDialog |
21 from PyQt5.QtWidgets import QApplication, QDialog, QInputDialog |
23 |
22 |
246 |
245 |
247 def vcsExists(self): |
246 def vcsExists(self): |
248 """ |
247 """ |
249 Public method used to test for the presence of the hg executable. |
248 Public method used to test for the presence of the hg executable. |
250 |
249 |
251 @return flag indicating the existance (boolean) and an error message |
250 @return flag indicating the existence (boolean) and an error message |
252 (string) |
251 (string) |
253 """ |
252 """ |
254 self.versionStr = '' |
253 from .HgUtilities import hgVersion |
255 errMsg = "" |
254 |
256 |
255 self.versionStr, self.version, errMsg = hgVersion(self.__plugin) |
257 args = self.initCommand("version") |
256 hgExists = errMsg == "" |
258 process = QProcess() |
257 if hgExists: |
259 process.start('hg', args) |
258 self.__getExtensionsInfo() |
260 procStarted = process.waitForStarted(5000) |
259 return hgExists, errMsg |
261 if procStarted: |
|
262 finished = process.waitForFinished(30000) |
|
263 if finished and process.exitCode() == 0: |
|
264 output = str(process.readAllStandardOutput(), |
|
265 self.getEncoding(), 'replace') |
|
266 self.versionStr = output.splitlines()[0].split()[-1][0:-1] |
|
267 v = list(re.match(r'.*?(\d+)\.(\d+)\.?(\d+)?(\+[0-9a-f-]+)?', |
|
268 self.versionStr).groups()) |
|
269 for i in range(3): |
|
270 try: |
|
271 v[i] = int(v[i]) |
|
272 except TypeError: |
|
273 v[i] = 0 |
|
274 except IndexError: |
|
275 v.append(0) |
|
276 self.version = tuple(v) |
|
277 self.__getExtensionsInfo() |
|
278 return True, errMsg |
|
279 else: |
|
280 if finished: |
|
281 errMsg = self.tr( |
|
282 "The hg process finished with the exit code {0}")\ |
|
283 .format(process.exitCode()) |
|
284 else: |
|
285 errMsg = self.tr( |
|
286 "The hg process did not finish within 30s.") |
|
287 else: |
|
288 errMsg = self.tr("Could not start the hg executable.") |
|
289 |
|
290 return False, errMsg |
|
291 |
260 |
292 def vcsInit(self, vcsDir, noDialog=False): |
261 def vcsInit(self, vcsDir, noDialog=False): |
293 """ |
262 """ |
294 Public method used to initialize the mercurial repository. |
263 Public method used to initialize the mercurial repository. |
295 |
264 |