18 |
18 |
19 class SvnStatusMonitorThread(VcsStatusMonitorThread): |
19 class SvnStatusMonitorThread(VcsStatusMonitorThread): |
20 """ |
20 """ |
21 Class implementing the VCS status monitor thread class for Subversion. |
21 Class implementing the VCS status monitor thread class for Subversion. |
22 """ |
22 """ |
|
23 |
23 def __init__(self, interval, project, vcs, parent=None): |
24 def __init__(self, interval, project, vcs, parent=None): |
24 """ |
25 """ |
25 Constructor |
26 Constructor |
26 |
27 |
27 @param interval new interval in seconds (integer) |
28 @param interval new interval in seconds (integer) |
28 @param project reference to the project object (Project) |
29 @param project reference to the project object (Project) |
29 @param vcs reference to the version control object |
30 @param vcs reference to the version control object |
30 @param parent reference to the parent object (QObject) |
31 @param parent reference to the parent object (QObject) |
31 """ |
32 """ |
32 VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent) |
33 VcsStatusMonitorThread.__init__(self, interval, project, vcs, parent) |
33 |
34 |
34 def _performMonitor(self): |
35 def _performMonitor(self): |
35 """ |
36 """ |
36 Protected method implementing the monitoring action. |
37 Protected method implementing the monitoring action. |
37 |
38 |
38 This method populates the statusList member variable |
39 This method populates the statusList member variable |
39 with a list of strings giving the status in the first column and the |
40 with a list of strings giving the status in the first column and the |
40 path relative to the project directory starting with the third column. |
41 path relative to the project directory starting with the third column. |
41 The allowed status flags are: |
42 The allowed status flags are: |
42 <ul> |
43 <ul> |
48 <li>"Z" path contains a conflict</li> |
49 <li>"Z" path contains a conflict</li> |
49 <li>"?" path is not tracked</li> |
50 <li>"?" path is not tracked</li> |
50 <li>"!" path is missing</li> |
51 <li>"!" path is missing</li> |
51 <li>" " path is back at normal</li> |
52 <li>" " path is back at normal</li> |
52 </ul> |
53 </ul> |
53 |
54 |
54 @return tuple of flag indicating successful operation (boolean) and |
55 @return tuple of flag indicating successful operation (boolean) and |
55 a status message in case of non successful operation (string) |
56 a status message in case of non successful operation (string) |
56 """ |
57 """ |
57 self.shouldUpdate = False |
58 self.shouldUpdate = False |
58 |
59 |
59 client = pysvn.Client() |
60 client = pysvn.Client() |
60 client.exception_style = 1 |
61 client.exception_style = 1 |
61 client.callback_get_login = self.__clientLoginCallback |
62 client.callback_get_login = self.__clientLoginCallback |
62 client.callback_ssl_server_trust_prompt = ( |
63 client.callback_ssl_server_trust_prompt = ( |
63 self.__clientSslServerTrustPromptCallback |
64 self.__clientSslServerTrustPromptCallback |
64 ) |
65 ) |
65 |
66 |
66 cwd = os.getcwd() |
67 cwd = os.getcwd() |
67 os.chdir(self.projectDir) |
68 os.chdir(self.projectDir) |
68 try: |
69 try: |
69 allFiles = client.status( |
70 allFiles = client.status( |
70 '.', recurse=True, get_all=True, ignore=True, |
71 ".", |
71 update=not Preferences.getVCS("MonitorLocalStatus")) |
72 recurse=True, |
|
73 get_all=True, |
|
74 ignore=True, |
|
75 update=not Preferences.getVCS("MonitorLocalStatus"), |
|
76 ) |
72 states = {} |
77 states = {} |
73 for file in allFiles: |
78 for file in allFiles: |
74 uptodate = True |
79 uptodate = True |
75 if file.repos_text_status != pysvn.wc_status_kind.none: |
80 if file.repos_text_status != pysvn.wc_status_kind.none: |
76 uptodate = ( |
81 uptodate = ( |
77 uptodate and |
82 uptodate |
78 file.repos_text_status != pysvn.wc_status_kind.modified |
83 and file.repos_text_status != pysvn.wc_status_kind.modified |
79 ) |
84 ) |
80 if file.repos_prop_status != pysvn.wc_status_kind.none: |
85 if file.repos_prop_status != pysvn.wc_status_kind.none: |
81 uptodate = ( |
86 uptodate = ( |
82 uptodate and |
87 uptodate |
83 file.repos_prop_status != pysvn.wc_status_kind.modified |
88 and file.repos_prop_status != pysvn.wc_status_kind.modified |
84 ) |
89 ) |
85 |
90 |
86 status = "" |
91 status = "" |
87 if not uptodate: |
92 if not uptodate: |
88 status = "U" |
93 status = "U" |
89 self.shouldUpdate = True |
94 self.shouldUpdate = True |
90 elif ( |
95 elif ( |
91 file.text_status == pysvn.wc_status_kind.conflicted or |
96 file.text_status == pysvn.wc_status_kind.conflicted |
92 file.prop_status == pysvn.wc_status_kind.conflicted |
97 or file.prop_status == pysvn.wc_status_kind.conflicted |
93 ): |
98 ): |
94 status = "Z" |
99 status = "Z" |
95 elif ( |
100 elif ( |
96 file.text_status == pysvn.wc_status_kind.deleted or |
101 file.text_status == pysvn.wc_status_kind.deleted |
97 file.prop_status == pysvn.wc_status_kind.deleted |
102 or file.prop_status == pysvn.wc_status_kind.deleted |
98 ): |
103 ): |
99 status = "O" |
104 status = "O" |
100 elif ( |
105 elif ( |
101 file.text_status == pysvn.wc_status_kind.modified or |
106 file.text_status == pysvn.wc_status_kind.modified |
102 file.prop_status == pysvn.wc_status_kind.modified |
107 or file.prop_status == pysvn.wc_status_kind.modified |
103 ): |
108 ): |
104 status = "M" |
109 status = "M" |
105 elif ( |
110 elif ( |
106 file.text_status == pysvn.wc_status_kind.added or |
111 file.text_status == pysvn.wc_status_kind.added |
107 file.prop_status == pysvn.wc_status_kind.added |
112 or file.prop_status == pysvn.wc_status_kind.added |
108 ): |
113 ): |
109 status = "A" |
114 status = "A" |
110 elif ( |
115 elif ( |
111 file.text_status == pysvn.wc_status_kind.replaced or |
116 file.text_status == pysvn.wc_status_kind.replaced |
112 file.prop_status == pysvn.wc_status_kind.replaced |
117 or file.prop_status == pysvn.wc_status_kind.replaced |
113 ): |
118 ): |
114 status = "R" |
119 status = "R" |
115 elif ( |
120 elif ( |
116 file.text_status == pysvn.wc_status_kind.unversioned or |
121 file.text_status == pysvn.wc_status_kind.unversioned |
117 file.prop_status == pysvn.wc_status_kind.unversioned |
122 or file.prop_status == pysvn.wc_status_kind.unversioned |
118 ): |
123 ): |
119 status = "?" |
124 status = "?" |
120 elif ( |
125 elif ( |
121 file.text_status == pysvn.wc_status_kind.missing or |
126 file.text_status == pysvn.wc_status_kind.missing |
122 file.prop_status == pysvn.wc_status_kind.missing |
127 or file.prop_status == pysvn.wc_status_kind.missing |
123 ): |
128 ): |
124 status = "!" |
129 status = "!" |
125 if status: |
130 if status: |
126 states[file.path] = status |
131 states[file.path] = status |
127 try: |
132 try: |
128 if self.reportedStates[file.path] != status: |
133 if self.reportedStates[file.path] != status: |
129 self.statusList.append( |
134 self.statusList.append("{0} {1}".format(status, file.path)) |
130 "{0} {1}".format(status, file.path)) |
|
131 except KeyError: |
135 except KeyError: |
132 self.statusList.append( |
136 self.statusList.append("{0} {1}".format(status, file.path)) |
133 "{0} {1}".format(status, file.path)) |
|
134 for name in list(self.reportedStates.keys()): |
137 for name in list(self.reportedStates.keys()): |
135 if name not in states: |
138 if name not in states: |
136 self.statusList.append(" {0}".format(name)) |
139 self.statusList.append(" {0}".format(name)) |
137 self.reportedStates = states |
140 self.reportedStates = states |
138 res = True |
141 res = True |
139 statusStr = self.tr( |
142 statusStr = self.tr("Subversion status checked successfully (using pysvn)") |
140 "Subversion status checked successfully (using pysvn)") |
|
141 except pysvn.ClientError as e: |
143 except pysvn.ClientError as e: |
142 res = False |
144 res = False |
143 statusStr = e.args[0] |
145 statusStr = e.args[0] |
144 os.chdir(cwd) |
146 os.chdir(cwd) |
145 return res, statusStr |
147 return res, statusStr |
146 |
148 |
147 def __clientLoginCallback(self, realm, username, may_save): |
149 def __clientLoginCallback(self, realm, username, may_save): |
148 """ |
150 """ |
149 Private method called by the client to get login information. |
151 Private method called by the client to get login information. |
150 |
152 |
151 @param realm name of the realm of the requested credentials (string) |
153 @param realm name of the realm of the requested credentials (string) |
152 @param username username as supplied by subversion (string) |
154 @param username username as supplied by subversion (string) |
153 @param may_save flag indicating, that subversion is willing to save |
155 @param may_save flag indicating, that subversion is willing to save |
154 the answers returned (boolean) |
156 the answers returned (boolean) |
155 @return tuple of four values (retcode, username, password, save). |
157 @return tuple of four values (retcode, username, password, save). |
157 by subversion, username and password contain the relevant data |
159 by subversion, username and password contain the relevant data |
158 as strings and save is a flag indicating, that username and |
160 as strings and save is a flag indicating, that username and |
159 password should be saved. Always returns (False, "", "", False). |
161 password should be saved. Always returns (False, "", "", False). |
160 """ |
162 """ |
161 return (False, "", "", False) |
163 return (False, "", "", False) |
162 |
164 |
163 def __clientSslServerTrustPromptCallback(self, trust_dict): |
165 def __clientSslServerTrustPromptCallback(self, trust_dict): |
164 """ |
166 """ |
165 Private method called by the client to request acceptance for a |
167 Private method called by the client to request acceptance for a |
166 ssl server certificate. |
168 ssl server certificate. |
167 |
169 |
168 @param trust_dict dictionary containing the trust data |
170 @param trust_dict dictionary containing the trust data |
169 @return tuple of three values (retcode, acceptedFailures, save). |
171 @return tuple of three values (retcode, acceptedFailures, save). |
170 Retcode should be true, if the certificate should be accepted, |
172 Retcode should be true, if the certificate should be accepted, |
171 acceptedFailures should indicate the accepted certificate failures |
173 acceptedFailures should indicate the accepted certificate failures |
172 and save should be True, if subversion should save the certificate. |
174 and save should be True, if subversion should save the certificate. |