comparison mercurial/dirstate.py @ 44078:f2c350e7371e

dirstate: move rust fast-path calling code to its own method This logic is about to get bigger, this will make it easier to read and not pollute the main Python logic. Differential Revision: https://phab.mercurial-scm.org/D7862
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 14 Jan 2020 16:00:57 +0100
parents 40fd1ef4e4c1
children 7f5410dfc8a6
comparison
equal deleted inserted replaced
44077:05881d002cb2 44078:f2c350e7371e
1081 iv = iter(visit) 1081 iv = iter(visit)
1082 for st in util.statfiles([join(i) for i in visit]): 1082 for st in util.statfiles([join(i) for i in visit]):
1083 results[next(iv)] = st 1083 results[next(iv)] = st
1084 return results 1084 return results
1085 1085
1086 def _rust_status(self, matcher, list_clean):
1087 # Force Rayon (Rust parallelism library) to respect the number of
1088 # workers. This is a temporary workaround until Rust code knows
1089 # how to read the config file.
1090 numcpus = self._ui.configint(b"worker", b"numcpus")
1091 if numcpus is not None:
1092 encoding.environ.setdefault(b'RAYON_NUM_THREADS', b'%d' % numcpus)
1093
1094 workers_enabled = self._ui.configbool(b"worker", b"enabled", True)
1095 if not workers_enabled:
1096 encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
1097
1098 (
1099 lookup,
1100 modified,
1101 added,
1102 removed,
1103 deleted,
1104 unknown,
1105 clean,
1106 ) = rustmod.status(
1107 self._map._rustmap,
1108 matcher,
1109 self._rootdir,
1110 bool(list_clean),
1111 self._lastnormaltime,
1112 self._checkexec,
1113 )
1114
1115 status = scmutil.status(
1116 modified=modified,
1117 added=added,
1118 removed=removed,
1119 deleted=deleted,
1120 unknown=unknown,
1121 ignored=[],
1122 clean=clean,
1123 )
1124 return (lookup, status)
1125
1086 def status(self, match, subrepos, ignored, clean, unknown): 1126 def status(self, match, subrepos, ignored, clean, unknown):
1087 '''Determine the status of the working copy relative to the 1127 '''Determine the status of the working copy relative to the
1088 dirstate and return a pair of (unsure, status), where status is of type 1128 dirstate and return a pair of (unsure, status), where status is of type
1089 scmutil.status and: 1129 scmutil.status and:
1090 1130
1125 elif not isinstance(match, allowed_matchers): 1165 elif not isinstance(match, allowed_matchers):
1126 # Matchers have yet to be implemented 1166 # Matchers have yet to be implemented
1127 use_rust = False 1167 use_rust = False
1128 1168
1129 if use_rust: 1169 if use_rust:
1130 # Force Rayon (Rust parallelism library) to respect the number of 1170 return self._rust_status(match, listclean)
1131 # workers. This is a temporary workaround until Rust code knows
1132 # how to read the config file.
1133 numcpus = self._ui.configint(b"worker", b"numcpus")
1134 if numcpus is not None:
1135 encoding.environ.setdefault(
1136 b'RAYON_NUM_THREADS', b'%d' % numcpus
1137 )
1138
1139 workers_enabled = self._ui.configbool(b"worker", b"enabled", True)
1140 if not workers_enabled:
1141 encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
1142
1143 (
1144 lookup,
1145 modified,
1146 added,
1147 removed,
1148 deleted,
1149 unknown,
1150 clean,
1151 ) = rustmod.status(
1152 dmap._rustmap,
1153 match,
1154 self._rootdir,
1155 bool(listclean),
1156 self._lastnormaltime,
1157 self._checkexec,
1158 )
1159
1160 status = scmutil.status(
1161 modified=modified,
1162 added=added,
1163 removed=removed,
1164 deleted=deleted,
1165 unknown=unknown,
1166 ignored=ignored,
1167 clean=clean,
1168 )
1169 return (lookup, status)
1170 1171
1171 def noop(f): 1172 def noop(f):
1172 pass 1173 pass
1173 1174
1174 dcontains = dmap.__contains__ 1175 dcontains = dmap.__contains__