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

Tue, 24 Sep 2024 17:52:41 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 24 Sep 2024 17:52:41 +0200
branch
eric7
changeset 10922
36a90a94765c
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
permissions
-rw-r--r--

Changed EricCore, EricGraphics, EricGui and some of EricNetwork to allow them to be extracted into an external library later on.

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
10439
21c28b0f9e41 Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10438
diff changeset
3 # Copyright (c) 2010 - 2024 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 the VCS status monitor thread class for Mercurial.
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
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: 9221
diff changeset
10 from eric7.VCS.StatusMonitorThread import VcsStatusMonitorThread
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
12
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 class HgStatusMonitorThread(VcsStatusMonitorThread):
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 Class implementing the VCS status monitor thread class for Mercurial.
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
17
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
18 def __init__(self, interval, project, vcs, parent=None):
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
21
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
22 @param interval new interval in seconds
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
23 @type int
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
24 @param project reference to the project object
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
25 @type Project
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param vcs reference to the version control object
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
27 @type Hg
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
28 @param parent reference to the parent object
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
29 @type QObject
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
248
f4561c24989a Changed code to better deal with project relative paths on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 216
diff changeset
31 VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
32
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
33 self.__client = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
34
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 def _performMonitor(self):
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 Protected method implementing the monitoring action.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
38
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
39 This method populates the statusList member variable with a list of
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
40 strings giving the status in the first column and the path relative
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
41 to the project directory starting with the third column. The allowed
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
42 status flags are:
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 <ul>
8618
356a2f1b04b0 Started implementing the VCS status widget for the left side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
44 <li>"A" path was added but not yet committed</li>
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 <li>"M" path has local changes</li>
216
6f9713e8d570 Added actions to identify the repo, to forget about files and added an additional status to be reported by the status monitor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 197
diff changeset
46 <li>"O" path was removed</li>
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 <li>"R" path was deleted and then re-added</li>
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 <li>"U" path needs an update</li>
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 <li>"Z" path contains a conflict</li>
8620
84f7f7867b5f Continued implementing the VCS status widget for the left side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8618
diff changeset
50 <li>"?" path is not tracked</li>
84f7f7867b5f Continued implementing the VCS status widget for the left side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8618
diff changeset
51 <li>"!" path is missing</li>
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 <li>" " path is back at normal</li>
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 </ul>
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
54
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
55 @return tuple of flag indicating successful operation and a status
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
56 message in case of non successful operation
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
57 @rtype tuple of (bool, str)
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.shouldUpdate = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
60
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
61 ok, err = self.__initClient()
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
62 if not ok:
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
63 return False, err
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
64
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
65 # step 1: get overall status
3302
e92f0dd51979 Removed the Mercurial support for a command options dialog and added useable global options to the Mercurial config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
66 args = self.vcs.initCommand("status")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67 args.append("--noninteractive")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68 args.append("--all")
8620
84f7f7867b5f Continued implementing the VCS status widget for the left side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8618
diff changeset
69 if self.vcs.hasSubrepositories():
84f7f7867b5f Continued implementing the VCS status widget for the left side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8618
diff changeset
70 args.append("--subrepos")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
72 output, error = self.__client.runcommand(args)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
73
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
74 if error:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
75 return False, error
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
76
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
77 states = {}
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
78 for line in output.splitlines():
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
79 if not line.startswith(" "):
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
80 flag, name = line.split(" ", 1)
8620
84f7f7867b5f Continued implementing the VCS status widget for the left side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8618
diff changeset
81 if flag in "AMR?!":
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
82 if flag == "R":
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
83 status = "O"
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
84 else:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
85 status = flag
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
86 states[name] = status
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
87
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
88 # step 2: get conflicting changes
3302
e92f0dd51979 Removed the Mercurial support for a command options dialog and added useable global options to the Mercurial config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
89 args = self.vcs.initCommand("resolve")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
90 args.append("--list")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
91
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
92 output, error = self.__client.runcommand(args)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
93
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
94 for line in output.splitlines():
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
95 flag, name = line.split(" ", 1)
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
96 if flag == "U":
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
97 states[name] = "Z" # conflict
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
98
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
99 # step 3: collect the status to be reported back
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
100 for name in states:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
101 try:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
102 if self.reportedStates[name] != states[name]:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
103 self.statusList.append("{0} {1}".format(states[name], name))
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
104 except KeyError:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
105 self.statusList.append("{0} {1}".format(states[name], name))
8205
4a0f1f896341 Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
106 for name in self.reportedStates:
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
107 if name not in states:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
108 self.statusList.append(" {0}".format(name))
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
109 self.reportedStates = states
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111 return (True, self.tr("Mercurial status checked successfully"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
112
6529
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
113 def _getInfo(self):
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
114 """
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
115 Protected method implementing the real info action.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
116
6529
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
117 @return short info message
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
118 @rtype str
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
119 """
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
120 ok, err = self.__initClient()
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
121 if not ok:
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
122 return ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
123
6529
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
124 args = self.vcs.initCommand("identify")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
125 args.append("--num")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
126 args.append("--id")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
127 args.append("--branch")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
128
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
129 output, error = self.__client.runcommand(args)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
130
6529
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
131 if error:
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
132 # ignore errors
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
133 return ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
134
6970
cf9c2dc3f3cc HgStatusMonitorThread: fixed an issue handling branches with spaces in their name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
135 globalRev, localRev, branch = output.splitlines()[0].split(None, 2)
6529
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
136 if globalRev.endswith("+"):
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
137 globalRev = globalRev[:-1]
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
138 if localRev.endswith("+"):
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
139 localRev = localRev[:-1]
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
140
6529
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
141 return self.tr("{0} / {1}:{2}", "branch, local id, global id").format(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
142 branch, localRev, globalRev
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
143 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
144
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
145 def _shutdown(self):
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
146 """
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
147 Protected method performing shutdown actions.
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
148 """
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
149 if self.__client:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
150 self.__client.stopServer()
6529
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
151
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
152 def __initClient(self):
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
153 """
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
154 Private method to initialize the Mercurial client.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
155
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
156 @return tuple containing an OK flag and potentially an error message
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
157 @rtype tuple of (bool, str)
6529
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
158 """
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
159 from .HgClient import HgClient
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
160
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
161 if self.__client is None:
6529
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
162 client = HgClient(self.projectDir, "utf-8", self.vcs)
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
163 ok, err = client.startServer()
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
164 if ok:
1c2968f124b7 VCS: added capability to show some VCS info in the status bar of the main window (next to the status LED).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
165 self.__client = client
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
166 else:
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
167 ok = True
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
168 err = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
169
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
170 return ok, err

eric ide

mercurial