Tue, 18 Oct 2022 16:06:21 +0200
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
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:
8620
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 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 | |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | @param interval new interval in seconds (integer) |
248
f4561c24989a
Changed code to better deal with project relative paths on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
216
diff
changeset
|
23 | @param project reference to the project object (Project) |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | @param vcs reference to the version control object |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | @param parent reference to the parent object (QObject) |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
248
f4561c24989a
Changed code to better deal with project relative paths on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
216
diff
changeset
|
27 | 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
|
28 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
29 | self.__client = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
30 | |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | def _performMonitor(self): |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | 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
|
34 | |
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
|
35 | 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
|
36 | 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
|
37 | 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
|
38 | status flags are: |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | <ul> |
8618
356a2f1b04b0
Started implementing the VCS status widget for the left side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
40 | <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
|
41 | <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
|
42 | <li>"O" path was removed</li> |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | <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
|
44 | <li>"U" path needs an update</li> |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | <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
|
46 | <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
|
47 | <li>"!" path is missing</li> |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | <li>" " path is back at normal</li> |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | </ul> |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
50 | |
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
|
51 | @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
|
52 | 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
|
53 | @rtype tuple of (bool, str) |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | """ |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | self.shouldUpdate = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
56 | |
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
|
57 | 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
|
58 | 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
|
59 | return False, err |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
61 | # 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
|
62 | 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
|
63 | args.append("--noninteractive") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
64 | 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
|
65 | 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
|
66 | args.append("--subrepos") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
67 | |
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
|
68 | 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
|
69 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
70 | if error: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
71 | return False, error |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
73 | states = {} |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
74 | 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
|
75 | if not line.startswith(" "): |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
76 | 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
|
77 | 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
|
78 | if flag == "R": |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
79 | status = "O" |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
80 | else: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
81 | status = flag |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
82 | states[name] = status |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
83 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
84 | # 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
|
85 | 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
|
86 | args.append("--list") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
87 | |
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
|
88 | 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
|
89 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
90 | 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
|
91 | 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
|
92 | if flag == "U": |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
93 | states[name] = "Z" # conflict |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
94 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
95 | # 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
|
96 | for name in states: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
97 | try: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
98 | 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
|
99 | 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
|
100 | except KeyError: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
101 | 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
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | self.reportedStates = states |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
106 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
107 | 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
|
108 | |
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
|
109 | 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
|
110 | """ |
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
|
111 | 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
|
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 | @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
|
114 | @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
|
115 | """ |
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
|
116 | 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
|
117 | 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
|
118 | return "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
119 | |
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
|
120 | 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
|
121 | args.append("--num") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
122 | args.append("--id") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
123 | args.append("--branch") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
124 | |
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
|
125 | 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
|
126 | |
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
|
127 | 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
|
128 | # 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
|
129 | return "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
130 | |
6970
cf9c2dc3f3cc
HgStatusMonitorThread: fixed an issue handling branches with spaces in their name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6942
diff
changeset
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | 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
|
135 | localRev = localRev[:-1] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
136 | |
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
|
137 | 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
|
138 | branch, localRev, globalRev |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
139 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
140 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
141 | def _shutdown(self): |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
142 | """ |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
143 | 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
|
144 | """ |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
145 | if self.__client: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
146 | 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
|
147 | |
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
|
148 | 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
|
149 | """ |
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
|
150 | 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
|
151 | |
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
|
152 | @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
|
153 | @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
|
154 | """ |
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
|
155 | 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
|
156 | from .HgClient import HgClient |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
157 | |
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 | 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
|
159 | 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
|
160 | 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
|
161 | 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
|
162 | 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
|
163 | 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
|
164 | err = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
165 | |
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 | return ok, err |