Plugins/VcsPlugins/vcsMercurial/HgStatusMonitorThread.py

changeset 3302
e92f0dd51979
parent 3190
a9a94491c4fd
child 3484
645c12de6b0c
equal deleted inserted replaced
3300:734353e7d679 3302:e92f0dd51979
8 """ 8 """
9 9
10 from PyQt4.QtCore import QProcess 10 from PyQt4.QtCore import QProcess
11 11
12 from VCS.StatusMonitorThread import VcsStatusMonitorThread 12 from VCS.StatusMonitorThread import VcsStatusMonitorThread
13
14 import Preferences
15 13
16 14
17 class HgStatusMonitorThread(VcsStatusMonitorThread): 15 class HgStatusMonitorThread(VcsStatusMonitorThread):
18 """ 16 """
19 Class implementing the VCS status monitor thread class for Mercurial. 17 Class implementing the VCS status monitor thread class for Mercurial.
26 @param project reference to the project object (Project) 24 @param project reference to the project object (Project)
27 @param vcs reference to the version control object 25 @param vcs reference to the version control object
28 @param parent reference to the parent object (QObject) 26 @param parent reference to the parent object (QObject)
29 """ 27 """
30 VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent) 28 VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent)
31
32 self.__ioEncoding = Preferences.getSystem("IOEncoding")
33 29
34 self.__client = None 30 self.__client = None
35 self.__useCommandLine = False 31 self.__useCommandLine = False
36 32
37 def _performMonitor(self): 33 def _performMonitor(self):
70 self.__useCommandLine = True 66 self.__useCommandLine = True
71 else: 67 else:
72 self.__useCommandLine = True 68 self.__useCommandLine = True
73 69
74 # step 1: get overall status 70 # step 1: get overall status
75 args = [] 71 args = self.vcs.initCommand("status")
76 args.append('status')
77 args.append('--noninteractive') 72 args.append('--noninteractive')
78 args.append('--all') 73 args.append('--all')
79 74
80 output = "" 75 output = ""
81 error = "" 76 error = ""
88 procStarted = process.waitForStarted(5000) 83 procStarted = process.waitForStarted(5000)
89 if procStarted: 84 if procStarted:
90 finished = process.waitForFinished(300000) 85 finished = process.waitForFinished(300000)
91 if finished and process.exitCode() == 0: 86 if finished and process.exitCode() == 0:
92 output = str(process.readAllStandardOutput(), 87 output = str(process.readAllStandardOutput(),
93 self.__ioEncoding, 'replace') 88 self.vcs.getEncoding(), 'replace')
94 else: 89 else:
95 process.kill() 90 process.kill()
96 process.waitForFinished() 91 process.waitForFinished()
97 error = str(process.readAllStandardError(), 92 error = str(process.readAllStandardError(),
98 self.__ioEncoding, 'replace') 93 self.vcs.getEncoding(), 'replace')
99 else: 94 else:
100 process.kill() 95 process.kill()
101 process.waitForFinished() 96 process.waitForFinished()
102 error = self.tr("Could not start the Mercurial process.") 97 error = self.tr("Could not start the Mercurial process.")
103 98
114 else: 109 else:
115 status = flag 110 status = flag
116 states[name] = status 111 states[name] = status
117 112
118 # step 2: get conflicting changes 113 # step 2: get conflicting changes
119 args = [] 114 args = self.vcs.initCommand("resolve")
120 args.append('resolve')
121 args.append('--list') 115 args.append('--list')
122 116
123 output = "" 117 output = ""
124 error = "" 118 error = ""
125 if self.__client: 119 if self.__client:
129 process.start('hg', args) 123 process.start('hg', args)
130 procStarted = process.waitForStarted(5000) 124 procStarted = process.waitForStarted(5000)
131 if procStarted: 125 if procStarted:
132 finished = process.waitForFinished(300000) 126 finished = process.waitForFinished(300000)
133 if finished and process.exitCode() == 0: 127 if finished and process.exitCode() == 0:
134 output = str( 128 output = str(process.readAllStandardOutput(),
135 process.readAllStandardOutput(), 129 self.vcs.getEncoding(), 'replace')
136 self.__ioEncoding, 'replace')
137 130
138 for line in output.splitlines(): 131 for line in output.splitlines():
139 flag, name = line.split(" ", 1) 132 flag, name = line.split(" ", 1)
140 if flag == "U": 133 if flag == "U":
141 states[name] = "Z" # conflict 134 states[name] = "Z" # conflict

eric ide

mercurial