mercurial/dirstate.py
branchstable
changeset 34935 ffeea2406276
parent 34934 6e66033f91cc
child 34940 c2b30348930f
equal deleted inserted replaced
34934:6e66033f91cc 34935:ffeea2406276
  1051         listignored, listclean, listunknown = ignored, clean, unknown
  1051         listignored, listclean, listunknown = ignored, clean, unknown
  1052         lookup, modified, added, unknown, ignored = [], [], [], [], []
  1052         lookup, modified, added, unknown, ignored = [], [], [], [], []
  1053         removed, deleted, clean = [], [], []
  1053         removed, deleted, clean = [], [], []
  1054 
  1054 
  1055         dmap = self._map
  1055         dmap = self._map
       
  1056         dmap.preload()
       
  1057         dcontains = dmap.__contains__
       
  1058         dget = dmap.__getitem__
  1056         ladd = lookup.append            # aka "unsure"
  1059         ladd = lookup.append            # aka "unsure"
  1057         madd = modified.append
  1060         madd = modified.append
  1058         aadd = added.append
  1061         aadd = added.append
  1059         uadd = unknown.append
  1062         uadd = unknown.append
  1060         iadd = ignored.append
  1063         iadd = ignored.append
  1072         # - match.traversedir does something, because match.traversedir should
  1075         # - match.traversedir does something, because match.traversedir should
  1073         #   be called for every dir in the working dir
  1076         #   be called for every dir in the working dir
  1074         full = listclean or match.traversedir is not None
  1077         full = listclean or match.traversedir is not None
  1075         for fn, st in self.walk(match, subrepos, listunknown, listignored,
  1078         for fn, st in self.walk(match, subrepos, listunknown, listignored,
  1076                                 full=full).iteritems():
  1079                                 full=full).iteritems():
  1077             if fn not in dmap:
  1080             if not dcontains(fn):
  1078                 if (listignored or mexact(fn)) and dirignore(fn):
  1081                 if (listignored or mexact(fn)) and dirignore(fn):
  1079                     if listignored:
  1082                     if listignored:
  1080                         iadd(fn)
  1083                         iadd(fn)
  1081                 else:
  1084                 else:
  1082                     uadd(fn)
  1085                     uadd(fn)
  1087             # Python tuple in compiled builds. The CPython UNPACK_SEQUENCE
  1090             # Python tuple in compiled builds. The CPython UNPACK_SEQUENCE
  1088             # opcode has fast paths when the value to be unpacked is a tuple or
  1091             # opcode has fast paths when the value to be unpacked is a tuple or
  1089             # a list, but falls back to creating a full-fledged iterator in
  1092             # a list, but falls back to creating a full-fledged iterator in
  1090             # general. That is much slower than simply accessing and storing the
  1093             # general. That is much slower than simply accessing and storing the
  1091             # tuple members one by one.
  1094             # tuple members one by one.
  1092             t = dmap[fn]
  1095             t = dget(fn)
  1093             state = t[0]
  1096             state = t[0]
  1094             mode = t[1]
  1097             mode = t[1]
  1095             size = t[2]
  1098             size = t[2]
  1096             time = t[3]
  1099             time = t[3]
  1097 
  1100 
  1214         self.copymap = {}
  1217         self.copymap = {}
  1215         self._map
  1218         self._map
  1216         return self.copymap
  1219         return self.copymap
  1217 
  1220 
  1218     def clear(self):
  1221     def clear(self):
  1219         self._map = {}
  1222         self._map.clear()
  1220         self.copymap = {}
  1223         self.copymap.clear()
  1221         self.setparents(nullid, nullid)
  1224         self.setparents(nullid, nullid)
  1222 
  1225 
  1223     def iteritems(self):
  1226     def iteritems(self):
  1224         return self._map.iteritems()
  1227         return self._map.iteritems()
  1225 
  1228 
  1244     def __delitem__(self, key):
  1247     def __delitem__(self, key):
  1245         del self._map[key]
  1248         del self._map[key]
  1246 
  1249 
  1247     def keys(self):
  1250     def keys(self):
  1248         return self._map.keys()
  1251         return self._map.keys()
       
  1252 
       
  1253     def preload(self):
       
  1254         """Loads the underlying data, if it's not already loaded"""
       
  1255         self._map
  1249 
  1256 
  1250     def nonnormalentries(self):
  1257     def nonnormalentries(self):
  1251         '''Compute the nonnormal dirstate entries from the dmap'''
  1258         '''Compute the nonnormal dirstate entries from the dmap'''
  1252         try:
  1259         try:
  1253             return parsers.nonnormalotherparententries(self._map)
  1260             return parsers.nonnormalotherparententries(self._map)
  1371         parse_dirstate = util.nogc(parsers.parse_dirstate)
  1378         parse_dirstate = util.nogc(parsers.parse_dirstate)
  1372         p = parse_dirstate(self._map, self.copymap, st)
  1379         p = parse_dirstate(self._map, self.copymap, st)
  1373         if not self._dirtyparents:
  1380         if not self._dirtyparents:
  1374             self.setparents(*p)
  1381             self.setparents(*p)
  1375 
  1382 
       
  1383         # Avoid excess attribute lookups by fast pathing certain checks
       
  1384         self.__contains__ = self._map.__contains__
       
  1385         self.__getitem__ = self._map.__getitem__
       
  1386         self.__setitem__ = self._map.__setitem__
       
  1387         self.__delitem__ = self._map.__delitem__
       
  1388         self.get = self._map.get
       
  1389 
  1376     def write(self, st, now):
  1390     def write(self, st, now):
  1377         st.write(parsers.pack_dirstate(self._map, self.copymap,
  1391         st.write(parsers.pack_dirstate(self._map, self.copymap,
  1378                                        self.parents(), now))
  1392                                        self.parents(), now))
  1379         st.close()
  1393         st.close()
  1380         self._dirtyparents = False
  1394         self._dirtyparents = False