1337
1343
state._sha1_provider = UppercaseSHA1Provider()
1338
1344
self.assertChangedFileIds(['file-id'], tree)
1347
class TestPackStat(tests.TestCase):
1348
"""Check packed representaton of stat values is robust on all inputs"""
1350
scenarios = helper_scenarios
1352
def pack(self, statlike_tuple):
1353
return self.helpers.pack_stat(os.stat_result(statlike_tuple))
1356
def unpack_field(packed_string, stat_field):
1357
return _dirstate_helpers_py._unpack_stat(packed_string)[stat_field]
1359
def test_result(self):
1360
self.assertEqual("AAAQAAAAABAAAAARAAAAAgAAAAEAAIHk",
1361
self.pack((33252, 1, 2, 0, 0, 0, 4096, 15.5, 16.5, 17.5)))
1363
def test_giant_inode(self):
1364
packed = self.pack((33252, 0xF80000ABC, 0, 0, 0, 0, 0, 0, 0, 0))
1365
self.assertEqual(0x80000ABC, self.unpack_field(packed, "st_ino"))
1367
def test_giant_size(self):
1368
packed = self.pack((33252, 0, 0, 0, 0, 0, (1 << 33) + 4096, 0, 0, 0))
1369
self.assertEqual(4096, self.unpack_field(packed, "st_size"))
1371
def test_fractional_mtime(self):
1372
packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 16.9375, 0))
1373
self.assertEqual(16, self.unpack_field(packed, "st_mtime"))
1375
def test_ancient_mtime(self):
1376
packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, -11644473600.0, 0))
1377
self.assertEqual(1240428288, self.unpack_field(packed, "st_mtime"))
1379
def test_distant_mtime(self):
1380
packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 64060588800.0, 0))
1381
self.assertEqual(3931046656, self.unpack_field(packed, "st_mtime"))
1383
def test_fractional_ctime(self):
1384
packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 0, 17.5625))
1385
self.assertEqual(17, self.unpack_field(packed, "st_ctime"))
1387
def test_ancient_ctime(self):
1388
packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 0, -11644473600.0))
1389
self.assertEqual(1240428288, self.unpack_field(packed, "st_ctime"))
1391
def test_distant_ctime(self):
1392
packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 0, 64060588800.0))
1393
self.assertEqual(3931046656, self.unpack_field(packed, "st_ctime"))
1395
def test_negative_dev(self):
1396
packed = self.pack((33252, 0, -0xFFFFFCDE, 0, 0, 0, 0, 0, 0, 0))
1397
self.assertEqual(0x322, self.unpack_field(packed, "st_dev"))