Thu, 30 Dec 2021 11:17:58 +0100
Updated copyright for 2022.
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 | |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from VCS.StatusMonitorThread import VcsStatusMonitorThread |
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 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
17 | 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
|
18 | """ |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | Constructor |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | @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
|
22 | @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
|
23 | @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
|
24 | @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
|
25 | """ |
248
f4561c24989a
Changed code to better deal with project relative paths on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
216
diff
changeset
|
26 | VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent) |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
28 | self.__client = None |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | def _performMonitor(self): |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | Protected method implementing the monitoring action. |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | |
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
|
34 | 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
|
35 | 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
|
36 | 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
|
37 | status flags are: |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | <ul> |
8618
356a2f1b04b0
Started implementing the VCS status widget for the left side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
39 | <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
|
40 | <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
|
41 | <li>"O" path was removed</li> |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | <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
|
43 | <li>"U" path needs an update</li> |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | <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
|
45 | <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
|
46 | <li>"!" path is missing</li> |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | <li>" " path is back at normal</li> |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | </ul> |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | |
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
|
50 | @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
|
51 | 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
|
52 | @rtype tuple of (bool, str) |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | self.shouldUpdate = False |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | |
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
|
56 | 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
|
57 | 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
|
58 | return False, err |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
59 | |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
60 | # 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
|
61 | args = self.vcs.initCommand("status") |
178
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | args.append('--noninteractive') |
dd9f0bca5e2f
Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | 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
|
64 | 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
|
65 | args.append("--subrepos") |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
66 | |
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
|
67 | output, error = self.__client.runcommand(args) |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
68 | |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
69 | if error: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
70 | return False, error |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
71 | |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
72 | states = {} |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
73 | 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
|
74 | if not line.startswith(" "): |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
75 | 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
|
76 | 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
|
77 | if flag == "R": |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
78 | status = "O" |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
79 | else: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
80 | status = flag |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
81 | states[name] = status |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
82 | |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
83 | # 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
|
84 | args = self.vcs.initCommand("resolve") |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
85 | args.append('--list') |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
86 | |
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
|
87 | output, error = self.__client.runcommand(args) |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
88 | |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
89 | 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
|
90 | 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
|
91 | if flag == "U": |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
92 | states[name] = "Z" # conflict |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
93 | |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
94 | # 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
|
95 | for name in states: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
96 | try: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
97 | if self.reportedStates[name] != states[name]: |
3008
7848489bcb92
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2771
diff
changeset
|
98 | self.statusList.append( |
7848489bcb92
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2771
diff
changeset
|
99 | "{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 |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
106 | |
7257
c4d0cac9b5c9
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
107 | return ( |
c4d0cac9b5c9
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
108 | True, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
109 | self.tr("Mercurial status checked successfully") |
7257
c4d0cac9b5c9
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
110 | ) |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
111 | |
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
|
112 | 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
|
113 | """ |
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 | Protected method implementing the real info action. |
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 | |
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
|
116 | @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
|
117 | @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
|
118 | """ |
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
|
119 | 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
|
120 | 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
|
121 | return "" |
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
|
122 | |
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
|
123 | args = self.vcs.initCommand("identify") |
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.append('--num') |
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
|
125 | args.append('--id') |
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
|
126 | args.append('--branch') |
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 | |
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
|
128 | output, error = self.__client.runcommand(args) |
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
|
129 | |
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
|
130 | 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
|
131 | # 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
|
132 | return "" |
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 | |
6970
cf9c2dc3f3cc
HgStatusMonitorThread: fixed an issue handling branches with spaces in their name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6942
diff
changeset
|
134 | 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
|
135 | 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
|
136 | 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
|
137 | 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
|
138 | localRev = localRev[:-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
|
139 | |
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
|
140 | return self.tr("{0} / {1}:{2}", "branch, local id, global id").format( |
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 | branch, localRev, globalRev) |
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
|
142 | |
1255
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
143 | def _shutdown(self): |
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 | 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
|
146 | """ |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
147 | if self.__client: |
e1d8a8a4d40c
Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
148 | 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
|
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 | 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
|
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 | Private method to initialize the Mercurial 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
|
153 | |
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
|
154 | @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
|
155 | @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
|
156 | """ |
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
|
157 | 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
|
158 | from .HgClient import HgClient |
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 | 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
|
160 | 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
|
161 | 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
|
162 | 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
|
163 | 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
|
164 | 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
|
165 | err = "" |
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 | |
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 | return ok, err |