1
# -*- coding: utf-8 -*-
3
# Copyright (c) 2006 - 2007 Detlev Offenbach <detlev@die-offenbachs.de>
7
Module implementing the VCS status monitor thread class for Subversion.
10
from PyQt4.QtCore import QRegExp, QProcess, QStringList, QString
12
from VCS.StatusMonitorThread import VcsStatusMonitorThread
16
class SvnStatusMonitorThread(VcsStatusMonitorThread):
18
Class implementing the VCS status monitor thread class for Subversion.
20
def __init__(self, interval, projectDir, parent = None):
24
@param interval new interval in seconds (integer)
25
@param projectDir project directory to monitor (string or QString)
26
@param parent reference to the parent object (QObject)
28
VcsStatusMonitorThread.__init__(self, interval, projectDir, parent)
30
self.__ioEncoding = str(Preferences.getSystem("IOEncoding"))
33
QRegExp('(.{8})\\s+([0-9]+)\\s+(.+)\\s*')
35
QRegExp('(.{8})\\s+([0-9-]+)\\s+([0-9?]+)\\s+([\\w?]+)\\s+(.+)\\s*')
37
def _performMonitor(self):
39
Protected method implementing the monitoring action.
41
This method populates the statusList member variable
42
with a list of strings giving the status in the first column and the
43
path relative to the project directory starting with the third column.
44
The allowed status flags are:
46
<ul>"A" path was added but not yet comitted</ul>
47
<ul>"M" path has local changes</ul>
48
<ul>"U" path needs an update</ul>
49
<ul>"Z" path contains a conflict</ul>
50
<ul>" " path is back at normal</ul>
53
@return tuple of flag indicating successful operation (boolean) and
54
a status message in case of non successful operation (QString)
59
args.append('--show-updates')
60
args.append('--non-interactive')
62
process.setWorkingDirectory(self.projectDir)
63
process.start('svn', args)
64
procStarted = process.waitForStarted()
66
finished = process.waitForFinished(300000)
67
if finished and process.exitCode() == 0:
69
unicode(process.readAllStandardOutput(), self.__ioEncoding, 'replace')
71
for line in output.splitlines():
72
if self.rx_status1.exactMatch(line):
73
flags = str(self.rx_status1.cap(1))
74
path = self.rx_status1.cap(3).trimmed()
75
elif self.rx_status2.exactMatch(line):
76
flags = str(self.rx_status2.cap(1))
77
path = self.rx_status2.cap(5).trimmed()
80
if flags[0] in "ACM" or \
81
(flags[0] == " " and flags[7] == "*"):
87
status = "Z" # give it highest priority
91
if self.reportedStates[name] != status:
92
self.statusList.append("%s %s" % (status, name))
94
self.statusList.append("%s %s" % (status, name))
95
for name in self.reportedStates.keys():
96
if name not in states:
97
self.statusList.append(" %s" % name)
98
self.reportedStates = states
100
self.trUtf8("Subversion status checked successfully (using svn)")
103
return False, QString(process.readAllStandardError())
106
return False, self.trUtf8("Could not start the Subversion process.")