620 else: |
622 else: |
621 dname, fname = self.splitPath(name) |
623 dname, fname = self.splitPath(name) |
622 names = [] |
624 names = [] |
623 tree = [] |
625 tree = [] |
624 wdir = dname |
626 wdir = dname |
625 while not os.path.exists(os.path.join(dname, self.adminDir)): |
627 if self.__wcng: |
626 # add directories recursively, if they aren't in the repository already |
628 repodir = dname |
627 tree.insert(-1, dname) |
629 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
628 dname = os.path.split(dname)[0] |
630 repodir = os.path.dirname(repodir) |
629 wdir = dname |
631 if os.path.splitdrive(repodir)[1] == os.sep: |
|
632 return # oops, project is not version controlled |
|
633 while os.path.normcase(dname) != os.path.normcase(repodir) and \ |
|
634 (os.path.normcase(dname) not in self.statusCache or \ |
|
635 self.statusCache[os.path.normcase(dname)] == self.canBeAdded): |
|
636 # add directories recursively, if they aren't in the repository already |
|
637 tree.insert(-1, dname) |
|
638 dname = os.path.dirname(dname) |
|
639 wdir = dname |
|
640 else: |
|
641 while not os.path.exists(os.path.join(dname, self.adminDir)): |
|
642 # add directories recursively, if they aren't in the repository already |
|
643 tree.insert(-1, dname) |
|
644 dname = os.path.dirname(dname) |
|
645 wdir = dname |
630 names.extend(tree) |
646 names.extend(tree) |
631 |
647 |
632 if isinstance(name, list): |
648 if isinstance(name, list): |
633 tree2 = [] |
649 tree2 = [] |
634 for n in name: |
650 for n in name: |
635 d = os.path.split(n)[0] |
651 d = os.path.dirname(n) |
636 while not os.path.exists(os.path.join(d, self.adminDir)): |
652 if self.__wcng: |
637 if d in tree2 + tree: |
653 repodir = d |
638 break |
654 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
639 tree2.append(d) |
655 repodir = os.path.dirname(repodir) |
640 d = os.path.split(d)[0] |
656 if os.path.splitdrive(repodir)[1] == os.sep: |
|
657 return # oops, project is not version controlled |
|
658 while os.path.normcase(d) != os.path.normcase(repodir) and \ |
|
659 (d not in tree2 + tree) and \ |
|
660 (os.path.normcase(d) not in self.statusCache or \ |
|
661 self.statusCache[os.path.normcase(d)] == self.canBeAdded): |
|
662 tree2.append(d) |
|
663 d = os.path.dirname(d) |
|
664 else: |
|
665 while not os.path.exists(os.path.join(d, self.adminDir)): |
|
666 if d in tree2 + tree: |
|
667 break |
|
668 tree2.append(d) |
|
669 d = os.path.dirname(d) |
641 tree2.reverse() |
670 tree2.reverse() |
642 names.extend(tree2) |
671 names.extend(tree2) |
643 names.extend(name) |
672 names.extend(name) |
644 else: |
673 else: |
645 names.append(name) |
674 names.append(name) |
691 """ |
720 """ |
692 tree = [] |
721 tree = [] |
693 if isinstance(path, list): |
722 if isinstance(path, list): |
694 dname, fnames = self.splitPathList(path) |
723 dname, fnames = self.splitPathList(path) |
695 for n in path: |
724 for n in path: |
696 d = os.path.split(n)[0] |
725 d = os.path.dirname(n) |
697 while not os.path.exists(os.path.join(d, self.adminDir)): |
726 if self.__wcng: |
|
727 repodir = d |
|
728 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
729 repodir = os.path.dirname(repodir) |
|
730 if os.path.splitdrive(repodir)[1] == os.sep: |
|
731 return # oops, project is not version controlled |
|
732 while os.path.normcase(d) != os.path.normcase(repodir) and \ |
|
733 (d not in tree) and \ |
|
734 (os.path.normcase(d) not in self.statusCache or \ |
|
735 self.statusCache[os.path.normcase(d)] == self.canBeAdded): |
|
736 tree.append(d) |
|
737 d = os.path.dirname(d) |
|
738 else: |
|
739 while not os.path.exists(os.path.join(d, self.adminDir)): |
|
740 # add directories recursively, |
|
741 # if they aren't in the repository already |
|
742 if d in tree: |
|
743 break |
|
744 tree.append(d) |
|
745 d = os.path.dirname(d) |
|
746 tree.reverse() |
|
747 else: |
|
748 dname, fname = os.path.split(path) |
|
749 if self.__wcng: |
|
750 repodir = dname |
|
751 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
752 repodir = os.path.dirname(repodir) |
|
753 if os.path.splitdrive(repodir)[1] == os.sep: |
|
754 return # oops, project is not version controlled |
|
755 while os.path.normcase(dname) != os.path.normcase(repodir) and \ |
|
756 (os.path.normcase(dname) not in self.statusCache or \ |
|
757 self.statusCache[os.path.normcase(dname)] == self.canBeAdded): |
|
758 # add directories recursively, if they aren't in the repository already |
|
759 tree.insert(-1, dname) |
|
760 dname = os.path.dirname(dname) |
|
761 else: |
|
762 while not os.path.exists(os.path.join(dname, self.adminDir)): |
698 # add directories recursively, |
763 # add directories recursively, |
699 # if they aren't in the repository already |
764 # if they aren't in the repository already |
700 if d in tree: |
765 tree.insert(-1, dname) |
701 break |
766 dname = os.path.dirname(dname) |
702 tree.append(d) |
|
703 d = os.path.split(d)[0] |
|
704 tree.reverse() |
|
705 else: |
|
706 dname, fname = os.path.split(path) |
|
707 while not os.path.exists(os.path.join(dname, self.adminDir)): |
|
708 # add directories recursively, |
|
709 # if they aren't in the repository already |
|
710 tree.insert(-1, dname) |
|
711 dname = os.path.split(dname)[0] |
|
712 if tree: |
767 if tree: |
713 self.vcsAdd(tree, True) |
768 self.vcsAdd(tree, True) |
714 |
769 |
715 names = [] |
770 names = [] |
716 if isinstance(path, list): |
771 if isinstance(path, list): |
1216 Public method used to get the registered state of a file in the vcs. |
1271 Public method used to get the registered state of a file in the vcs. |
1217 |
1272 |
1218 @param name filename to check (string) |
1273 @param name filename to check (string) |
1219 @return a combination of canBeCommited and canBeAdded |
1274 @return a combination of canBeCommited and canBeAdded |
1220 """ |
1275 """ |
|
1276 if self.__wcng: |
|
1277 return self.__vcsRegisteredState_wcng(name) |
|
1278 else: |
|
1279 return self.__vcsRegisteredState_wc(name) |
|
1280 |
|
1281 def __vcsRegisteredState_wcng(self, name): |
|
1282 """ |
|
1283 Private method used to get the registered state of a file in the vcs. |
|
1284 |
|
1285 This is the variant for subversion installations using the new working copy |
|
1286 meta-data format. |
|
1287 |
|
1288 @param name filename to check (string) |
|
1289 @return a combination of canBeCommited and canBeAdded |
|
1290 """ |
|
1291 if name.endswith(os.sep): |
|
1292 name = name[:-1] |
|
1293 name = os.path.normcase(name) |
|
1294 dname, fname = self.splitPath(name) |
|
1295 |
|
1296 if fname == '.' and os.path.isdir(os.path.join(dname, self.adminDir)): |
|
1297 return self.canBeCommitted |
|
1298 |
|
1299 if name in self.statusCache: |
|
1300 return self.statusCache[name] |
|
1301 |
|
1302 name = os.path.normcase(name) |
|
1303 states = { name : 0 } |
|
1304 states = self.vcsAllRegisteredStates(states, dname, False) |
|
1305 if states[name] == self.canBeCommitted: |
|
1306 return self.canBeCommitted |
|
1307 else: |
|
1308 return self.canBeAdded |
|
1309 |
|
1310 def __vcsRegisteredState_wc(self, name): |
|
1311 """ |
|
1312 Private method used to get the registered state of a file in the vcs. |
|
1313 |
|
1314 This is the variant for subversion installations using the old working copy |
|
1315 meta-data format. |
|
1316 |
|
1317 @param name filename to check (string) |
|
1318 @return a combination of canBeCommited and canBeAdded |
|
1319 """ |
1221 dname, fname = self.splitPath(name) |
1320 dname, fname = self.splitPath(name) |
1222 |
1321 |
1223 if fname == '.': |
1322 if fname == '.': |
1224 if os.path.isdir(os.path.join(dname, self.adminDir)): |
1323 if os.path.isdir(os.path.join(dname, self.adminDir)): |
1225 return self.canBeCommitted |
1324 return self.canBeCommitted |
1244 |
1343 |
1245 @param names dictionary with all filenames to be checked as keys |
1344 @param names dictionary with all filenames to be checked as keys |
1246 @param dname directory to check in (string) |
1345 @param dname directory to check in (string) |
1247 @param shortcut flag indicating a shortcut should be taken (boolean) |
1346 @param shortcut flag indicating a shortcut should be taken (boolean) |
1248 @return the received dictionary completed with a combination of |
1347 @return the received dictionary completed with a combination of |
|
1348 canBeCommited and canBeAdded or None in order to signal an error |
|
1349 """ |
|
1350 if self.__wcng: |
|
1351 return self.__vcsAllRegisteredStates_wcng(names, dname, shortcut) |
|
1352 else: |
|
1353 return self.__vcsAllRegisteredStates_wc(names, dname, shortcut) |
|
1354 |
|
1355 def __vcsAllRegisteredStates_wcng(self, names, dname, shortcut = True): |
|
1356 """ |
|
1357 Private method used to get the registered states of a number of files in the vcs. |
|
1358 |
|
1359 This is the variant for subversion installations using the new working copy |
|
1360 meta-data format. |
|
1361 |
|
1362 <b>Note:</b> If a shortcut is to be taken, the code will only check, if the named |
|
1363 directory has been scanned already. If so, it is assumed, that the states for |
|
1364 all files has been populated by the previous run. |
|
1365 |
|
1366 @param names dictionary with all filenames to be checked as keys |
|
1367 @param dname directory to check in (string) |
|
1368 @param shortcut flag indicating a shortcut should be taken (boolean) |
|
1369 @return the received dictionary completed with a combination of |
|
1370 canBeCommited and canBeAdded or None in order to signal an error |
|
1371 """ |
|
1372 if dname.endswith(os.sep): |
|
1373 dname = dname[:-1] |
|
1374 dname = os.path.normcase(dname) |
|
1375 |
|
1376 found = False |
|
1377 for name in self.statusCache.keys(): |
|
1378 if name in names: |
|
1379 found = True |
|
1380 names[name] = self.statusCache[name] |
|
1381 |
|
1382 if not found: |
|
1383 # find the root of the repo |
|
1384 repodir = dname |
|
1385 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
1386 repodir = os.path.dirname(repodir) |
|
1387 if os.path.splitdrive(repodir)[1] == os.sep: |
|
1388 return names |
|
1389 |
|
1390 from .SvnDialogMixin import SvnDialogMixin |
|
1391 mixin = SvnDialogMixin() |
|
1392 client = self.getClient() |
|
1393 client.callback_get_login = \ |
|
1394 mixin._clientLoginCallback |
|
1395 client.callback_ssl_server_trust_prompt = \ |
|
1396 mixin._clientSslServerTrustPromptCallback |
|
1397 |
|
1398 try: |
|
1399 locker = QMutexLocker(self.vcsExecutionMutex) |
|
1400 allFiles = client.status(dname, recurse = True, get_all = True, |
|
1401 ignore = True, update = False) |
|
1402 locker.unlock() |
|
1403 dirs = [x for x in names.keys() if os.path.isdir(x)] |
|
1404 for file in allFiles: |
|
1405 name = os.path.normcase(file.path) |
|
1406 if file.is_versioned: |
|
1407 if name in names: |
|
1408 names[name] = self.canBeCommitted |
|
1409 dn = name |
|
1410 while os.path.splitdrive(dn)[1] != os.sep and \ |
|
1411 dn != repodir: |
|
1412 dn = os.path.dirname(dn) |
|
1413 if dn in self.statusCache and \ |
|
1414 self.statusCache[dn] == self.canBeCommitted: |
|
1415 break |
|
1416 self.statusCache[dn] = self.canBeCommitted |
|
1417 self.statusCache[name] = self.canBeCommitted |
|
1418 if dirs: |
|
1419 for d in dirs: |
|
1420 if name.startswith(d): |
|
1421 names[d] = self.canBeCommitted |
|
1422 self.statusCache[d] = self.canBeCommitted |
|
1423 dirs.remove(d) |
|
1424 break |
|
1425 else: |
|
1426 self.statusCache[name] = self.canBeAdded |
|
1427 except pysvn.ClientError: |
|
1428 locker.unlock() # ignore pysvn errors |
|
1429 |
|
1430 return names |
|
1431 |
|
1432 def __vcsAllRegisteredStates_wc(self, names, dname, shortcut = True): |
|
1433 """ |
|
1434 Private method used to get the registered states of a number of files in the vcs. |
|
1435 |
|
1436 This is the variant for subversion installations using the old working copy |
|
1437 meta-data format. |
|
1438 |
|
1439 <b>Note:</b> If a shortcut is to be taken, the code will only check, if the named |
|
1440 directory has been scanned already. If so, it is assumed, that the states for |
|
1441 all files has been populated by the previous run. |
|
1442 |
|
1443 @param names dictionary with all filenames to be checked as keys |
|
1444 @param dname directory to check in (string) |
|
1445 @param shortcut flag indicating a shortcut should be taken (boolean) |
|
1446 @return the received dictionary completed with a combination of |
1249 canBeCommited and canBeAdded or None in order to signal an error |
1447 canBeCommited and canBeAdded or None in order to signal an error |
1250 """ |
1448 """ |
1251 if not os.path.isdir(os.path.join(dname, self.adminDir)): |
1449 if not os.path.isdir(os.path.join(dname, self.adminDir)): |
1252 # not under version control -> do nothing |
1450 # not under version control -> do nothing |
1253 return names |
1451 return names |
2026 @param project reference to the project object |
2224 @param project reference to the project object |
2027 @return the project helper object |
2225 @return the project helper object |
2028 """ |
2226 """ |
2029 helper = self.__plugin.getProjectHelper() |
2227 helper = self.__plugin.getProjectHelper() |
2030 helper.setObjects(self, project) |
2228 helper.setObjects(self, project) |
|
2229 self.__wcng = \ |
|
2230 os.path.exists(os.path.join(project.getProjectPath(), ".svn", "format")) or \ |
|
2231 os.path.exists(os.path.join(project.getProjectPath(), "_svn", "format")) |
2031 return helper |
2232 return helper |
2032 |
2233 |
2033 ############################################################################ |
2234 ############################################################################ |
2034 ## Status Monitor Thread methods |
2235 ## Status Monitor Thread methods |
2035 ############################################################################ |
2236 ############################################################################ |