Mercurial > public > mercurial-scm > hg
comparison mercurial/posix.py @ 18442:ecba9b0e7672
posix: don't compare atime when determining if a file has changed
A file's atime might change even if the file itself doesn't change. This might
cause us to invalidate caches more often than necessary.
Before this change, hg add often resulted in the dirstate being parsed twice
on systems that track atime. After this change, it is only parsed once. For a
repository with over 180,000 files, this speeds up hg add from 1.2 seconds to
1.0.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 18 Jan 2013 15:55:16 -0800 |
parents | 0d5a22f73a1f |
children | a3b2dc1aa909 |
comparison
equal
deleted
inserted
replaced
18441:1f794204abbd | 18442:ecba9b0e7672 |
---|---|
488 | 488 |
489 __hash__ = object.__hash__ | 489 __hash__ = object.__hash__ |
490 | 490 |
491 def __eq__(self, other): | 491 def __eq__(self, other): |
492 try: | 492 try: |
493 return self.stat == other.stat | 493 # Only dev, ino, size, mtime and atime are likely to change. Out |
494 # of these, we shouldn't compare atime but should compare the | |
495 # rest. However, one of the other fields changing indicates | |
496 # something fishy going on, so return False if anything but atime | |
497 # changes. | |
498 return (self.stat.st_mode == other.stat.st_mode and | |
499 self.stat.st_ino == other.stat.st_ino and | |
500 self.stat.st_dev == other.stat.st_dev and | |
501 self.stat.st_nlink == other.stat.st_nlink and | |
502 self.stat.st_uid == other.stat.st_uid and | |
503 self.stat.st_gid == other.stat.st_gid and | |
504 self.stat.st_size == other.stat.st_size and | |
505 self.stat.st_mtime == other.stat.st_mtime and | |
506 self.stat.st_ctime == other.stat.st_ctime) | |
494 except AttributeError: | 507 except AttributeError: |
495 return False | 508 return False |
496 | 509 |
497 def __ne__(self, other): | 510 def __ne__(self, other): |
498 return not self == other | 511 return not self == other |