* [gentoo-commits] portage r15073 - main/branches/2.1.7/pym/portage
@ 2009-12-13 3:51 Zac Medico (zmedico)
0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-12-13 3:51 UTC (permalink / raw
To: gentoo-commits
Author: zmedico
Date: 2009-12-13 03:51:52 +0000 (Sun, 13 Dec 2009)
New Revision: 15073
Modified:
main/branches/2.1.7/pym/portage/__init__.py
Log:
Tweak movefile() timestamp preservation code to maximize precision for old
timestamps that are closer to the epoch. (trunk r15039)
Modified: main/branches/2.1.7/pym/portage/__init__.py
===================================================================
--- main/branches/2.1.7/pym/portage/__init__.py 2009-12-13 03:51:39 UTC (rev 15072)
+++ main/branches/2.1.7/pym/portage/__init__.py 2009-12-13 03:51:52 UTC (rev 15073)
@@ -7676,28 +7676,28 @@
else:
# Prevent mtime from rounding up to the next second.
int_mtime = sstat[stat.ST_MTIME]
- mtime_str = "%i.9999999" % int_mtime
- min_len = len(str(int_mtime)) + 2
- while True:
- mtime_str = mtime_str[:-1]
- newmtime = float(mtime_str)
- if int_mtime == long(newmtime):
- another_digit = None
- for i in range(1, 9):
- i_str = str(i)
- if int_mtime != long(float(mtime_str + i_str)):
- break
- else:
- another_digit = i_str
- if another_digit is not None:
- mtime_str += another_digit
- newmtime = float(mtime_str)
+ mtime_str = "%i." % int_mtime
+ digits = 0
+ max_digits = 9
+ while digits < max_digits:
+ if int_mtime == long(float(mtime_str + "9")):
+ mtime_str += "9"
+ digits += 1
+ else:
+ if digits < max_digits:
+ another_digit = None
+ for i in range(1, 9):
+ i_str = str(i)
+ if int_mtime != \
+ long(float(mtime_str + i_str)):
+ break
+ else:
+ another_digit = i_str
+ if another_digit is not None:
+ mtime_str += another_digit
+ digits += 1
break
- elif len(mtime_str) <= min_len:
- # This shouldn't happen, but let's make sure
- # we can never have an infinite loop.
- newmtime = int_mtime
- break
+ newmtime = float(mtime_str)
os.utime(dest, (newmtime, newmtime))
newmtime = sstat[stat.ST_MTIME]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-12-13 3:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-13 3:51 [gentoo-commits] portage r15073 - main/branches/2.1.7/pym/portage Zac Medico (zmedico)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox