src/eric7/Plugins/VcsPlugins/vcsSubversion/subversion.py

branch
eric7
changeset 10491
acabc60b19a2
parent 10441
a79201e0e149
child 10683
779cda568acb
equal deleted inserted replaced
10490:527d47826e97 10491:acabc60b19a2
18 18
19 from eric7 import Preferences, Utilities 19 from eric7 import Preferences, Utilities
20 from eric7.EricWidgets import EricMessageBox 20 from eric7.EricWidgets import EricMessageBox
21 from eric7.EricWidgets.EricApplication import ericApp 21 from eric7.EricWidgets.EricApplication import ericApp
22 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog 22 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog
23 from eric7.VCS.VersionControl import VersionControl 23 from eric7.VCS.VersionControl import VersionControl, VersionControlState
24 24
25 from .SvnDialog import SvnDialog 25 from .SvnDialog import SvnDialog
26 from .SvnUtilities import amendConfig, createDefaultConfig, getConfigPath 26 from .SvnUtilities import amendConfig, createDefaultConfig, getConfigPath
27 27
28 28
700 repodir = os.path.dirname(repodir) 700 repodir = os.path.dirname(repodir)
701 if os.path.splitdrive(repodir)[1] == os.sep: 701 if os.path.splitdrive(repodir)[1] == os.sep:
702 return # oops, project is not version controlled 702 return # oops, project is not version controlled
703 while os.path.normcase(dname) != os.path.normcase(repodir) and ( 703 while os.path.normcase(dname) != os.path.normcase(repodir) and (
704 os.path.normcase(dname) not in self.statusCache 704 os.path.normcase(dname) not in self.statusCache
705 or self.statusCache[os.path.normcase(dname)] == self.canBeAdded 705 or self.statusCache[os.path.normcase(dname)]
706 == VersionControlState.Uncontrolled
706 ): 707 ):
707 # add directories recursively, if they aren't in the 708 # add directories recursively, if they aren't in the
708 # repository already 709 # repository already
709 tree.insert(-1, dname) 710 tree.insert(-1, dname)
710 dname = os.path.dirname(dname) 711 dname = os.path.dirname(dname)
731 while ( 732 while (
732 os.path.normcase(d) != os.path.normcase(repodir) 733 os.path.normcase(d) != os.path.normcase(repodir)
733 and (d not in tree2 + tree) 734 and (d not in tree2 + tree)
734 and ( 735 and (
735 os.path.normcase(d) not in self.statusCache 736 os.path.normcase(d) not in self.statusCache
736 or self.statusCache[os.path.normcase(d)] == self.canBeAdded 737 or self.statusCache[os.path.normcase(d)]
738 == VersionControlState.Uncontrolled
737 ) 739 )
738 ): 740 ):
739 tree2.append(d) 741 tree2.append(d)
740 d = os.path.dirname(d) 742 d = os.path.dirname(d)
741 else: 743 else:
799 while ( 801 while (
800 os.path.normcase(d) != os.path.normcase(repodir) 802 os.path.normcase(d) != os.path.normcase(repodir)
801 and (d not in tree) 803 and (d not in tree)
802 and ( 804 and (
803 os.path.normcase(d) not in self.statusCache 805 os.path.normcase(d) not in self.statusCache
804 or self.statusCache[os.path.normcase(d)] == self.canBeAdded 806 or self.statusCache[os.path.normcase(d)]
807 == VersionControlState.Uncontrolled
805 ) 808 )
806 ): 809 ):
807 tree.append(d) 810 tree.append(d)
808 d = os.path.dirname(d) 811 d = os.path.dirname(d)
809 else: 812 else:
823 repodir = os.path.dirname(repodir) 826 repodir = os.path.dirname(repodir)
824 if os.path.splitdrive(repodir)[1] == os.sep: 827 if os.path.splitdrive(repodir)[1] == os.sep:
825 return # oops, project is not version controlled 828 return # oops, project is not version controlled
826 while os.path.normcase(dname) != os.path.normcase(repodir) and ( 829 while os.path.normcase(dname) != os.path.normcase(repodir) and (
827 os.path.normcase(dname) not in self.statusCache 830 os.path.normcase(dname) not in self.statusCache
828 or self.statusCache[os.path.normcase(dname)] == self.canBeAdded 831 or self.statusCache[os.path.normcase(dname)]
832 == VersionControlState.Uncontrolled
829 ): 833 ):
830 # add directories recursively, if they aren't in the 834 # add directories recursively, if they aren't in the
831 # repository already 835 # repository already
832 tree.insert(-1, dname) 836 tree.insert(-1, dname)
833 dname = os.path.dirname(dname) 837 dname = os.path.dirname(dname)
1315 """ 1319 """
1316 Public method used to get the registered state of a file in the vcs. 1320 Public method used to get the registered state of a file in the vcs.
1317 1321
1318 @param name filename to check 1322 @param name filename to check
1319 @type str 1323 @type str
1320 @return registered state (one of canBeCommited and canBeAdded) 1324 @return registered state
1321 @rtype int 1325 @rtype VersionControlState
1322 """ 1326 """
1323 if self.__wcng: 1327 if self.__wcng:
1324 return self.__vcsRegisteredState_wcng(name) 1328 return self.__vcsRegisteredState_wcng(name)
1325 else: 1329 else:
1326 return self.__vcsRegisteredState_wc(name) 1330 return self.__vcsRegisteredState_wc(name)
1332 This is the variant for subversion installations using the new 1336 This is the variant for subversion installations using the new
1333 working copy meta-data format. 1337 working copy meta-data format.
1334 1338
1335 @param name filename to check 1339 @param name filename to check
1336 @type str 1340 @type str
1337 @return registered state (one of canBeCommited and canBeAdded) 1341 @return registered state
1338 @rtype int 1342 @rtype VersionControlState
1339 """ 1343 """
1340 if name.endswith(os.sep): 1344 if name.endswith(os.sep):
1341 name = name[:-1] 1345 name = name[:-1]
1342 name = os.path.normcase(name) 1346 name = os.path.normcase(name)
1343 dname, fname = self.splitPath(name) 1347 dname, fname = self.splitPath(name)
1344 1348
1345 if fname == "." and os.path.isdir(os.path.join(dname, self.adminDir)): 1349 if fname == "." and os.path.isdir(os.path.join(dname, self.adminDir)):
1346 return self.canBeCommitted 1350 return VersionControlState.Controlled
1347 1351
1348 if name in self.statusCache: 1352 if name in self.statusCache:
1349 return self.statusCache[name] 1353 return self.statusCache[name]
1350 1354
1351 name = os.path.normcase(name) 1355 name = os.path.normcase(name)
1352 states = {name: 0} 1356 states = {name: 0}
1353 states = self.vcsAllRegisteredStates(states, dname, False) 1357 states = self.vcsAllRegisteredStates(states, dname, False)
1354 if states[name] == self.canBeCommitted: 1358 if states[name] == VersionControlState.Controlled:
1355 return self.canBeCommitted 1359 return VersionControlState.Controlled
1356 else: 1360 else:
1357 return self.canBeAdded 1361 return VersionControlState.Uncontrolled
1358 1362
1359 def __vcsRegisteredState_wc(self, name): 1363 def __vcsRegisteredState_wc(self, name):
1360 """ 1364 """
1361 Private method used to get the registered state of a file in the VCS. 1365 Private method used to get the registered state of a file in the VCS.
1362 1366
1363 This is the variant for subversion installations using the old working 1367 This is the variant for subversion installations using the old working
1364 copy meta-data format. 1368 copy meta-data format.
1365 1369
1366 @param name filename to check 1370 @param name filename to check
1367 @type str 1371 @type str
1368 @return registered state (one of canBeCommited and canBeAdded) 1372 @return registered state
1369 @rtype int 1373 @rtype VersionControlState
1370 """ 1374 """
1371 dname, fname = self.splitPath(name) 1375 dname, fname = self.splitPath(name)
1372 1376
1373 if fname == ".": 1377 if fname == ".":
1374 if os.path.isdir(os.path.join(dname, self.adminDir)): 1378 if os.path.isdir(os.path.join(dname, self.adminDir)):
1375 return self.canBeCommitted 1379 return VersionControlState.Controlled
1376 else: 1380 else:
1377 return self.canBeAdded 1381 return VersionControlState.Uncontrolled
1378 1382
1379 name = os.path.normcase(name) 1383 name = os.path.normcase(name)
1380 states = {name: 0} 1384 states = {name: 0}
1381 states = self.vcsAllRegisteredStates(states, dname, False) 1385 states = self.vcsAllRegisteredStates(states, dname, False)
1382 if states[name] == self.canBeCommitted: 1386 if states[name] == VersionControlState.Controlled:
1383 return self.canBeCommitted 1387 return VersionControlState.Controlled
1384 else: 1388 else:
1385 return self.canBeAdded 1389 return VersionControlState.Uncontrolled
1386 1390
1387 def vcsAllRegisteredStates(self, names, dname, shortcut=True): 1391 def vcsAllRegisteredStates(self, names, dname, shortcut=True):
1388 """ 1392 """
1389 Public method used to get the registered states of a number of files 1393 Public method used to get the registered states of a number of files
1390 in the VCS. 1394 in the VCS.
1397 @type dict 1401 @type dict
1398 @param dname directory to check in 1402 @param dname directory to check in
1399 @type str 1403 @type str
1400 @param shortcut flag indicating a shortcut should be taken 1404 @param shortcut flag indicating a shortcut should be taken
1401 @type bool 1405 @type bool
1402 @return the received dictionary completed with a combination of 1406 @return the received dictionary completed with the VCS state or None in
1403 canBeCommited and canBeAdded or None in order to signal an error 1407 order to signal an error
1404 @rtype dict 1408 @rtype dict
1405 """ 1409 """
1406 if self.__wcng: 1410 if self.__wcng:
1407 return self.__vcsAllRegisteredStates_wcng(names, dname) 1411 return self.__vcsAllRegisteredStates_wcng(names, dname)
1408 else: 1412 else:
1422 1426
1423 @param names dictionary with all filenames to be checked as keys 1427 @param names dictionary with all filenames to be checked as keys
1424 @type dict 1428 @type dict
1425 @param dname directory to check in 1429 @param dname directory to check in
1426 @type str 1430 @type str
1427 @return the received dictionary completed with a combination of 1431 @return the received dictionary completed with the VCS state or None in
1428 canBeCommited and canBeAdded or None in order to signal an error 1432 order to signal an error
1429 @rtype dict 1433 @rtype dict
1430 """ 1434 """
1431 if dname.endswith(os.sep): 1435 if dname.endswith(os.sep):
1432 dname = dname[:-1] 1436 dname = dname[:-1]
1433 dname = os.path.normcase(dname) 1437 dname = os.path.normcase(dname)
1472 else: 1476 else:
1473 continue 1477 continue
1474 name = os.path.normcase(path) 1478 name = os.path.normcase(path)
1475 if flags[0] not in "?I": 1479 if flags[0] not in "?I":
1476 if name in names: 1480 if name in names:
1477 names[name] = self.canBeCommitted 1481 names[name] = VersionControlState.Controlled
1478 self.statusCache[name] = self.canBeCommitted 1482 self.statusCache[name] = VersionControlState.Controlled
1479 else: 1483 else:
1480 self.statusCache[name] = self.canBeAdded 1484 self.statusCache[name] = VersionControlState.Uncontrolled
1481 1485
1482 return names 1486 return names
1483 1487
1484 def __vcsAllRegisteredStates_wc(self, names, dname, shortcut=True): 1488 def __vcsAllRegisteredStates_wc(self, names, dname, shortcut=True):
1485 """ 1489 """
1497 @type dict 1501 @type dict
1498 @param dname directory to check in 1502 @param dname directory to check in
1499 @type str 1503 @type str
1500 @param shortcut flag indicating a shortcut should be taken 1504 @param shortcut flag indicating a shortcut should be taken
1501 @type bool 1505 @type bool
1502 @return the received dictionary completed with a combination of 1506 @return the received dictionary completed with the VCS state or None in
1503 canBeCommited and canBeAdded or None in order to signal an error 1507 order to signal an error
1504 @rtype dict 1508 @rtype dict
1505 """ 1509 """
1506 if not os.path.isdir(os.path.join(dname, self.adminDir)): 1510 if not os.path.isdir(os.path.join(dname, self.adminDir)):
1507 # not under version control -> do nothing 1511 # not under version control -> do nothing
1508 return names 1512 return names
1544 else: 1548 else:
1545 continue 1549 continue
1546 name = os.path.normcase(path) 1550 name = os.path.normcase(path)
1547 if flags[0] not in "?I": 1551 if flags[0] not in "?I":
1548 if name in names: 1552 if name in names:
1549 names[name] = self.canBeCommitted 1553 names[name] = VersionControlState.Controlled
1550 self.statusCache[name] = self.canBeCommitted 1554 self.statusCache[name] = VersionControlState.Controlled
1551 else: 1555 else:
1552 self.statusCache[name] = self.canBeAdded 1556 self.statusCache[name] = VersionControlState.Uncontrolled
1553 1557
1554 return names 1558 return names
1555 1559
1556 def clearStatusCache(self): 1560 def clearStatusCache(self):
1557 """ 1561 """

eric ide

mercurial