Rev 2327: Add the most recent time stamp into path_info output, for cache usability checking. in file:///home/robertc/source/baz/dirstate2/
Robert Collins
robertc at robertcollins.net
Fri Mar 9 14:30:37 GMT 2007
At file:///home/robertc/source/baz/dirstate2/
------------------------------------------------------------
revno: 2327
revision-id: robertc at robertcollins.net-20070309143019-8y1a649z5hzryiuh
parent: robertc at robertcollins.net-20070309061608-pau0d6iy2rss65lg
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate2
timestamp: Sat 2007-03-10 01:30:19 +1100
message:
Add the most recent time stamp into path_info output, for cache usability checking.
modified:
bzrlib/path_info_python.py path_info_python.py-20070309041626-f8val8ukxzzzyudi-2
bzrlib/tests/path_info_implementations/test_path_info.py test_path_info.py-20070309041626-f8val8ukxzzzyudi-5
=== modified file 'bzrlib/path_info_python.py'
--- a/bzrlib/path_info_python.py 2007-03-09 06:16:08 +0000
+++ b/bzrlib/path_info_python.py 2007-03-09 14:30:19 +0000
@@ -32,6 +32,7 @@
# into bzrlib.
file_kind_from_stat_mode = sys.modules['bzrlib.path_info'].file_kind_from_stat_mode
kind_missing = sys.modules['bzrlib.path_info'].kind_missing
+kind_file = sys.modules['bzrlib.path_info'].kind_file
def pack_stat(st, _encode=base64.encodestring, _pack=struct.pack):
@@ -49,9 +50,10 @@
def path_info(abspath, _lstat=os.lstat, _mapper=file_kind_from_stat_mode,
- _S_IEXEC=stat.S_IEXEC, _ENOENT=errno.ENOENT, _kind_missing=kind_missing):
+ _S_IEXEC=stat.S_IEXEC, _ENOENT=errno.ENOENT, _kind_missing=kind_missing,
+ _kind_file=kind_file):
"""Get the kind, size, executability and statcache key for abspath."""
- assert abspath.__class__ == str
+ assert abspath.__class__ == str, '%r is not a basic string' % (abspath, )
try:
st = _lstat(abspath)
except OSError, e:
@@ -60,6 +62,16 @@
else:
# TODO: could make this a constant to return, if we expect it to be
# common.
- return (_kind_missing, 0, False, '')
- return (_mapper(st.st_mode), st.st_size, bool(_S_IEXEC & st.st_mode),
- pack_stat(st))
+ return (_kind_missing, 0, False, 0, '')
+ kind = _mapper(st.st_mode)
+ if kind is _kind_file:
+ size = st.st_size
+ executable = bool(_S_IEXEC & st.st_mode)
+ else:
+ size = 0
+ executable = False
+ if st.st_mtime < st.st_ctime:
+ recenttime = st.st_ctime
+ else:
+ recenttime = st.st_mtime
+ return (_mapper(st.st_mode), size, executable, recenttime, pack_stat(st))
=== modified file 'bzrlib/tests/path_info_implementations/test_path_info.py'
--- a/bzrlib/tests/path_info_implementations/test_path_info.py 2007-03-09 06:16:08 +0000
+++ b/bzrlib/tests/path_info_implementations/test_path_info.py 2007-03-09 14:30:19 +0000
@@ -33,7 +33,11 @@
self.build_tree(['file'])
result = self.path_info.path_info(os.path.abspath('file'))
stat = os.lstat('file')
- expected = ('file', stat.st_size, False, pack_stat(stat))
+ if stat.st_mtime < stat.st_ctime:
+ recenttime = stat.st_ctime
+ else:
+ recenttime = stat.st_mtime
+ expected = ('file', stat.st_size, False, recenttime, pack_stat(stat))
self.assertEqual(expected, result)
self.assertIs(kind_file, result[0])
@@ -47,8 +51,12 @@
# make the file executable for this user
os.chmod('file', st.st_mode | stat.S_IXUSR)
st = os.lstat('file')
+ if st.st_mtime < st.st_ctime:
+ recenttime = st.st_ctime
+ else:
+ recenttime = st.st_mtime
result = self.path_info.path_info(os.path.abspath('file'))
- expected = ('file', st.st_size, True, pack_stat(st))
+ expected = ('file', st.st_size, True, recenttime, pack_stat(st))
self.assertEqual(expected, result)
self.assertIs(kind_file, result[0])
@@ -68,8 +76,12 @@
encoding = sys.getfilesystemencoding()
encoded_name = u'\xe8file'.encode(encoding)
result = self.path_info.path_info(os.path.abspath(encoded_name))
- stat = os.lstat(encoded_name)
- expected = ('file', stat.st_size, False, pack_stat(stat))
+ st = os.lstat(encoded_name)
+ if st.st_mtime < st.st_ctime:
+ recenttime = st.st_ctime
+ else:
+ recenttime = st.st_mtime
+ expected = ('file', st.st_size, False, recenttime, pack_stat(st))
self.assertEqual(expected, result)
self.assertIs(kind_file, result[0])
@@ -77,6 +89,6 @@
# path_info should return a canned 'missing' kind for paths that are not
# present on disk.
result = self.path_info.path_info(os.path.abspath('missing-file'))
- expected = ('missing', 0, False, '')
+ expected = ('missing', 0, False, 0, '')
self.assertEqual(expected, result)
self.assertIs(kind_missing, result[0])
More information about the bazaar-commits
mailing list