52 @return tuple of flag indicating successful operation (boolean) and |
56 @return tuple of flag indicating successful operation (boolean) and |
53 a status message in case of non successful operation (string) |
57 a status message in case of non successful operation (string) |
54 """ |
58 """ |
55 self.shouldUpdate = False |
59 self.shouldUpdate = False |
56 |
60 |
57 process = QProcess() |
61 if self.__client is None and not self.__useCommandLine: |
|
62 if self.vcs.versionStr >= "1.9": |
|
63 client = HgClient(self.projectDir, "utf-8") |
|
64 ok, err = client.startServer() |
|
65 if ok: |
|
66 self.__client = client |
|
67 else: |
|
68 self.__useCommandLine = True |
|
69 else: |
|
70 self.__useCommandLine = True |
|
71 |
|
72 # step 1: get overall status |
58 args = [] |
73 args = [] |
59 args.append('status') |
74 args.append('status') |
60 args.append('--noninteractive') |
75 args.append('--noninteractive') |
61 args.append('--all') |
76 args.append('--all') |
62 process.setWorkingDirectory(self.projectDir) |
77 |
63 process.start('hg', args) |
78 output = "" |
64 procStarted = process.waitForStarted() |
79 error = "" |
65 if procStarted: |
80 if self.__client: |
66 finished = process.waitForFinished(300000) |
81 output, error = self.__client.runcommand(args) |
67 if finished and process.exitCode() == 0: |
82 else: |
68 output = \ |
83 process = QProcess() |
69 str(process.readAllStandardOutput(), self.__ioEncoding, 'replace') |
84 process.setWorkingDirectory(self.projectDir) |
70 states = {} |
85 process.start('hg', args) |
71 for line in output.splitlines(): |
86 procStarted = process.waitForStarted() |
72 if not line.startswith(" "): |
87 if procStarted: |
73 flag, name = line.split(" ", 1) |
88 finished = process.waitForFinished(300000) |
74 if flag in "AMR": |
89 if finished and process.exitCode() == 0: |
75 if flag == "R": |
90 output = \ |
76 status = "O" |
91 str(process.readAllStandardOutput(), self.__ioEncoding, 'replace') |
77 else: |
92 else: |
78 status = flag |
93 process.kill() |
79 states[name] = status |
94 process.waitForFinished() |
80 |
95 error = \ |
81 args = [] |
96 str(process.readAllStandardError(), self.__ioEncoding, 'replace') |
82 args.append('resolve') |
|
83 args.append('--list') |
|
84 process.setWorkingDirectory(self.projectDir) |
|
85 process.start('hg', args) |
|
86 procStarted = process.waitForStarted() |
|
87 if procStarted: |
|
88 finished = process.waitForFinished(300000) |
|
89 if finished and process.exitCode() == 0: |
|
90 output = str( |
|
91 process.readAllStandardOutput(), self.__ioEncoding, 'replace') |
|
92 for line in output.splitlines(): |
|
93 flag, name = line.split(" ", 1) |
|
94 if flag == "U": |
|
95 states[name] = "Z" # conflict |
|
96 |
|
97 for name in states: |
|
98 try: |
|
99 if self.reportedStates[name] != states[name]: |
|
100 self.statusList.append("{0} {1}".format(states[name], name)) |
|
101 except KeyError: |
|
102 self.statusList.append("{0} {1}".format(states[name], name)) |
|
103 for name in self.reportedStates.keys(): |
|
104 if name not in states: |
|
105 self.statusList.append(" {0}".format(name)) |
|
106 self.reportedStates = states |
|
107 return True, \ |
|
108 self.trUtf8("Mercurial status checked successfully") |
|
109 else: |
97 else: |
110 process.kill() |
98 process.kill() |
111 process.waitForFinished() |
99 process.waitForFinished() |
112 return False, \ |
100 error = self.trUtf8("Could not start the Mercurial process.") |
113 str(process.readAllStandardError(), |
101 |
114 Preferences.getSystem("IOEncoding"), |
102 if error: |
115 'replace') |
103 return False, error |
|
104 |
|
105 states = {} |
|
106 for line in output.splitlines(): |
|
107 if not line.startswith(" "): |
|
108 flag, name = line.split(" ", 1) |
|
109 if flag in "AMR": |
|
110 if flag == "R": |
|
111 status = "O" |
|
112 else: |
|
113 status = flag |
|
114 states[name] = status |
|
115 |
|
116 # step 2: get conflicting changes |
|
117 args = [] |
|
118 args.append('resolve') |
|
119 args.append('--list') |
|
120 |
|
121 output = "" |
|
122 error = "" |
|
123 if self.__client: |
|
124 output, error = self.__client.runcommand(args) |
116 else: |
125 else: |
117 process.kill() |
126 process.setWorkingDirectory(self.projectDir) |
118 process.waitForFinished() |
127 process.start('hg', args) |
119 return False, self.trUtf8("Could not start the Mercurial process.") |
128 procStarted = process.waitForStarted() |
|
129 if procStarted: |
|
130 finished = process.waitForFinished(300000) |
|
131 if finished and process.exitCode() == 0: |
|
132 output = str( |
|
133 process.readAllStandardOutput(), self.__ioEncoding, 'replace') |
|
134 |
|
135 for line in output.splitlines(): |
|
136 flag, name = line.split(" ", 1) |
|
137 if flag == "U": |
|
138 states[name] = "Z" # conflict |
|
139 |
|
140 # step 3: collect the status to be reported back |
|
141 for name in states: |
|
142 try: |
|
143 if self.reportedStates[name] != states[name]: |
|
144 self.statusList.append("{0} {1}".format(states[name], name)) |
|
145 except KeyError: |
|
146 self.statusList.append("{0} {1}".format(states[name], name)) |
|
147 for name in self.reportedStates.keys(): |
|
148 if name not in states: |
|
149 self.statusList.append(" {0}".format(name)) |
|
150 self.reportedStates = states |
|
151 |
|
152 return True, \ |
|
153 self.trUtf8("Mercurial status checked successfully") |
|
154 |
|
155 def _shutdown(self): |
|
156 """ |
|
157 Protected method performing shutdown actions. |
|
158 """ |
|
159 if self.__client: |
|
160 self.__client.stopServer() |