comparison mercurial/dirstate.py @ 35835:bf367a93f000

dirstate: use native strings when peeking in __dict__ # skip-blame because we're just adding a prefix on a string prefix Differential Revision: https://phab.mercurial-scm.org/D1894
author Augie Fackler <augie@google.com>
date Wed, 17 Jan 2018 21:44:15 -0500
parents 8db4ca768416
children 6e7fae8f1c6c
comparison
equal deleted inserted replaced
35834:f61461d2bfd8 35835:bf367a93f000
358 358
359 This is different from localrepo.invalidatedirstate() because it always 359 This is different from localrepo.invalidatedirstate() because it always
360 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to 360 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
361 check whether the dirstate has changed before rereading it.''' 361 check whether the dirstate has changed before rereading it.'''
362 362
363 for a in ("_map", "_branch", "_ignore"): 363 for a in (r"_map", r"_branch", r"_ignore"):
364 if a in self.__dict__: 364 if a in self.__dict__:
365 delattr(self, a) 365 delattr(self, a)
366 self._lastnormaltime = 0 366 self._lastnormaltime = 0
367 self._dirty = False 367 self._dirty = False
368 self._updatedfiles.clear() 368 self._updatedfiles.clear()
1262 """Loads the underlying data, if it's not already loaded""" 1262 """Loads the underlying data, if it's not already loaded"""
1263 self._map 1263 self._map
1264 1264
1265 def addfile(self, f, oldstate, state, mode, size, mtime): 1265 def addfile(self, f, oldstate, state, mode, size, mtime):
1266 """Add a tracked file to the dirstate.""" 1266 """Add a tracked file to the dirstate."""
1267 if oldstate in "?r" and "_dirs" in self.__dict__: 1267 if oldstate in "?r" and r"_dirs" in self.__dict__:
1268 self._dirs.addpath(f) 1268 self._dirs.addpath(f)
1269 if oldstate == "?" and "_alldirs" in self.__dict__: 1269 if oldstate == "?" and r"_alldirs" in self.__dict__:
1270 self._alldirs.addpath(f) 1270 self._alldirs.addpath(f)
1271 self._map[f] = dirstatetuple(state, mode, size, mtime) 1271 self._map[f] = dirstatetuple(state, mode, size, mtime)
1272 if state != 'n' or mtime == -1: 1272 if state != 'n' or mtime == -1:
1273 self.nonnormalset.add(f) 1273 self.nonnormalset.add(f)
1274 if size == -2: 1274 if size == -2:
1280 1280
1281 The `size` parameter is used to store sentinel values that indicate 1281 The `size` parameter is used to store sentinel values that indicate
1282 the file's previous state. In the future, we should refactor this 1282 the file's previous state. In the future, we should refactor this
1283 to be more explicit about what that state is. 1283 to be more explicit about what that state is.
1284 """ 1284 """
1285 if oldstate not in "?r" and "_dirs" in self.__dict__: 1285 if oldstate not in "?r" and r"_dirs" in self.__dict__:
1286 self._dirs.delpath(f) 1286 self._dirs.delpath(f)
1287 if oldstate == "?" and "_alldirs" in self.__dict__: 1287 if oldstate == "?" and r"_alldirs" in self.__dict__:
1288 self._alldirs.addpath(f) 1288 self._alldirs.addpath(f)
1289 if "filefoldmap" in self.__dict__: 1289 if r"filefoldmap" in self.__dict__:
1290 normed = util.normcase(f) 1290 normed = util.normcase(f)
1291 self.filefoldmap.pop(normed, None) 1291 self.filefoldmap.pop(normed, None)
1292 self._map[f] = dirstatetuple('r', 0, size, 0) 1292 self._map[f] = dirstatetuple('r', 0, size, 0)
1293 self.nonnormalset.add(f) 1293 self.nonnormalset.add(f)
1294 1294
1297 Remove a file from the dirstate. Returns True if the file was 1297 Remove a file from the dirstate. Returns True if the file was
1298 previously recorded. 1298 previously recorded.
1299 """ 1299 """
1300 exists = self._map.pop(f, None) is not None 1300 exists = self._map.pop(f, None) is not None
1301 if exists: 1301 if exists:
1302 if oldstate != "r" and "_dirs" in self.__dict__: 1302 if oldstate != "r" and r"_dirs" in self.__dict__:
1303 self._dirs.delpath(f) 1303 self._dirs.delpath(f)
1304 if "_alldirs" in self.__dict__: 1304 if r"_alldirs" in self.__dict__:
1305 self._alldirs.delpath(f) 1305 self._alldirs.delpath(f)
1306 if "filefoldmap" in self.__dict__: 1306 if r"filefoldmap" in self.__dict__:
1307 normed = util.normcase(f) 1307 normed = util.normcase(f)
1308 self.filefoldmap.pop(normed, None) 1308 self.filefoldmap.pop(normed, None)
1309 self.nonnormalset.discard(f) 1309 self.nonnormalset.discard(f)
1310 return exists 1310 return exists
1311 1311