src/eric7/Plugins/VcsPlugins/vcsMercurial/hg.py

branch
eric7
changeset 10491
acabc60b19a2
parent 10490
527d47826e97
child 10517
aecd5a8c958c
equal deleted inserted replaced
10490:527d47826e97 10491:acabc60b19a2
19 from eric7.EricWidgets import EricFileDialog, EricMessageBox 19 from eric7.EricWidgets import EricFileDialog, EricMessageBox
20 from eric7.EricWidgets.EricApplication import ericApp 20 from eric7.EricWidgets.EricApplication import ericApp
21 from eric7.QScintilla.MiniEditor import MiniEditor 21 from eric7.QScintilla.MiniEditor import MiniEditor
22 from eric7.SystemUtilities import FileSystemUtilities 22 from eric7.SystemUtilities import FileSystemUtilities
23 from eric7.VCS.RepositoryInfoDialog import VcsRepositoryInfoDialog 23 from eric7.VCS.RepositoryInfoDialog import VcsRepositoryInfoDialog
24 from eric7.VCS.VersionControl import VersionControl 24 from eric7.VCS.VersionControl import VersionControl, VersionControlState
25 25
26 from .HgClient import HgClient 26 from .HgClient import HgClient
27 from .HgDialog import HgDialog 27 from .HgDialog import HgDialog
28 28
29 29
1096 """ 1096 """
1097 Public method used to get the registered state of a file in the vcs. 1097 Public method used to get the registered state of a file in the vcs.
1098 1098
1099 @param name file or directory name to check 1099 @param name file or directory name to check
1100 @type str 1100 @type str
1101 @return registered state (one of canBeCommited and canBeAdded) 1101 @return registered state
1102 @rtype int 1102 @rtype VersionControlState
1103 """ 1103 """
1104 if name.endswith(os.sep): 1104 if name.endswith(os.sep):
1105 name = name[:-1] 1105 name = name[:-1]
1106 name = os.path.normcase(name) 1106 name = os.path.normcase(name)
1107 1107
1108 if os.path.isdir(name) and os.path.isdir(os.path.join(name, self.adminDir)): 1108 if os.path.isdir(name) and os.path.isdir(os.path.join(name, self.adminDir)):
1109 return self.canBeCommitted 1109 return VersionControlState.Controlled
1110 1110
1111 if name in self.statusCache: 1111 if name in self.statusCache:
1112 return self.statusCache[name] 1112 return self.statusCache[name]
1113 args = self.initCommand("status") 1113 args = self.initCommand("status")
1114 args.append("--all") 1114 args.append("--all")
1123 flag, path = line.split(" ", 1) 1123 flag, path = line.split(" ", 1)
1124 absname = FileSystemUtilities.normcasepath( 1124 absname = FileSystemUtilities.normcasepath(
1125 os.path.join(repodir, path) 1125 os.path.join(repodir, path)
1126 ) 1126 )
1127 if flag not in "?I" and absname == name: 1127 if flag not in "?I" and absname == name:
1128 return self.canBeCommitted 1128 return VersionControlState.Controlled
1129 1129
1130 return self.canBeAdded 1130 return VersionControlState.Uncontrolled
1131 1131
1132 def vcsAllRegisteredStates(self, names, dname, shortcut=True): # noqa: U100 1132 def vcsAllRegisteredStates(self, names, dname, shortcut=True): # noqa: U100
1133 """ 1133 """
1134 Public method used to get the registered states of a number of files 1134 Public method used to get the registered states of a number of files
1135 in the vcs. 1135 in the vcs.
1142 @type dict 1142 @type dict
1143 @param dname directory to check in 1143 @param dname directory to check in
1144 @type str 1144 @type str
1145 @param shortcut flag indicating a shortcut should be taken 1145 @param shortcut flag indicating a shortcut should be taken
1146 @type bool 1146 @type bool
1147 @return the received dictionary completed with a combination of 1147 @return the received dictionary completed with the VCS state or None in
1148 canBeCommited and canBeAdded or None in order to signal an error 1148 order to signal an error
1149 @rtype dict 1149 @rtype dict
1150 """ 1150 """
1151 if dname.endswith(os.sep): 1151 if dname.endswith(os.sep):
1152 dname = dname[:-1] 1152 dname = dname[:-1]
1153 dname = os.path.normcase(dname) 1153 dname = os.path.normcase(dname)
1173 flag, path = line.split(" ", 1) 1173 flag, path = line.split(" ", 1)
1174 name = os.path.normcase(os.path.join(repoPath, path)) 1174 name = os.path.normcase(os.path.join(repoPath, path))
1175 dirName = os.path.dirname(name) 1175 dirName = os.path.dirname(name)
1176 if name.startswith(dname) and flag not in "?I": 1176 if name.startswith(dname) and flag not in "?I":
1177 if name in names: 1177 if name in names:
1178 names[name] = self.canBeCommitted 1178 names[name] = VersionControlState.Controlled
1179 if dirName in names: 1179 if dirName in names:
1180 names[dirName] = self.canBeCommitted 1180 names[dirName] = VersionControlState.Controlled
1181 if dirs: 1181 if dirs:
1182 for d in dirs: 1182 for d in dirs:
1183 if name.startswith(d): 1183 if name.startswith(d):
1184 names[d] = self.canBeCommitted 1184 names[d] = VersionControlState.Controlled
1185 dirs.remove(d) 1185 dirs.remove(d)
1186 break 1186 break
1187 if flag not in "?I": 1187 if flag not in "?I":
1188 self.statusCache[name] = self.canBeCommitted 1188 self.statusCache[name] = VersionControlState.Controlled
1189 self.statusCache[dirName] = self.canBeCommitted 1189 self.statusCache[dirName] = VersionControlState.Controlled
1190 else: 1190 else:
1191 self.statusCache[name] = self.canBeAdded 1191 self.statusCache[name] = VersionControlState.Uncontrolled
1192 if dirName not in self.statusCache: 1192 if dirName not in self.statusCache:
1193 self.statusCache[dirName] = self.canBeAdded 1193 self.statusCache[
1194 dirName
1195 ] = VersionControlState.Uncontrolled
1194 1196
1195 return names 1197 return names
1196 1198
1197 def clearStatusCache(self): 1199 def clearStatusCache(self):
1198 """ 1200 """

eric ide

mercurial