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

branch
eric7
changeset 10491
acabc60b19a2
parent 10439
21c28b0f9e41
child 10517
aecd5a8c958c
equal deleted inserted replaced
10490:527d47826e97 10491:acabc60b19a2
23 from eric7 import Preferences, Utilities 23 from eric7 import Preferences, Utilities
24 from eric7.EricUtilities.EricMutexLocker import EricMutexLocker 24 from eric7.EricUtilities.EricMutexLocker import EricMutexLocker
25 from eric7.EricWidgets import EricMessageBox 25 from eric7.EricWidgets import EricMessageBox
26 from eric7.EricWidgets.EricApplication import ericApp 26 from eric7.EricWidgets.EricApplication import ericApp
27 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog 27 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog
28 from eric7.VCS.VersionControl import VersionControl 28 from eric7.VCS.VersionControl import VersionControl, VersionControlState
29 29
30 from .SvnDialog import SvnDialog 30 from .SvnDialog import SvnDialog
31 from .SvnUtilities import amendConfig, createDefaultConfig, getConfigPath 31 from .SvnUtilities import amendConfig, createDefaultConfig, getConfigPath
32 32
33 33
752 repodir = os.path.dirname(repodir) 752 repodir = os.path.dirname(repodir)
753 if os.path.splitdrive(repodir)[1] == os.sep: 753 if os.path.splitdrive(repodir)[1] == os.sep:
754 return # oops, project is not version controlled 754 return # oops, project is not version controlled
755 while os.path.normcase(dname) != os.path.normcase(repodir) and ( 755 while os.path.normcase(dname) != os.path.normcase(repodir) and (
756 os.path.normcase(dname) not in self.statusCache 756 os.path.normcase(dname) not in self.statusCache
757 or self.statusCache[os.path.normcase(dname)] == self.canBeAdded 757 or self.statusCache[os.path.normcase(dname)]
758 == VersionControlState.Uncontrolled
758 ): 759 ):
759 # add directories recursively, if they aren't in the 760 # add directories recursively, if they aren't in the
760 # repository already 761 # repository already
761 tree.insert(-1, dname) 762 tree.insert(-1, dname)
762 dname = os.path.dirname(dname) 763 dname = os.path.dirname(dname)
783 while ( 784 while (
784 (os.path.normcase(d) != os.path.normcase(repodir)) 785 (os.path.normcase(d) != os.path.normcase(repodir))
785 and (d not in tree2 + tree) 786 and (d not in tree2 + tree)
786 and ( 787 and (
787 os.path.normcase(d) not in self.statusCache 788 os.path.normcase(d) not in self.statusCache
788 or self.statusCache[os.path.normcase(d)] == self.canBeAdded 789 or self.statusCache[os.path.normcase(d)]
790 == VersionControlState.Uncontrolled
789 ) 791 )
790 ): 792 ):
791 tree2.append(d) 793 tree2.append(d)
792 d = os.path.dirname(d) 794 d = os.path.dirname(d)
793 else: 795 else:
865 while ( 867 while (
866 (os.path.normcase(d) != os.path.normcase(repodir)) 868 (os.path.normcase(d) != os.path.normcase(repodir))
867 and (d not in tree) 869 and (d not in tree)
868 and ( 870 and (
869 os.path.normcase(d) not in self.statusCache 871 os.path.normcase(d) not in self.statusCache
870 or self.statusCache[os.path.normcase(d)] == self.canBeAdded 872 or self.statusCache[os.path.normcase(d)]
873 == VersionControlState.Uncontrolled
871 ) 874 )
872 ): 875 ):
873 tree.append(d) 876 tree.append(d)
874 d = os.path.dirname(d) 877 d = os.path.dirname(d)
875 else: 878 else:
889 repodir = os.path.dirname(repodir) 892 repodir = os.path.dirname(repodir)
890 if os.path.splitdrive(repodir)[1] == os.sep: 893 if os.path.splitdrive(repodir)[1] == os.sep:
891 return # oops, project is not version controlled 894 return # oops, project is not version controlled
892 while (os.path.normcase(dname) != os.path.normcase(repodir)) and ( 895 while (os.path.normcase(dname) != os.path.normcase(repodir)) and (
893 os.path.normcase(dname) not in self.statusCache 896 os.path.normcase(dname) not in self.statusCache
894 or self.statusCache[os.path.normcase(dname)] == self.canBeAdded 897 or self.statusCache[os.path.normcase(dname)]
898 == VersionControlState.Uncontrolled
895 ): 899 ):
896 # add directories recursively, if they aren't in the 900 # add directories recursively, if they aren't in the
897 # repository already 901 # repository already
898 tree.insert(-1, dname) 902 tree.insert(-1, dname)
899 dname = os.path.dirname(dname) 903 dname = os.path.dirname(dname)
1481 """ 1485 """
1482 Public method used to get the registered state of a file in the vcs. 1486 Public method used to get the registered state of a file in the vcs.
1483 1487
1484 @param name filename to check 1488 @param name filename to check
1485 @type str 1489 @type str
1486 @return registered state (one of canBeCommited and canBeAdded) 1490 @return registered state
1487 @rtype int 1491 @rtype VersionControlState
1488 """ 1492 """
1489 if self.__wcng: 1493 if self.__wcng:
1490 return self.__vcsRegisteredState_wcng(name) 1494 return self.__vcsRegisteredState_wcng(name)
1491 else: 1495 else:
1492 return self.__vcsRegisteredState_wc(name) 1496 return self.__vcsRegisteredState_wc(name)
1498 This is the variant for subversion installations using the new 1502 This is the variant for subversion installations using the new
1499 working copy meta-data format. 1503 working copy meta-data format.
1500 1504
1501 @param name filename to check 1505 @param name filename to check
1502 @type str 1506 @type str
1503 @return registered state (one of canBeCommited and canBeAdded) 1507 @return registered state
1504 @rtype int 1508 @rtype VersionControlState
1505 """ 1509 """
1506 if name.endswith(os.sep): 1510 if name.endswith(os.sep):
1507 name = name[:-1] 1511 name = name[:-1]
1508 name = os.path.normcase(name) 1512 name = os.path.normcase(name)
1509 dname, fname = self.splitPath(name) 1513 dname, fname = self.splitPath(name)
1510 1514
1511 if fname == "." and os.path.isdir(os.path.join(dname, self.adminDir)): 1515 if fname == "." and os.path.isdir(os.path.join(dname, self.adminDir)):
1512 return self.canBeCommitted 1516 return VersionControlState.Controlled
1513 1517
1514 if name in self.statusCache: 1518 if name in self.statusCache:
1515 return self.statusCache[name] 1519 return self.statusCache[name]
1516 1520
1517 name = os.path.normcase(name) 1521 name = os.path.normcase(name)
1518 states = {name: 0} 1522 states = {name: 0}
1519 states = self.vcsAllRegisteredStates(states, dname, False) 1523 states = self.vcsAllRegisteredStates(states, dname, False)
1520 if states[name] == self.canBeCommitted: 1524 if states[name] == VersionControlState.Controlled:
1521 return self.canBeCommitted 1525 return VersionControlState.Controlled
1522 else: 1526 else:
1523 return self.canBeAdded 1527 return VersionControlState.Uncontrolled
1524 1528
1525 def __vcsRegisteredState_wc(self, name): 1529 def __vcsRegisteredState_wc(self, name):
1526 """ 1530 """
1527 Private method used to get the registered state of a file in the vcs. 1531 Private method used to get the registered state of a file in the vcs.
1528 1532
1529 This is the variant for subversion installations using the old working 1533 This is the variant for subversion installations using the old working
1530 copy meta-data format. 1534 copy meta-data format.
1531 1535
1532 @param name filename to check 1536 @param name filename to check
1533 @type str 1537 @type str
1534 @return registered state (one of canBeCommited and canBeAdded) 1538 @return registered state
1535 @rtype int 1539 @rtype VersionControlState
1536 """ 1540 """
1537 dname, fname = self.splitPath(name) 1541 dname, fname = self.splitPath(name)
1538 1542
1539 if fname == ".": 1543 if fname == ".":
1540 if os.path.isdir(os.path.join(dname, self.adminDir)): 1544 if os.path.isdir(os.path.join(dname, self.adminDir)):
1541 return self.canBeCommitted 1545 return VersionControlState.Controlled
1542 else: 1546 else:
1543 return self.canBeAdded 1547 return VersionControlState.Uncontrolled
1544 1548
1545 name = os.path.normcase(name) 1549 name = os.path.normcase(name)
1546 states = {name: 0} 1550 states = {name: 0}
1547 states = self.vcsAllRegisteredStates(states, dname, False) 1551 states = self.vcsAllRegisteredStates(states, dname, False)
1548 if states[name] == self.canBeCommitted: 1552 if states[name] == VersionControlState.Controlled:
1549 return self.canBeCommitted 1553 return VersionControlState.Controlled
1550 else: 1554 else:
1551 return self.canBeAdded 1555 return VersionControlState.Uncontrolled
1552 1556
1553 def vcsAllRegisteredStates(self, names, dname, shortcut=True): 1557 def vcsAllRegisteredStates(self, names, dname, shortcut=True):
1554 """ 1558 """
1555 Public method used to get the registered states of a number of files 1559 Public method used to get the registered states of a number of files
1556 in the vcs. 1560 in the vcs.
1563 @type dict 1567 @type dict
1564 @param dname directory to check in 1568 @param dname directory to check in
1565 @type str 1569 @type str
1566 @param shortcut flag indicating a shortcut should be taken 1570 @param shortcut flag indicating a shortcut should be taken
1567 @type bool 1571 @type bool
1568 @return the received dictionary completed with a combination of 1572 @return the received dictionary completed with the VCS state or None in
1569 canBeCommited and canBeAdded or None in order to signal an error 1573 order to signal an error
1570 @rtype dict 1574 @rtype dict
1571 """ 1575 """
1572 if self.__wcng: 1576 if self.__wcng:
1573 return self.__vcsAllRegisteredStates_wcng(names, dname, shortcut) 1577 return self.__vcsAllRegisteredStates_wcng(names, dname, shortcut)
1574 else: 1578 else:
1590 @type dict 1594 @type dict
1591 @param dname directory to check in 1595 @param dname directory to check in
1592 @type str 1596 @type str
1593 @param shortcut flag indicating a shortcut should be taken 1597 @param shortcut flag indicating a shortcut should be taken
1594 @type bool 1598 @type bool
1595 @return the received dictionary completed with a combination of 1599 @return the received dictionary completed with the VCS state or None in
1596 canBeCommited and canBeAdded or None in order to signal an error 1600 order to signal an error
1597 @rtype dict 1601 @rtype dict
1598 """ 1602 """
1599 from .SvnDialogMixin import SvnDialogMixin 1603 from .SvnDialogMixin import SvnDialogMixin
1600 1604
1601 if dname.endswith(os.sep): 1605 if dname.endswith(os.sep):
1631 dirs = [x for x in names if os.path.isdir(x)] 1635 dirs = [x for x in names if os.path.isdir(x)]
1632 for file in allFiles: 1636 for file in allFiles:
1633 name = os.path.normcase(file.path) 1637 name = os.path.normcase(file.path)
1634 if self.__isVersioned(file): 1638 if self.__isVersioned(file):
1635 if name in names: 1639 if name in names:
1636 names[name] = self.canBeCommitted 1640 names[name] = VersionControlState.Controlled
1637 dn = name 1641 dn = name
1638 while os.path.splitdrive(dn)[1] != os.sep and dn != repodir: 1642 while os.path.splitdrive(dn)[1] != os.sep and dn != repodir:
1639 dn = os.path.dirname(dn) 1643 dn = os.path.dirname(dn)
1640 if ( 1644 if (
1641 dn in self.statusCache 1645 dn in self.statusCache
1642 and self.statusCache[dn] == self.canBeCommitted 1646 and self.statusCache[dn]
1647 == VersionControlState.Controlled
1643 ): 1648 ):
1644 break 1649 break
1645 self.statusCache[dn] = self.canBeCommitted 1650 self.statusCache[dn] = VersionControlState.Controlled
1646 self.statusCache[name] = self.canBeCommitted 1651 self.statusCache[name] = VersionControlState.Controlled
1647 if dirs: 1652 if dirs:
1648 for d in dirs: 1653 for d in dirs:
1649 if name.startswith(d): 1654 if name.startswith(d):
1650 names[d] = self.canBeCommitted 1655 names[d] = VersionControlState.Controlled
1651 self.statusCache[d] = self.canBeCommitted 1656 self.statusCache[d] = VersionControlState.Controlled
1652 dirs.remove(d) 1657 dirs.remove(d)
1653 break 1658 break
1654 else: 1659 else:
1655 self.statusCache[name] = self.canBeAdded 1660 self.statusCache[name] = VersionControlState.Uncontrolled
1656 1661
1657 return names 1662 return names
1658 1663
1659 def __vcsAllRegisteredStates_wc(self, names, dname, shortcut=True): 1664 def __vcsAllRegisteredStates_wc(self, names, dname, shortcut=True):
1660 """ 1665 """
1672 @type dict 1677 @type dict
1673 @param dname directory to check in 1678 @param dname directory to check in
1674 @type str 1679 @type str
1675 @param shortcut flag indicating a shortcut should be taken 1680 @param shortcut flag indicating a shortcut should be taken
1676 @type bool 1681 @type bool
1677 @return the received dictionary completed with a combination of 1682 @return the received dictionary completed with the VCS state or None in
1678 canBeCommited and canBeAdded or None in order to signal an error 1683 order to signal an error
1679 @rtype dict 1684 @rtype dict
1680 """ 1685 """
1681 from .SvnDialogMixin import SvnDialogMixin 1686 from .SvnDialogMixin import SvnDialogMixin
1682 1687
1683 if not os.path.isdir(os.path.join(dname, self.adminDir)): 1688 if not os.path.isdir(os.path.join(dname, self.adminDir)):
1709 ) 1714 )
1710 for file in allFiles: 1715 for file in allFiles:
1711 name = os.path.normcase(file.path) 1716 name = os.path.normcase(file.path)
1712 if self.__isVersioned(file): 1717 if self.__isVersioned(file):
1713 if name in names: 1718 if name in names:
1714 names[name] = self.canBeCommitted 1719 names[name] = VersionControlState.Controlled
1715 self.statusCache[name] = self.canBeCommitted 1720 self.statusCache[name] = VersionControlState.Controlled
1716 else: 1721 else:
1717 self.statusCache[name] = self.canBeAdded 1722 self.statusCache[name] = VersionControlState.Uncontrolled
1718 1723
1719 return names 1724 return names
1720 1725
1721 def __isVersioned(self, status): 1726 def __isVersioned(self, status):
1722 """ 1727 """

eric ide

mercurial