src/eric7/Plugins/VcsPlugins/vcsMercurial/HgUtilities.py

Sun, 18 Dec 2022 19:33:46 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 18 Dec 2022 19:33:46 +0100
branch
eric7
changeset 9624
b47dfa7a137d
parent 9473
3f23dbf37dbe
child 9653
e67609152c5e
permissions
-rw-r--r--

Refactored the Utilities and Globals modules in order to enhance the maintainability.

178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
3 # Copyright (c) 2010 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing some common utility functions for the Mercurial package.
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
11 import re
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9420
diff changeset
13 from PyQt6.QtCore import QCoreApplication, QProcess, QProcessEnvironment
2816
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
14
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
15 from eric7.SystemUtilities import OSUtilities, PythonUtilities
8288
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
16
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
17
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
18 def getHgExecutable():
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
19 """
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
20 Function to get the full path of the Mercurial executable.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
21
8288
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
22 @return path of the Mercurial executable
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
23 @rtype str
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
24 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9288
diff changeset
25 from eric7.Plugins.PluginVcsMercurial import VcsMercurialPlugin
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
26
9054
adae534abaf0 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
27 exe = VcsMercurialPlugin.getPreferences("MercurialExecutablePath")
adae534abaf0 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
28 if not exe:
adae534abaf0 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
29 program = "hg"
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
30 if OSUtilities.isWindowsPlatform():
9054
adae534abaf0 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
31 program += ".exe"
9420
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
32
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
33 progPath = os.path.join(PythonUtilities.getPythonScriptsDirectory(), program)
9420
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
34 if os.path.exists(progPath):
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
35 exe = progPath
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
36
9288
ce20d7c936b1 Little fix in HgUtilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
37 if not exe:
ce20d7c936b1 Little fix in HgUtilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
38 exe = program
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
39
8288
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
40 return exe
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
42
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 def getConfigPath():
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
8288
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
45 Function to get the filename of the config file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
46
8288
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
47 @return filename of the config file
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
48 @rtype str
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
50 if OSUtilities.isWindowsPlatform():
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 userprofile = os.environ["USERPROFILE"]
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 return os.path.join(userprofile, "Mercurial.ini")
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 else:
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
54 homedir = OSUtilities.getHomeDir()
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 return os.path.join(homedir, ".hgrc")
2816
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
56
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
57
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
58 def prepareProcess(proc, encoding="", language=""):
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
59 """
8288
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
60 Function to prepare the given process.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
61
8288
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
62 @param proc reference to the process to be prepared
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
63 @type QProcess
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
64 @param encoding encoding to be used by the process
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
65 @type str
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
66 @param language language to be set
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
67 @type str
2816
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
68 """
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
69 env = QProcessEnvironment.systemEnvironment()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
70 env.insert("HGPLAIN", "1")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71
2816
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
72 # set the encoding for the process
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
73 if encoding:
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
74 env.insert("HGENCODING", encoding)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
75
2816
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
76 # set the language for the process
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
77 if language:
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
78 env.insert("LANGUAGE", language)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
79
2816
05aab5164d64 A little optimization for the Mercurial interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
80 proc.setProcessEnvironment(env)
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
81
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
82
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
83 def hgVersion(plugin):
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
84 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
85 Public method to determine the Mercurial version.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
86
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
87 @param plugin reference to the plugin object
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
88 @type VcsMercurialPlugin
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
89 @return tuple containing the Mercurial version as a string and as a tuple
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
90 and an error message.
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
91 @rtype tuple of str, tuple of int and str
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
92 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
93 versionStr = ""
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
94 version = ()
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
95 errorMsg = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
96
8288
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
97 exe = getHgExecutable()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
98
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
99 args = ["version"]
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
100 args.extend(plugin.getGlobalOptions())
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
101 process = QProcess()
8288
809d5d5ac2ba Made Mercurial an optional installation requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
102 process.start(exe, args)
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
103 procStarted = process.waitForStarted(5000)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
104 if procStarted:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
105 finished = process.waitForFinished(30000)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
106 if finished and process.exitCode() == 0:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
107 output = str(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
108 process.readAllStandardOutput(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
109 plugin.getPreferences("Encoding"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110 "replace",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111 )
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
112 versionStr = output.splitlines()[0].split()[-1][0:-1]
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113 v = list(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
114 re.match(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
115 r".*?(\d+)\.(\d+)\.?(\d+)?(\+[0-9a-f-]+)?", versionStr
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
116 ).groups()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
117 )
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
118 if v[-1] is None:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
119 del v[-1]
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
120 for i in range(3):
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
121 try:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
122 v[i] = int(v[i])
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
123 except TypeError:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
124 v[i] = 0
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
125 except IndexError:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
126 v.append(0)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
127 version = tuple(v)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
128 else:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
129 if finished:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
130 errorMsg = QCoreApplication.translate(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
131 "HgUtilities", "The hg process finished with the exit code {0}"
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
132 ).format(process.exitCode())
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
133 else:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
134 errorMsg = QCoreApplication.translate(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
135 "HgUtilities", "The hg process did not finish within 30s."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
136 )
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
137 else:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
138 errorMsg = QCoreApplication.translate(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
139 "HgUtilities", "Could not start the hg executable."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
140 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
141
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
142 return versionStr, version, errorMsg

eric ide

mercurial