Plugins/VcsPlugins/vcsMercurial/HgStatusMonitorThread.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3302
e92f0dd51979
child 3555
43473ba956ce
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
7 Module implementing the VCS status monitor thread class for Mercurial. 7 Module implementing the VCS status monitor thread class for Mercurial.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 try: 11 try:
12 str = unicode # __IGNORE_WARNING__ 12 str = unicode
13 except (NameError): 13 except NameError:
14 pass 14 pass
15 15
16 from PyQt4.QtCore import QProcess 16 from PyQt4.QtCore import QProcess
17 17
18 from VCS.StatusMonitorThread import VcsStatusMonitorThread 18 from VCS.StatusMonitorThread import VcsStatusMonitorThread
19
20 import Preferences
21 19
22 20
23 class HgStatusMonitorThread(VcsStatusMonitorThread): 21 class HgStatusMonitorThread(VcsStatusMonitorThread):
24 """ 22 """
25 Class implementing the VCS status monitor thread class for Mercurial. 23 Class implementing the VCS status monitor thread class for Mercurial.
32 @param project reference to the project object (Project) 30 @param project reference to the project object (Project)
33 @param vcs reference to the version control object 31 @param vcs reference to the version control object
34 @param parent reference to the parent object (QObject) 32 @param parent reference to the parent object (QObject)
35 """ 33 """
36 VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent) 34 VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent)
37
38 self.__ioEncoding = Preferences.getSystem("IOEncoding")
39 35
40 self.__client = None 36 self.__client = None
41 self.__useCommandLine = False 37 self.__useCommandLine = False
42 38
43 def _performMonitor(self): 39 def _performMonitor(self):
76 self.__useCommandLine = True 72 self.__useCommandLine = True
77 else: 73 else:
78 self.__useCommandLine = True 74 self.__useCommandLine = True
79 75
80 # step 1: get overall status 76 # step 1: get overall status
81 args = [] 77 args = self.vcs.initCommand("status")
82 args.append('status')
83 args.append('--noninteractive') 78 args.append('--noninteractive')
84 args.append('--all') 79 args.append('--all')
85 80
86 output = "" 81 output = ""
87 error = "" 82 error = ""
94 procStarted = process.waitForStarted(5000) 89 procStarted = process.waitForStarted(5000)
95 if procStarted: 90 if procStarted:
96 finished = process.waitForFinished(300000) 91 finished = process.waitForFinished(300000)
97 if finished and process.exitCode() == 0: 92 if finished and process.exitCode() == 0:
98 output = str(process.readAllStandardOutput(), 93 output = str(process.readAllStandardOutput(),
99 self.__ioEncoding, 'replace') 94 self.vcs.getEncoding(), 'replace')
100 else: 95 else:
101 process.kill() 96 process.kill()
102 process.waitForFinished() 97 process.waitForFinished()
103 error = str(process.readAllStandardError(), 98 error = str(process.readAllStandardError(),
104 self.__ioEncoding, 'replace') 99 self.vcs.getEncoding(), 'replace')
105 else: 100 else:
106 process.kill() 101 process.kill()
107 process.waitForFinished() 102 process.waitForFinished()
108 error = self.trUtf8("Could not start the Mercurial process.") 103 error = self.tr("Could not start the Mercurial process.")
109 104
110 if error: 105 if error:
111 return False, error 106 return False, error
112 107
113 states = {} 108 states = {}
120 else: 115 else:
121 status = flag 116 status = flag
122 states[name] = status 117 states[name] = status
123 118
124 # step 2: get conflicting changes 119 # step 2: get conflicting changes
125 args = [] 120 args = self.vcs.initCommand("resolve")
126 args.append('resolve')
127 args.append('--list') 121 args.append('--list')
128 122
129 output = "" 123 output = ""
130 error = "" 124 error = ""
131 if self.__client: 125 if self.__client:
135 process.start('hg', args) 129 process.start('hg', args)
136 procStarted = process.waitForStarted(5000) 130 procStarted = process.waitForStarted(5000)
137 if procStarted: 131 if procStarted:
138 finished = process.waitForFinished(300000) 132 finished = process.waitForFinished(300000)
139 if finished and process.exitCode() == 0: 133 if finished and process.exitCode() == 0:
140 output = str( 134 output = str(process.readAllStandardOutput(),
141 process.readAllStandardOutput(), 135 self.vcs.getEncoding(), 'replace')
142 self.__ioEncoding, 'replace')
143 136
144 for line in output.splitlines(): 137 for line in output.splitlines():
145 flag, name = line.split(" ", 1) 138 flag, name = line.split(" ", 1)
146 if flag == "U": 139 if flag == "U":
147 states[name] = "Z" # conflict 140 states[name] = "Z" # conflict
158 if name not in states: 151 if name not in states:
159 self.statusList.append(" {0}".format(name)) 152 self.statusList.append(" {0}".format(name))
160 self.reportedStates = states 153 self.reportedStates = states
161 154
162 return True, \ 155 return True, \
163 self.trUtf8("Mercurial status checked successfully") 156 self.tr("Mercurial status checked successfully")
164 157
165 def _shutdown(self): 158 def _shutdown(self):
166 """ 159 """
167 Protected method performing shutdown actions. 160 Protected method performing shutdown actions.
168 """ 161 """

eric ide

mercurial